ci: split dev/prod test and race jobs into parallel matrix
CI / Go vulnerabilities (push) Successful in 36s
CI / Build & Vet (push) Successful in 46s
CI / Frontend lint & types (push) Successful in 2m13s
CI / Tests (prod) (push) Successful in 1m28s
CI / Tests (dev) (push) Successful in 2m2s
CI / Race (prod) (push) Successful in 3m8s
CI / Race (dev) (push) Successful in 4m44s
CI / Go vulnerabilities (push) Successful in 36s
CI / Build & Vet (push) Successful in 46s
CI / Frontend lint & types (push) Successful in 2m13s
CI / Tests (prod) (push) Successful in 1m28s
CI / Tests (dev) (push) Successful in 2m2s
CI / Race (prod) (push) Successful in 3m8s
CI / Race (dev) (push) Successful in 4m44s
Extract Build & Vet into a separate gate job. Use matrix strategy for test and race jobs so dev and prod variants run concurrently after vet passes. Cache keys include label to avoid collisions. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+66
-34
@@ -13,8 +13,49 @@ env:
|
|||||||
POSTGRES_DB: mydb
|
POSTGRES_DB: mydb
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
vet:
|
||||||
|
name: Build & Vet
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: sh
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.25"
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Cache Go modules
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}-vet
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
|
||||||
|
- name: Fix node toolcache path for Post-step cleanup
|
||||||
|
run: |
|
||||||
|
mkdir -p /opt/hostedtoolcache/node/22.23.1/x64/bin
|
||||||
|
ln -sf /usr/local/bin/node /opt/hostedtoolcache/node/22.23.1/x64/bin/node
|
||||||
|
|
||||||
|
- run: go build ./...
|
||||||
|
working-directory: backend
|
||||||
|
|
||||||
|
- name: Vet (dev tags)
|
||||||
|
run: go vet -tags "test,dev" ./...
|
||||||
|
working-directory: backend
|
||||||
|
|
||||||
|
- name: Vet (prod tags)
|
||||||
|
run: go vet -tags "test,!dev" ./...
|
||||||
|
working-directory: backend
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Tests
|
name: Tests (${{ matrix.label }})
|
||||||
|
needs: [vet]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -31,6 +72,15 @@ jobs:
|
|||||||
--health-interval 10s
|
--health-interval 10s
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- label: dev
|
||||||
|
gotags: test,dev
|
||||||
|
verbose: -v
|
||||||
|
- label: prod
|
||||||
|
gotags: test,!dev
|
||||||
|
verbose: ""
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -46,7 +96,7 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
~/go/pkg/mod
|
~/go/pkg/mod
|
||||||
~/.cache/go-build
|
~/.cache/go-build
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}-test
|
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}-test-${{ matrix.label }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go-
|
||||||
|
|
||||||
@@ -65,33 +115,16 @@ jobs:
|
|||||||
|
|
||||||
- run: PGPASSWORD=mypassword psql -h postgres -U myuser -d mydb -c "CREATE DATABASE crussell_test_db;" 2>/dev/null || true
|
- run: PGPASSWORD=mypassword psql -h postgres -U myuser -d mydb -c "CREATE DATABASE crussell_test_db;" 2>/dev/null || true
|
||||||
|
|
||||||
- run: go build ./...
|
- name: Test (${{ matrix.label }} tags)
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
|
run: go test -tags "${{ matrix.gotags }}" -count=1 ${{ matrix.verbose }} -timeout 180s ./...
|
||||||
- name: Vet (dev tags)
|
|
||||||
run: go vet -tags "test,dev" ./...
|
|
||||||
working-directory: backend
|
|
||||||
|
|
||||||
- name: Vet (prod tags)
|
|
||||||
run: go vet -tags "test,!dev" ./...
|
|
||||||
working-directory: backend
|
|
||||||
|
|
||||||
- name: Test (dev tags)
|
|
||||||
working-directory: backend
|
|
||||||
run: go test -tags "test,dev" -count=1 -v -timeout 180s ./...
|
|
||||||
env:
|
|
||||||
POSTGRES_HOST: postgres
|
|
||||||
TEST_DB_HOST: postgres
|
|
||||||
|
|
||||||
- name: Test (prod tags — behavioral ratelimit, prod-only compile)
|
|
||||||
working-directory: backend
|
|
||||||
run: go test -tags "test,!dev" -count=1 -timeout 180s ./...
|
|
||||||
env:
|
env:
|
||||||
POSTGRES_HOST: postgres
|
POSTGRES_HOST: postgres
|
||||||
TEST_DB_HOST: postgres
|
TEST_DB_HOST: postgres
|
||||||
|
|
||||||
race:
|
race:
|
||||||
name: Race detector
|
name: Race (${{ matrix.label }})
|
||||||
|
needs: [vet]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -108,6 +141,13 @@ jobs:
|
|||||||
--health-interval 10s
|
--health-interval 10s
|
||||||
--health-timeout 5s
|
--health-timeout 5s
|
||||||
--health-retries 5
|
--health-retries 5
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- label: dev
|
||||||
|
gotags: test,dev
|
||||||
|
- label: prod
|
||||||
|
gotags: test,!dev
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -123,7 +163,7 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
~/go/pkg/mod
|
~/go/pkg/mod
|
||||||
~/.cache/go-build
|
~/.cache/go-build
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}-race
|
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}-race-${{ matrix.label }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-go-
|
${{ runner.os }}-go-
|
||||||
|
|
||||||
@@ -142,17 +182,9 @@ jobs:
|
|||||||
|
|
||||||
- run: PGPASSWORD=mypassword psql -h postgres -U myuser -d mydb -c "CREATE DATABASE crussell_test_db;" 2>/dev/null || true
|
- run: PGPASSWORD=mypassword psql -h postgres -U myuser -d mydb -c "CREATE DATABASE crussell_test_db;" 2>/dev/null || true
|
||||||
|
|
||||||
- name: Race (dev tags)
|
- name: Race (${{ matrix.label }} tags)
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: go test -tags "test,dev" -race -count=1 -timeout 240s ./...
|
run: go test -tags "${{ matrix.gotags }}" -race -count=1 -timeout 240s ./...
|
||||||
env:
|
|
||||||
POSTGRES_HOST: postgres
|
|
||||||
TEST_DB_HOST: postgres
|
|
||||||
CGO_ENABLED: "1"
|
|
||||||
|
|
||||||
- name: Race (prod tags)
|
|
||||||
working-directory: backend
|
|
||||||
run: go test -tags "test,!dev" -race -count=1 -timeout 240s ./...
|
|
||||||
env:
|
env:
|
||||||
POSTGRES_HOST: postgres
|
POSTGRES_HOST: postgres
|
||||||
TEST_DB_HOST: postgres
|
TEST_DB_HOST: postgres
|
||||||
|
|||||||
Reference in New Issue
Block a user