Skip to content

Commit cccd779

Browse files
committed
Update CI for Postgres 15 + Swift 5.7, add code coverage, add API breakage check
1 parent a8b2839 commit cccd779

File tree

1 file changed

+87
-39
lines changed

1 file changed

+87
-39
lines changed

.github/workflows/test.yml

Lines changed: 87 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,92 @@
11
name: test
2-
on: [ 'pull_request' ]
2+
on:
3+
pull_request: { branches: ['*'] }
4+
push: { branches: ['main'] }
5+
6+
env:
7+
LOG_LEVEL: debug
8+
SWIFT_DETERMINISTIC_HASHING: 1
9+
POSTGRES_HOSTNAME: 'psql-a'
10+
POSTGRES_HOSTNAME_A: 'psql-a'
11+
POSTGRES_HOSTNAME_B: 'psql-b'
12+
POSTGRES_DB: 'test_database'
13+
POSTGRES_DB_A: 'test_database'
14+
POSTGRES_DB_B: 'test_database'
15+
POSTGRES_USER: 'test_username'
16+
POSTGRES_USER_A: 'test_username'
17+
POSTGRES_USER_B: 'test_username'
18+
POSTGRES_PASSWORD: 'test_password'
19+
POSTGRES_PASSWORD_A: 'test_password'
20+
POSTGRES_PASSWORD_B: 'test_password'
321

422
jobs:
23+
# Baseline test run for code coverage stats
24+
codecov:
25+
strategy:
26+
matrix: { dbimage: ['postgres:15'], dbauth: ['scram-sha-256'] }
27+
runs-on: ubuntu-latest
28+
container: swift:5.7-jammy
29+
services:
30+
psql-a:
31+
image: ${{ matrix.dbimage }}
32+
env:
33+
POSTGRES_USER: 'test_username'
34+
POSTGRES_DB: 'test_database'
35+
POSTGRES_PASSWORD: 'test_password'
36+
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
37+
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.dbauth }}
38+
steps:
39+
- name: Save Postgres version and method to env
40+
run: |
41+
echo POSTGRES_VERSION='${{ matrix.dbimage }}' >> $GITHUB_ENV
42+
echo POSTGRES_AUTH_METHOD='${{ matrix.dbauth }}' >> $GITHUB_ENV
43+
- name: Check out package
44+
uses: actions/checkout@v3
45+
- name: Run local tests with coverage
46+
run: swift test --enable-code-coverage
47+
- name: Submit coverage report to Codecov.io
48+
uses: vapor/swift-codecov-action@v0.2
49+
with:
50+
cc_flags: 'unittests'
51+
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,POSTGRES_VERSION,POSTGRES_AUTH_METHOD'
52+
cc_fail_ci_if_error: true
53+
cc_verbose: true
54+
cc_dry_run: false
55+
56+
# Check for API breakage versus main
57+
api-breakage:
58+
if: github.event_name == 'pull_request'
59+
runs-on: ubuntu-latest
60+
container: swift:5.7-jammy
61+
steps:
62+
- name: Check out package
63+
uses: actions/checkout@v3
64+
with:
65+
fetch-depth: 0
66+
# https://github.com/actions/checkout/issues/766
67+
- name: Mark the workspace as safe
68+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
69+
- name: Check for API breaking changes
70+
run: swift package diagnose-api-breaking-changes origin/main
71+
572
linux-all:
73+
if: github.event_name == 'pull_request'
674
strategy:
775
fail-fast: false
876
matrix:
9-
dbimage:
10-
- postgres:14
11-
- postgres:13
12-
- postgres:11
13-
dbauth:
14-
- trust
15-
- md5
16-
- scram-sha-256
17-
swiftver:
18-
- swift:5.4
19-
- swift:5.5
20-
- swift:5.6
21-
- swiftlang/swift:nightly-main
22-
swiftos:
23-
- focal
24-
container: ${{ format('{0}-{1}', matrix.swiftver, matrix.swiftos) }}
77+
dbimage: ['postgres:15', 'postgres:14', 'postgres:11']
78+
swiftver: [
79+
'swift:5.4-focal', 'swift:5.5-focal', 'swift:5.6-focal',
80+
'swift:5.7-jammy',
81+
'swiftlang/swift:nightly-main-jammy'
82+
]
83+
include: [
84+
{dbimage: 'postgres:15', dbauth: 'scram-sha-256'},
85+
{dbimage: 'postgres:14', dbauth: 'md5'},
86+
{dbimage: 'postgres:11', dbauth: 'trust'}
87+
]
88+
container: ${{ matrix.swiftver }}
2589
runs-on: ubuntu-latest
26-
env:
27-
LOG_LEVEL: debug
28-
POSTGRES_DB_A: 'test_database'
29-
POSTGRES_DB_B: 'test_database'
30-
POSTGRES_USER_A: 'test_username'
31-
POSTGRES_USER_B: 'test_username'
32-
POSTGRES_PASSWORD_A: 'test_password'
33-
POSTGRES_PASSWORD_B: 'test_password'
34-
POSTGRES_HOSTNAME_A: 'psql-a'
35-
POSTGRES_HOSTNAME_B: 'psql-b'
36-
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
3790
services:
3891
psql-a:
3992
image: ${{ matrix.dbimage }}
@@ -58,26 +111,21 @@ jobs:
58111
run: swift test
59112

60113
macos-all:
114+
if: github.event_name == 'pull_request'
61115
strategy:
62116
fail-fast: false
63117
matrix:
64-
# Only test latest version and one auth method on macOS
65-
dbimage:
66-
- postgresql@14
67-
dbauth:
68-
- scram-sha-256
118+
dbimage: ['postgresql@14'] # N.B.: As of this writing, Homebrew didn't have Postgres 15 yet
119+
dbauth: ['scram-sha-256']
69120
macos: ['macos-11', 'macos-12']
70-
xcode: ['latest-stable', 'latest']
71-
exclude: [{ macos: 'macos-11', xcode: 'latest' }]
121+
xcode: ['latest-stable']
72122
runs-on: ${{ matrix.macos }}
73123
env:
74124
LOG_LEVEL: debug
125+
POSTGRES_HOSTNAME: 127.0.0.1
75126
POSTGRES_HOSTNAME_A: 127.0.0.1
76127
POSTGRES_HOSTNAME_B: 127.0.0.1
77-
POSTGRES_USER_A: 'test_username'
78-
POSTGRES_USER_B: 'test_username'
79-
POSTGRES_PASSWORD_A: 'test_password'
80-
POSTGRES_PASSWORD_B: 'test_password'
128+
POSTGRES_DB: 'test_database_a'
81129
POSTGRES_DB_A: 'test_database_a'
82130
POSTGRES_DB_B: 'test_database_b'
83131
steps:

0 commit comments

Comments
 (0)