Skip to content

Commit dcf78b0

Browse files
authored
Upgrade CI (#382)
1 parent 3561175 commit dcf78b0

File tree

4 files changed

+143
-40
lines changed

4 files changed

+143
-40
lines changed

.github/workflows/test.yml

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,52 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
container:
20+
swift-image:
2121
- swift:5.6-focal
2222
- swift:5.7-jammy
2323
- swift:5.8-jammy
2424
- swiftlang/swift:nightly-5.9-jammy
2525
- swiftlang/swift:nightly-main-jammy
26-
container: ${{ matrix.container }}
26+
include:
27+
- swift-image: swift:5.8-jammy
28+
code-coverage: true
29+
container: ${{ matrix.swift-image }}
2730
runs-on: ubuntu-latest
2831
steps:
29-
- name: Note Swift version
30-
if: ${{ contains(matrix.swiftver, 'nightly') }}
31-
run: |
32-
echo "SWIFT_PLATFORM=$(. /etc/os-release && echo "${ID}${VERSION_ID}")" >>"${GITHUB_ENV}"
33-
echo "SWIFT_VERSION=$(cat /.swift_tag)" >>"${GITHUB_ENV}"
3432
- name: Display OS and Swift versions
33+
shell: bash
3534
run: |
36-
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version
35+
[[ -z "${SWIFT_PLATFORM}" ]] && SWIFT_PLATFORM="$(. /etc/os-release && echo "${ID}${VERSION_ID}")"
36+
[[ -z "${SWIFT_VERSION}" ]] && SWIFT_VERSION="$(cat /.swift_tag 2>/dev/null || true)"
37+
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}"
38+
swift --version
3739
- name: Check out package
3840
uses: actions/checkout@v3
39-
- name: Run unit tests with code coverage and Thread Sanitizer
40-
run: swift test --filter=^PostgresNIOTests --sanitize=thread --enable-code-coverage
41-
- name: Submit coverage report to Codecov.io
42-
uses: vapor/[email protected]
43-
with:
44-
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH'
45-
cc_fail_ci_if_error: false
41+
- name: Run unit tests with Thread Sanitizer
42+
env:
43+
CODE_COVERAGE: ${{ matrix.code-coverage && '--enable-code-coverage' || '' }}
44+
run: |
45+
swift test --filter=^PostgresNIOTests --sanitize=thread ${CODE_COVERAGE}
46+
- name: Submit code coverage
47+
if: ${{ matrix.code-coverage }}
48+
uses: vapor/[email protected]
4649

4750
linux-integration-and-dependencies:
4851
if: github.event_name == 'pull_request'
4952
strategy:
5053
fail-fast: false
5154
matrix:
52-
dbimage:
55+
postgres-image:
5356
- postgres:15
5457
- postgres:13
5558
- postgres:11
5659
include:
57-
- dbimage: postgres:15
58-
dbauth: scram-sha-256
59-
- dbimage: postgres:13
60-
dbauth: md5
61-
- dbimage: postgres:11
62-
dbauth: trust
60+
- postgres-image: postgres:15
61+
postgres-auth: scram-sha-256
62+
- postgres-image: postgres:13
63+
postgres-auth: md5
64+
- postgres-image: postgres:11
65+
postgres-auth: trust
6366
container:
6467
image: swift:5.8-jammy
6568
volumes: [ 'pgrunshare:/var/run/postgresql' ]
@@ -79,29 +82,31 @@ jobs:
7982
POSTGRES_HOSTNAME_A: 'psql-a'
8083
POSTGRES_HOSTNAME_B: 'psql-b'
8184
POSTGRES_SOCKET: '/var/run/postgresql/.s.PGSQL.5432'
82-
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
85+
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }}
8386
services:
8487
psql-a:
85-
image: ${{ matrix.dbimage }}
88+
image: ${{ matrix.postgres-image }}
8689
volumes: [ 'pgrunshare:/var/run/postgresql' ]
8790
env:
8891
POSTGRES_USER: 'test_username'
8992
POSTGRES_DB: 'test_database'
9093
POSTGRES_PASSWORD: 'test_password'
91-
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
92-
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.dbauth }}
94+
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }}
95+
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }}
9396
psql-b:
94-
image: ${{ matrix.dbimage }}
97+
image: ${{ matrix.postgres-image }}
9598
volumes: [ 'pgrunshare:/var/run/postgresql' ]
9699
env:
97100
POSTGRES_USER: 'test_username'
98101
POSTGRES_DB: 'test_database'
99102
POSTGRES_PASSWORD: 'test_password'
100-
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
101-
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.dbauth }}
103+
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }}
104+
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }}
102105
steps:
103106
- name: Display OS and Swift versions
104107
run: |
108+
[[ -z "${SWIFT_PLATFORM}" ]] && SWIFT_PLATFORM="$(. /etc/os-release && echo "${ID}${VERSION_ID}")"
109+
[[ -z "${SWIFT_VERSION}" ]] && SWIFT_VERSION="$(cat /.swift_tag 2>/dev/null || true)"
105110
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version
106111
- name: Check out package
107112
uses: actions/checkout@v3
@@ -128,33 +133,34 @@ jobs:
128133
strategy:
129134
fail-fast: false
130135
matrix:
131-
dbimage:
136+
postgres-formula:
132137
# Only test one version on macOS, let Linux do the rest
133138
- postgresql@14
134-
dbauth:
139+
postgres-auth:
135140
# Only test one auth method on macOS, Linux tests will cover the others
136141
- scram-sha-256
137-
xcode:
138-
- latest-stable
142+
xcode-version:
143+
- '~14.3'
144+
- '15.0-beta'
139145
runs-on: macos-13
140146
env:
141147
POSTGRES_HOSTNAME: 127.0.0.1
142148
POSTGRES_USER: 'test_username'
143149
POSTGRES_PASSWORD: 'test_password'
144150
POSTGRES_DB: 'postgres'
145-
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
151+
POSTGRES_AUTH_METHOD: ${{ matrix.postgres-auth }}
146152
POSTGRES_SOCKET: '/tmp/.s.PGSQL.5432'
147-
POSTGRES_VERSION: ${{ matrix.dbimage }}
153+
POSTGRES_FORMULA: ${{ matrix.postgres-formula }}
148154
steps:
149155
- name: Select latest available Xcode
150156
uses: maxim-lobanov/setup-xcode@v1
151157
with:
152-
xcode-version: ${{ matrix.xcode }}
158+
xcode-version: ${{ matrix.xcode-version }}
153159
- name: Install Postgres, setup DB and auth, and wait for server start
154160
run: |
155-
export PATH="$(brew --prefix)/opt/${POSTGRES_VERSION}/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
156-
(brew unlink postgresql || true) && brew install "${POSTGRES_VERSION}" && brew link --force "${POSTGRES_VERSION}"
157-
initdb --locale=C --auth-host "${POSTGRES_HOST_AUTH_METHOD}" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
161+
export PATH="$(brew --prefix)/opt/${POSTGRES_FORMULA}/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
162+
(brew unlink postgresql || true) && brew install "${POSTGRES_FORMULA}" && brew link --force "${POSTGRES_FORMULA}"
163+
initdb --locale=C --auth-host "${POSTGRES_AUTH_METHOD}" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
158164
pg_ctl start --wait
159165
timeout-minutes: 2
160166
- name: Checkout code
@@ -165,7 +171,7 @@ jobs:
165171
api-breakage:
166172
if: github.event_name == 'pull_request'
167173
runs-on: ubuntu-latest
168-
container: swift:5.8-jammy
174+
container: swift:jammy
169175
steps:
170176
- name: Checkout
171177
uses: actions/checkout@v3
@@ -177,3 +183,17 @@ jobs:
177183
- name: API breaking changes
178184
run: swift package diagnose-api-breaking-changes origin/main
179185

186+
gh-codeql:
187+
runs-on: ubuntu-latest
188+
permissions: { security-events: write }
189+
steps:
190+
- name: Check out code
191+
uses: actions/checkout@v3
192+
- name: Initialize CodeQL
193+
uses: github/codeql-action/init@v2
194+
with:
195+
languages: swift
196+
- name: Perform build
197+
run: swift build
198+
- name: Run CodeQL analyze
199+
uses: github/codeql-action/analyze@v2
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 36 additions & 0 deletions
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"theme": {
3+
"aside": {
4+
"border-radius": "6px",
5+
"border-style": "double",
6+
"border-width": "3px"
7+
},
8+
"border-radius": "0",
9+
"button": {
10+
"border-radius": "16px",
11+
"border-width": "1px",
12+
"border-style": "solid"
13+
},
14+
"code": {
15+
"border-radius": "16px",
16+
"border-width": "1px",
17+
"border-style": "solid"
18+
},
19+
"color": {
20+
"fill": {
21+
"dark": "rgb(20, 20, 22)",
22+
"light": "rgb(255, 255, 255)"
23+
},
24+
"psql-blue": "#336791",
25+
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-documentation-intro-accent) 30%, #1f1d1f 100%)",
26+
"documentation-intro-accent": "var(--color-psql-blue)",
27+
"documentation-intro-accent-outer": {
28+
"dark": "rgb(255, 255, 255)",
29+
"light": "rgb(51, 51, 51)"
30+
},
31+
"documentation-intro-accent-inner": {
32+
"dark": "rgb(51, 51, 51)",
33+
"light": "rgb(255, 255, 255)"
34+
}
35+
},
36+
"icons": {
37+
"technology": "/images/vapor-postgres-logo.svg",
38+
"article": "/images/article.svg"
39+
}
40+
},
41+
"features": {
42+
"quickNavigation": {
43+
"enable": true
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)