Skip to content

Commit

Permalink
chore(ci): fast-path for PR status checks (#2282)
Browse files Browse the repository at this point in the history
Heavyweight tests do not run on pull requests, only in the merge queue.

Co-authored-by: gak <[email protected]>
  • Loading branch information
alecthomas and gak authored Aug 7, 2024
1 parent 6a5483a commit 9fd58d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
on:
push:
branches:
- main
pull_request:
merge_group:
name: CI
concurrency:
group: ${{ github.ref }}-ci
Expand All @@ -21,7 +19,8 @@ jobs:
- name: Docker Compose
run: docker compose up -d --wait
- name: Test
run: go-test-annotate
run: |
go-test-annotate ${{ (github.event_name == 'pull_request' && github.event.action != 'enqueued') && '-short' || '' }}
test-readme:
name: Test README
runs-on: ubuntu-latest
Expand Down Expand Up @@ -152,6 +151,7 @@ jobs:
run: just build-extension
build-all:
name: Rebuild All
if: github.event_name != 'pull_request' || github.event.action == 'enqueued'
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -177,6 +177,7 @@ jobs:
- run: cd docs && zola build
integration-shard:
name: Shard Integration Tests
if: github.event_name != 'pull_request' || github.event.action == 'enqueued'
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.extract-tests.outputs.matrix }}
Expand All @@ -192,6 +193,7 @@ jobs:
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
if: github.event_name != 'pull_request' || github.event.action == 'enqueued'
needs: integration-shard
runs-on: ubuntu-latest
strategy:
Expand All @@ -207,15 +209,15 @@ jobs:
- name: Build Cache
uses: ./.github/actions/build-cache
- name: Docker Compose
run: docker compose up -d --wait
run: docker compose --profile integration 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)
go test -v -race -tags integration -run ${{ matrix.test }} $(git grep -l '^//go:build integration' | xargs grep -l '^func ${{ matrix.test }}' | xargs -I {} dirname ./{})
integration-success:
name: Integration Success
needs: [integration-run]
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ services:
- 4318:4318 # OTLP http receiver
localstack:
image: localstack/localstack
profiles:
- integration
ports:
- 4566:4566
environment:
SERVICES: secretsmanager
DEBUG: 1
DEBUG: 1
2 changes: 1 addition & 1 deletion scripts/go-test-annotate
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -euo pipefail
# then match lines containing lines that look like error messages.

fail=0
if ! gotestsum --format-hide-empty-pkg --junitfile junit-go.xml --junitfile-hide-empty-pkg -- -race -fullpath ./...; then
if ! gotestsum --format-hide-empty-pkg --junitfile junit-go.xml --junitfile-hide-empty-pkg -- -race -fullpath "$@" ./...; then
fail=1
fi

Expand Down

0 comments on commit 9fd58d3

Please sign in to comment.