Skip to content

Commit

Permalink
ci: Parallelize Go tests jobs
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 allows to get faster builds with a very minimal effort
  • Loading branch information
3v1n0 committed Sep 27, 2024
1 parent 908d67e commit f92cd88
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 @@ -120,6 +120,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 @@ -159,13 +163,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 @@ -178,6 +185,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 @@ -207,10 +215,12 @@ jobs:
mv "${raw_cov_dir}"/*.gcov "${cod_cov_dir}"
- name: Run tests (with race detector)
if: matrix.test == 'race'
run: |
go test -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 @@ -234,6 +244,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 @@ -243,5 +254,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 f92cd88

Please sign in to comment.