-
-
Notifications
You must be signed in to change notification settings - Fork 76
160 lines (154 loc) · 5.5 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
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
MYSQL_HOSTNAME: 'mysql-a'
MYSQL_HOSTNAME_A: 'mysql-a'
MYSQL_HOSTNAME_B: 'mysql-b'
MYSQL_DATABASE: 'test_database'
MYSQL_DATABASE_A: 'test_database'
MYSQL_DATABASE_B: 'test_database'
MYSQL_USERNAME: 'test_username'
MYSQL_USERNAME_A: 'test_username'
MYSQL_USERNAME_B: 'test_username'
MYSQL_PASSWORD: 'test_password'
MYSQL_PASSWORD_A: 'test_password'
MYSQL_PASSWORD_B: 'test_password'
jobs:
api-breakage:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.8-jammy
steps:
- name: Check out code
uses: actions/checkout@v3
with: { 'fetch-depth': 0 }
- name: Run API breakage check action
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@reusable-workflows
dependents:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
services:
mysql-a:
image: ${{ matrix.dbimage }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_USER: test_username
MYSQL_PASSWORD: test_password
MYSQL_DATABASE: test_database
mysql-b:
image: ${{ matrix.dbimage }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_USER: test_username
MYSQL_PASSWORD: test_password
MYSQL_DATABASE: test_database
container: swift:5.8-jammy
strategy:
fail-fast: false
matrix:
dbimage:
- mysql:5.7
- mysql:8.0
- mariadb:11
- percona:8.0
steps:
- name: Check out package
uses: actions/checkout@v3
with: { path: 'mysql-kit' }
- name: Check out dependent
uses: actions/checkout@v3
with:
repository: vapor/fluent-mysql-driver
path: fluent-mysql-driver
- name: Use local package
run: swift package --package-path fluent-mysql-driver edit mysql-kit --path ./mysql-kit
- name: Run tests with Thread Sanitizer
run: swift test --package-path fluent-mysql-driver --sanitize=thread
# Run unit tests (Linux), do code coverage in same job to cut down on extra builds
linux-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
dbimage:
- mysql:5.7
- mysql:8.0
- mariadb:10.4
- mariadb:11
- percona:8.0
runner:
# List is deliberately incomplete; we want to avoid running 50 jobs on every commit
- swift:5.6-focal
- swift:5.8-jammy
- swiftlang/swift:nightly-5.9-jammy
container: ${{ matrix.runner }}
runs-on: ubuntu-latest
services:
mysql-a:
image: ${{ matrix.dbimage }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_USER: test_username
MYSQL_PASSWORD: test_password
MYSQL_DATABASE: test_database
steps:
- name: Save MySQL version to env
run: |
echo MYSQL_VERSION='${{ matrix.dbimage }}' >> $GITHUB_ENV
- name: Display versions
shell: bash
run: |
if [[ '${{ contains(matrix.container, 'nightly') }}' == 'true' ]]; then
SWIFT_PLATFORM="$(source /etc/os-release && echo "${ID}${VERSION_ID}")" SWIFT_VERSION="$(cat /.swift_tag)"
printf 'SWIFT_PLATFORM=%s\nSWIFT_VERSION=%s\n' "${SWIFT_PLATFORM}" "${SWIFT_VERSION}" >>"${GITHUB_ENV}"
fi
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version
- name: Check out package
uses: actions/checkout@v3
- name: Run local tests with coverage and TSan
run: swift test --enable-code-coverage --sanitize=thread
- name: Submit coverage report to Codecov.io
uses: vapor/[email protected]
with:
cc_env_vars: 'SWIFT_VERSION,SWIFT_PLATFORM,RUNNER_OS,RUNNER_ARCH,MYSQL_VERSION'
# Run unit tests (macOS). Don't bother with lots of variations, Linux will cover that.
macos-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
formula: [ '[email protected]' ]
macos: [ 'macos-13' ]
xcode: [ 'latest-stable' ]
runs-on: ${{ matrix.macos }}
steps:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode }}
- name: Install MySQL server from Homebrew
run: brew install ${{ matrix.formula }} && brew link --force ${{ matrix.formula }}
- name: Start MySQL server
run: brew services start ${{ matrix.formula }}
- name: Wait for MySQL server to be ready
run: until echo | mysql -uroot; do sleep 1; done
timeout-minutes: 5
- name: Set up MySQL databases and privileges
run: |
mysql -uroot --batch <<-'SQL'
CREATE USER test_username@localhost IDENTIFIED BY 'test_password';
CREATE DATABASE test_database;
GRANT ALL PRIVILEGES ON test_database.* TO test_username@localhost;
SQL
- name: Check out code
uses: actions/checkout@v3
- name: Run tests with Thread Sanitizer
run: swift test --sanitize=thread
env: { MYSQL_HOSTNAME: '127.0.0.1' }