Skip to content

Commit

Permalink
chore(ci): run integration tests on PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed May 16, 2024
1 parent 1c12c8f commit 890627f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
52 changes: 48 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ jobs:
run: npm run lint
- name: VSCode Extension NPM Build
run: just build-extension
integration:
name: Integration Tests
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/integration.yml
build-all:
name: Rebuild All
runs-on: ubuntu-latest
Expand All @@ -146,3 +142,51 @@ jobs:
run: just init-db
- name: Rebuild All
run: just build-all
integration-shard:
name: Shard Integration Tests
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.extract-tests.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Extract test cases
id: extract-tests
run: |
# shellcheck disable=SC2046
echo "matrix={\"test\":$(jq -c -n '$ARGS.positional' --args $(git grep -l '^//go:build integration' | xargs grep '^func Test' | awk '{print $2}' | cut -d'(' -f1))}" >> "$GITHUB_OUTPUT"
integration-run:
name: Integration Test
needs: integration-shard
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.shard.outputs.matrix)}}

Check failure on line 166 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Lint

property "shard" is not defined in object type {integration-shard: {outputs: {matrix: string}; result: string}} [expression]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/activate-hermit@v1
with:
cache: true
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Docker Compose
run: docker compose up -d --wait
- name: Create DB
run: just init-db
- name: Download Go Modules
run: go mod download
- name: Run ${{ matrix.test }}
run: |
# shellcheck disable=SC2046
go test -v -race -tags integration -run ${{ matrix.test }} $(git grep -l '^//go:build integration' | xargs -I {} dirname './{}' | sort | uniq)
integration-success:
name: Integration Success
needs: [integration-run]
runs-on: ubuntu-latest
steps:
- name: Ok
run: echo "Integration tests passed"
17 changes: 12 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ concurrency:
cancel-in-progress: true
name: Integration
jobs:
prepare:
shard:
name: Shard
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.extract-tests.outputs.matrix }}
Expand All @@ -19,13 +20,14 @@ jobs:
id: extract-tests
run: |
# shellcheck disable=SC2046
echo "matrix={\"test\":$(jq -c -n '$ARGS.positional' --args $(grep -r -l '^//go:build integration' integration backend/controller/cronjobs | xargs grep '^func Test' | awk '{print $2}' | cut -d'(' -f1))}" >> "$GITHUB_OUTPUT"
echo "matrix={\"test\":$(jq -c -n '$ARGS.positional' --args $(git grep -l '^//go:build integration' | xargs grep '^func Test' | awk '{print $2}' | cut -d'(' -f1))}" >> "$GITHUB_OUTPUT"
integration:
needs: prepare
name: Test
needs: shard
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
matrix: ${{fromJson(needs.shard.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -42,4 +44,9 @@ jobs:
- name: Download Go Modules
run: go mod download
- name: Run ${{ matrix.test }}
run: go test -v -race -tags integration -run ${{ matrix.test }} ./integration/... ./backend/controller/cronjobs
run: |
# shellcheck disable=SC2046
go test -v -race -tags integration -run ${{ matrix.test }} $(git grep -l '^//go:build integration' | xargs -I {} dirname './{}' | sort | uniq)
success:

Check failure on line 50 in .github/workflows/integration.yml

View workflow job for this annotation

GitHub Actions / Lint

"steps" section is missing in job "success" [syntax-check]
needs: [integration]
runs-on: ubuntu-latest

0 comments on commit 890627f

Please sign in to comment.