-
-
Notifications
You must be signed in to change notification settings - Fork 70
205 lines (197 loc) · 6.88 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
push: { branches: [ main ] }
env:
LOG_LEVEL: info
SWIFT_DETERMINISTIC_HASHING: 1
POSTGRES_HOSTNAME: 'psql-a'
POSTGRES_HOSTNAME_A: 'psql-a'
POSTGRES_HOSTNAME_B: 'psql-b'
POSTGRES_DB: 'test_database'
POSTGRES_DB_A: 'test_database'
POSTGRES_DB_B: 'test_database'
POSTGRES_USER: 'test_username'
POSTGRES_USER_A: 'test_username'
POSTGRES_USER_B: 'test_username'
POSTGRES_PASSWORD: 'test_password'
POSTGRES_PASSWORD_A: 'test_password'
POSTGRES_PASSWORD_B: 'test_password'
jobs:
# Check for API breakage versus main
api-breakage:
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:jammy
steps:
- name: Checkout
uses: actions/checkout@v4
with: { 'fetch-depth': 0 }
- name: API breaking changes
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
swift package diagnose-api-breaking-changes origin/main
dependency-graph:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
container: swift:jammy
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Fix Git configuration
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
apt-get update && apt-get install -y curl
- name: Submit dependency graph
uses: vapor-community/swift-dependency-submission@v0.1
code-coverage:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:jammy
services:
psql-a:
image: postgres:16
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Run unit tests for coverage data
run: swift test --enable-code-coverage
- name: Upload coverage data
uses: vapor/swift-codecov-action@v0.2
gh-codeql:
if: ${{ false && !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container:
image: swift:5.10-jammy
permissions: { actions: write, contents: read, security-events: write }
timeout-minutes: 60
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Mark repo safe in non-fake global config
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Check Swift compatibility
id: swift-check
uses: vapor/ci/.github/actions/check-compatible-swift@main
- name: Initialize CodeQL
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
uses: github/codeql-action/init@v3
with: { languages: swift }
- name: Perform build
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
run: swift build
- name: Run CodeQL analyze
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
uses: github/codeql-action/analyze@v3
linux-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
postgres-image:
- postgres:16
- postgres:14
- postgres:12
swift-image:
- swift:5.8-jammy
- swift:5.9-jammy
- swift:5.10-jammy
- swiftlang/swift:nightly-main-jammy
include:
- postgres-image: postgres:16
postgres-auth: scram-sha-256
- postgres-image: postgres:14
postgres-auth: md5
- postgres-image: postgres:12
postgres-auth: trust
runs-on: ubuntu-latest
container: ${{ matrix.swift-image }}
services:
psql-a:
image: ${{ matrix.postgres-image }}
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }}
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }}
steps:
- name: Check out package
uses: actions/checkout@v4
- name: Run local tests
run: swift test
linux-integration:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.10-jammy
services:
psql-a:
image: postgres:16
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
psql-b:
image: postgres:15
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
steps:
- name: Check out package
uses: actions/checkout@v4
with: { path: 'postgres-kit' }
- name: Check out fluent-postgres-driver dependent
uses: actions/checkout@v4
with: { repository: 'vapor/fluent-postgres-driver', path: 'fluent-postgres-driver' }
- name: Use local package
run: swift package --package-path fluent-postgres-driver edit postgres-kit --path postgres-kit
- name: Run fluent-postgres-kit tests
run: swift test --package-path fluent-postgres-driver
macos-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
include:
- macos-version: macos-13
xcode-version: '~14.3'
- macos-version: macos-14
xcode-version: latest
runs-on: ${{ matrix.macos-version }}
env:
POSTGRES_HOSTNAME: 127.0.0.1
POSTGRES_DB: postgres
steps:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Install Postgres, setup DB and auth, and wait for server start
run: |
brew upgrade || true
export PATH="$(brew --prefix)/opt/postgresql@14/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
(brew unlink postgresql@14 || true) && brew install "postgresql@15" && brew link --force "postgresql@15"
initdb --locale=C --auth-host "scram-sha-256" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
pg_ctl start --wait
timeout-minutes: 15
- name: Checkout code
uses: actions/checkout@v4
- name: Run local tests
run: swift test