Skip to content

Commit

Permalink
ci: Parallelize Go tests jobs (#558)
Browse files Browse the repository at this point in the history
Tests start to take quite a bit of time an in case a specific test kind
fails we have to restart the whole CI job.

To avoid this use a matrix to parallelize the go test jobs and skip the
steps that are not required in each step.

This is not optimal since we still repeat the setup (although some parts
are cached and in general the common part takes less than a minute), but
it still allows to get way faster builds (~ -50%) with a very minimal
effort
  • Loading branch information
3v1n0 authored Sep 27, 2024
2 parents 8468a90 + f92cd88 commit 1ba9bce
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ jobs:
go-tests:
name: "Go: Tests"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ["coverage", "race", "asan"]
steps:
- name: Install dependencies
run: |
Expand Down Expand Up @@ -160,13 +164,16 @@ jobs:
chmod +x ttyd.x86_64
sudo mv ttyd.x86_64 /usr/bin/ttyd
- uses: actions-rs/toolchain@v1
- name: Install rust
if: matrix.test != 'asan'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly # We need nightly to enable instrumentation for coverage.
override: true
components: llvm-tools-preview
- name: Install grcov
if: matrix.test == 'coverage'
run: |
set -eu
cargo install grcov
Expand All @@ -179,6 +186,7 @@ jobs:
echo ASAN_OPTIONS="log_path=${artifacts_dir}/asan.log:print_stats=true" >> $GITHUB_ENV
- name: Run tests (with coverage collection)
if: matrix.test == 'coverage'
env:
G_DEBUG: "fatal-criticals"
run: |
Expand Down Expand Up @@ -208,10 +216,12 @@ jobs:
mv "${raw_cov_dir}"/*.gcov "${cod_cov_dir}"
- name: Run tests (with race detector)
if: matrix.test == 'race'
run: |
go test -timeout ${GO_TESTS_TIMEOUT} -race ./...
- name: Run PAM tests (with Address Sanitizer)
if: matrix.test == 'asan'
env:
# Do not optimize, keep debug symbols and frame pointer for better
# stack trace information in case of ASAN errors.
Expand All @@ -235,6 +245,7 @@ jobs:
exit ${exit_code}
- name: Upload coverage to Codecov
if: matrix.test == 'coverage'
uses: codecov/codecov-action@v4
with:
directory: ./coverage/codecov
Expand All @@ -244,5 +255,5 @@ jobs:
if: failure()
uses: actions/upload-artifact@v4
with:
name: authd-${{ github.job }}-artifacts-${{ github.run_attempt }}
name: authd-${{ github.job }}-${{ matrix.test }}-artifacts-${{ github.run_attempt }}
path: ${{ env.AUTHD_TEST_ARTIFACTS_PATH }}

0 comments on commit 1ba9bce

Please sign in to comment.