mirror of
https://gitea.com/gitea/runner.git
synced 2026-08-26 22:07:45 +00:00
test: speed up tests (#1181)
Parallelize isolated workflow tests, consolidate redundant fixtures, and replace fixed waits with deterministic synchronization. Keep the readable curl service probe and use `getent` for hostname resolution. Measured on the same machine with `make test`: 1. Wall time: 170.50s to 136.12s, down 34.38s or 20.2%. 1. `act/runner`: 138.417s to 124.291s, down 14.126s or 10.2%. 1. `act/runner` coverage: unchanged at 85.2%. 1. `TestDockerExecAbort`: 2.514s to 0.012s package time. Stability checks: 1. Cancellation and deadline tests: 100 race-enabled repetitions. 1. Host runner suite: 10 race-enabled repetitions. 1. Changed Docker fixtures: 3 consecutive repetitions. Full race suite, Go and Windows lint, source checks, and security scan pass. Assisted-by: Codex:GPT-5 Reviewed-on: https://gitea.com/gitea/runner/pulls/1181 Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
+4
-1
@@ -1,4 +1,4 @@
|
||||
name: issue-597
|
||||
name: issues-597-598
|
||||
on: push
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ jobs:
|
||||
- name: My first true step
|
||||
if: ${{endsWith('Hello world', 'ld')}}
|
||||
run: echo "Renst the Octocat"
|
||||
- name: My second true step
|
||||
if: "!endsWith('Hello world', 'od')"
|
||||
run: echo "Renst the Octocat"
|
||||
- name: My second false step
|
||||
if: "endsWith('Should not evaluate', 'o2')"
|
||||
run: exit 1
|
||||
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
name: issue-598
|
||||
on: push
|
||||
|
||||
|
||||
jobs:
|
||||
my_first_job:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: My first false step
|
||||
if: "endsWith('Hello world', 'o1')"
|
||||
run: exit 1
|
||||
- name: My first true step
|
||||
if: "!endsWith('Hello world', 'od')"
|
||||
run: echo "Renst the Octocat"
|
||||
- name: My second false step
|
||||
if: "endsWith('Hello world', 'o2')"
|
||||
run: exit 1
|
||||
- name: My third false step
|
||||
if: "endsWith('Hello world', 'o2')"
|
||||
run: exit 1
|
||||
@@ -1,11 +0,0 @@
|
||||
name: job-container
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:24-bookworm-slim
|
||||
options: --user 1000
|
||||
steps:
|
||||
- run: echo PASS
|
||||
Vendored
+2
-2
@@ -12,13 +12,13 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, macos-latest]
|
||||
node: [4, 6, 8, 10]
|
||||
node: [4, 10]
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node: [8.x, 10.x, 12.x, 13.x]
|
||||
node: [8.x, 13.x]
|
||||
steps:
|
||||
- run: echo ${NODE_VERSION} | grep ${{ matrix.node }}
|
||||
env:
|
||||
|
||||
+2
-8
@@ -4,11 +4,5 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install tools
|
||||
run: |
|
||||
apt update
|
||||
apt install -y iputils-ping
|
||||
- name: Run hostname test
|
||||
run: |
|
||||
hostname -f
|
||||
ping -c 4 $(hostname -f)
|
||||
- name: Resolve the container hostname
|
||||
run: getent hosts "$(hostname -f)"
|
||||
|
||||
Vendored
+4
-19
@@ -12,32 +12,17 @@ jobs:
|
||||
- id: set_2
|
||||
run: |
|
||||
echo "::set-output name=var_3::$(echo var3)"
|
||||
- id: set_3
|
||||
run: |
|
||||
echo "::set-output name=var_4::$(echo var4)"
|
||||
outputs:
|
||||
variable_1: ${{ steps.set_1.outputs.var_1 }}
|
||||
variable_2: ${{ steps.set_1.outputs.var_2 }}
|
||||
variable_3: ${{ steps.set_2.outputs.var_3 }}
|
||||
variable_4: ${{ steps.set_3.outputs.var_4 }}
|
||||
|
||||
build:
|
||||
needs: build_output
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check set_1 var1
|
||||
- name: Check outputs
|
||||
run: |
|
||||
echo "${{ needs.build_output.outputs.variable_1 }}"
|
||||
echo "${{ needs.build_output.outputs.variable_1 }}" | grep 'var1' || exit 1
|
||||
- name: Check set_1 var2
|
||||
run: |
|
||||
echo "${{ needs.build_output.outputs.variable_2 }}"
|
||||
echo "${{ needs.build_output.outputs.variable_2 }}" | grep 'var2' || exit 1
|
||||
- name: Check set_2 var3
|
||||
run: |
|
||||
echo "${{ needs.build_output.outputs.variable_3 }}"
|
||||
echo "${{ needs.build_output.outputs.variable_3 }}" | grep 'var3' || exit 1
|
||||
- name: Check set_3 var4
|
||||
run: |
|
||||
echo "${{ needs.build_output.outputs.variable_4 }}"
|
||||
echo "${{ needs.build_output.outputs.variable_4 }}" | grep 'var4' || exit 1
|
||||
test "${{ needs.build_output.outputs.variable_1 }}" = var1
|
||||
test "${{ needs.build_output.outputs.variable_2 }}" = var2
|
||||
test "${{ needs.build_output.outputs.variable_3 }}" = var3
|
||||
|
||||
+1
-5
@@ -10,14 +10,10 @@ jobs:
|
||||
ports:
|
||||
- 80
|
||||
steps:
|
||||
- name: Echo the Postgres service ID / Network / Ports
|
||||
run: |
|
||||
echo "id: ${{ job.services.postgres.id }}"
|
||||
echo "network: ${{ job.services.postgres.network }}"
|
||||
echo "ports: ${{ job.services.postgres.ports }}"
|
||||
- name: The job context describes the started containers
|
||||
run: |
|
||||
test -n "${{ job.container.id }}"
|
||||
test -n "${{ job.services.postgres.id }}"
|
||||
test -n "${{ job.services.postgres.ports }}"
|
||||
test -n "${{ job.services.postgres.ports['80'] }}"
|
||||
test "${{ job.services.postgres.network }}" = "${{ job.container.network }}"
|
||||
|
||||
+9
-12
@@ -4,6 +4,9 @@ env:
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
@@ -12,6 +15,12 @@ jobs:
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
- run: |
|
||||
if [[ -n "$BASH" ]]; then
|
||||
echo "I'm $BASH!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
check-container:
|
||||
runs-on: ubuntu-latest
|
||||
container: node:24-bookworm-slim
|
||||
@@ -23,15 +32,3 @@ jobs:
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
check-job-default:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- run: |
|
||||
if [[ -n "$BASH" ]]; then
|
||||
echo "I'm $BASH!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
+3
-6
@@ -3,16 +3,13 @@ env:
|
||||
MY_SHELL: pwsh
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
$PSVersionTable
|
||||
check-job-default:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
$PSVersionTable
|
||||
- run: |
|
||||
$PSVersionTable
|
||||
|
||||
+9
-12
@@ -4,6 +4,9 @@ env:
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- shell: ${{ env.MY_SHELL }}
|
||||
run: |
|
||||
@@ -12,6 +15,12 @@ jobs:
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
- run: |
|
||||
if [ -z ${BASH+x} ]; then
|
||||
echo "I'm sh!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
check-container:
|
||||
runs-on: ubuntu-latest
|
||||
container: alpine:latest
|
||||
@@ -23,15 +32,3 @@ jobs:
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
check-job-default:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ env.MY_SHELL }}
|
||||
steps:
|
||||
- run: |
|
||||
if [ -z ${BASH+x} ]; then
|
||||
echo "I'm sh!"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
name: conclusion
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: first
|
||||
run: exit 0
|
||||
- id: second
|
||||
continue-on-error: true
|
||||
run: exit 1
|
||||
- run: echo '${{ steps.first.conclusion }}' | grep 'success'
|
||||
- run: echo '${{ steps.second.conclusion }}' | grep 'success'
|
||||
@@ -1,14 +0,0 @@
|
||||
name: outcome
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: first
|
||||
run: exit 0
|
||||
- id: second
|
||||
continue-on-error: true
|
||||
run: exit 1
|
||||
- run: echo '${{ steps.first.outcome }}' | grep 'success'
|
||||
- run: echo '${{ steps.second.outcome }}' | grep 'failure'
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
name: steps context
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: first
|
||||
run: exit 0
|
||||
- id: second
|
||||
continue-on-error: true
|
||||
run: exit 1
|
||||
- run: |
|
||||
test '${{ steps.first.conclusion }}' = success
|
||||
test '${{ steps.second.conclusion }}' = success
|
||||
test '${{ steps.first.outcome }}' = success
|
||||
test '${{ steps.second.outcome }}' = failure
|
||||
Reference in New Issue
Block a user