Skip to content

Commit f614fef

Browse files
committed
ci: optimize test matrix - PR uses PG 17 only, main tests all versions
- Split into test-pr (PG 17) and test-main (PG 14-17) jobs - Add concurrency control to cancel superseded runs - Limit main to 2 parallel jobs (max-parallel: 2) - Pull common env vars to workflow level
1 parent 6a27d0c commit f614fef

File tree

1 file changed

+40
-23
lines changed

1 file changed

+40
-23
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,61 @@ on:
88
- main
99
workflow_dispatch:
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: true
14+
1115
env:
1216
CARGO_TERM_COLOR: always
17+
CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
18+
CS_DEFAULT_KEYSET_ID: ${{ secrets.CS_DEFAULT_KEYSET_ID }}
19+
CS_TENANT_KEYSET_ID_1: ${{ secrets.CS_TENANT_KEYSET_ID_1 }}
20+
CS_TENANT_KEYSET_ID_2: ${{ secrets.CS_TENANT_KEYSET_ID_2 }}
21+
CS_TENANT_KEYSET_ID_3: ${{ secrets.CS_TENANT_KEYSET_ID_3 }}
22+
CS_TENANT_KEYSET_NAME_1: ${{ secrets.CS_TENANT_KEYSET_NAME_1 }}
23+
CS_TENANT_KEYSET_NAME_2: ${{ secrets.CS_TENANT_KEYSET_NAME_2 }}
24+
CS_TENANT_KEYSET_NAME_3: ${{ secrets.CS_TENANT_KEYSET_NAME_3 }}
25+
CS_CLIENT_ID: ${{ secrets.CS_CLIENT_ID }}
26+
CS_CLIENT_KEY: ${{ secrets.CS_CLIENT_KEY }}
27+
CS_WORKSPACE_CRN: ${{ secrets.CS_WORKSPACE_CRN }}
28+
RUST_BACKTRACE: "1"
1329

1430
jobs:
15-
test:
31+
# PR: Test against PostgreSQL 17 only for fast feedback
32+
test-pr:
33+
name: Test (PostgreSQL 17)
34+
if: github.event_name == 'pull_request'
35+
runs-on: blacksmith-16vcpu-ubuntu-2204
36+
env:
37+
PG_VERSION: 17
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: ./.github/actions/setup-test
41+
- run: mise run postgres:up --extra-args "--detach --wait"
42+
- run: mise run --output prefix test
43+
- uses: ./.github/actions/send-slack-notification
44+
with:
45+
channel: engineering
46+
webhook_url: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK_URL }}
47+
48+
# Main: Test against all PostgreSQL versions (2 at a time)
49+
test-main:
1650
name: Test (PostgreSQL ${{ matrix.pg_version }})
51+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
1752
runs-on: blacksmith-16vcpu-ubuntu-2204
1853
strategy:
1954
fail-fast: false
55+
max-parallel: 2
2056
matrix:
21-
pg_version: [14, 15, 16, 17] # PG 18 not currently supported
57+
pg_version: [14, 15, 16, 17]
2258
env:
2359
PG_VERSION: ${{ matrix.pg_version }}
2460
steps:
2561
- uses: actions/checkout@v4
2662
- uses: ./.github/actions/setup-test
27-
- run: |
28-
mise run postgres:up --extra-args "--detach --wait"
29-
- env:
30-
# REMEMBER TO ADD ENVIRONMENT VARIABLES TO tests/docker-compose.yml
31-
# The tests/docker-compose.yml config passes the ENV vars into the container
32-
CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
33-
CS_DEFAULT_KEYSET_ID: ${{ secrets.CS_DEFAULT_KEYSET_ID }}
34-
CS_TENANT_KEYSET_ID_1: ${{ secrets.CS_TENANT_KEYSET_ID_1 }}
35-
CS_TENANT_KEYSET_ID_2: ${{ secrets.CS_TENANT_KEYSET_ID_2 }}
36-
CS_TENANT_KEYSET_ID_3: ${{ secrets.CS_TENANT_KEYSET_ID_3 }}
37-
CS_TENANT_KEYSET_NAME_1: ${{ secrets.CS_TENANT_KEYSET_NAME_1 }}
38-
CS_TENANT_KEYSET_NAME_2: ${{ secrets.CS_TENANT_KEYSET_NAME_2 }}
39-
CS_TENANT_KEYSET_NAME_3: ${{ secrets.CS_TENANT_KEYSET_NAME_3 }}
40-
CS_CLIENT_ID: ${{ secrets.CS_CLIENT_ID }}
41-
CS_CLIENT_KEY: ${{ secrets.CS_CLIENT_KEY }}
42-
CS_WORKSPACE_CRN: ${{ secrets.CS_WORKSPACE_CRN }}
43-
RUST_BACKTRACE: "1"
44-
run: |
45-
mise run --output prefix test
46-
63+
- run: mise run postgres:up --extra-args "--detach --wait"
64+
- run: mise run --output prefix test
4765
- uses: ./.github/actions/send-slack-notification
4866
with:
4967
channel: engineering
5068
webhook_url: ${{ secrets.SLACK_NOTIFICATION_WEBHOOK_URL }}
51-

0 commit comments

Comments
 (0)