1
1
name : test
2
2
on :
3
- pull_request :
3
+ pull_request : { branches: ['*'] }
4
4
push : { branches: [ main ] }
5
- defaults :
6
- run :
7
- shell : bash
5
+
6
+ env :
7
+ LOG_LEVEL : debug
8
+ SWIFT_DETERMINISTIC_HASHING : 1
9
+ MYSQL_HOSTNAME : ' mysql-a'
10
+ MYSQL_HOSTNAME_A : ' mysql-a'
11
+ MYSQL_HOSTNAME_B : ' mysql-b'
12
+ MYSQL_DATABASE : ' test_database'
13
+ MYSQL_DATABASE_A : ' test_database'
14
+ MYSQL_DATABASE_B : ' test_database'
15
+ MYSQL_USERNAME : ' test_username'
16
+ MYSQL_USERNAME_A : ' test_username'
17
+ MYSQL_USERNAME_B : ' test_username'
18
+ MYSQL_PASSWORD : ' test_password'
19
+ MYSQL_PASSWORD_A : ' test_password'
20
+ MYSQL_PASSWORD_B : ' test_password'
21
+
8
22
jobs :
23
+
24
+ codecov :
25
+ strategy :
26
+ # For MySQL we have to run coverage baselines against multiple DB versions thanks to
27
+ # the driver's behavior changing notably depending on the server.
28
+ matrix : { dbimage: ['mysql:5.7', 'mysql:8.0', 'mariadb:10.7'] }
29
+ runs-on : ubuntu-latest
30
+ container : swift:5.7-jammy
31
+ services :
32
+ mysql-a :
33
+ image : ${{ matrix.dbimage }}
34
+ env :
35
+ MYSQL_ALLOW_EMPTY_PASSWORD : " true"
36
+ MYSQL_USER : test_username
37
+ MYSQL_PASSWORD : test_password
38
+ MYSQL_DATABASE : test_database
39
+ steps :
40
+ - name : Save MySQL version to env
41
+ run : |
42
+ echo MYSQL_VERSION='${{ matrix.dbimage }}' >> $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,MYSQL_VERSION'
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
+
72
+ # Test integration with downstream Fluent driver
9
73
dependents :
74
+ if : github.event_name == 'pull_request'
10
75
runs-on : ubuntu-latest
11
76
services :
12
77
mysql-a :
13
78
image : ${{ matrix.dbimage }}
14
79
env :
15
80
MYSQL_ALLOW_EMPTY_PASSWORD : " true"
16
- MYSQL_USER : vapor_username
17
- MYSQL_PASSWORD : vapor_password
18
- MYSQL_DATABASE : vapor_database
81
+ MYSQL_USER : test_username
82
+ MYSQL_PASSWORD : test_password
83
+ MYSQL_DATABASE : test_database
19
84
mysql-b :
20
85
image : ${{ matrix.dbimage }}
21
86
env :
22
87
MYSQL_ALLOW_EMPTY_PASSWORD : " true"
23
- MYSQL_USER : vapor_username
24
- MYSQL_PASSWORD : vapor_password
25
- MYSQL_DATABASE : vapor_database
26
- container : swift:5.6-focal
88
+ MYSQL_USER : test_username
89
+ MYSQL_PASSWORD : test_password
90
+ MYSQL_DATABASE : test_database
91
+ container : swift:5.7-jammy
27
92
strategy :
28
93
fail-fast : false
29
94
matrix :
95
+ # Same minimum all-behavior set as the code coverage runs
30
96
dbimage :
31
97
- mysql:5.7
32
98
- mysql:8.0
33
- - mariadb:10.3
34
99
- mariadb:10.7
35
- - percona:8.0
36
100
dependent :
37
101
- fluent-mysql-driver
38
102
steps :
@@ -49,15 +113,13 @@ jobs:
49
113
- name : Use local package
50
114
run : swift package edit mysql-kit --path ../package
51
115
working-directory : dependent
52
- - name : Run tests with Thread Sanitizer
116
+ - name : Run tests with Thread Sanitizer
53
117
run : swift test --sanitize=thread
54
118
working-directory : dependent
55
- env :
56
- MYSQL_HOSTNAME : mysql-a
57
- MYSQL_HOSTNAME_A : mysql-a
58
- MYSQL_HOSTNAME_B : mysql-b
59
- LOG_LEVEL : info
60
- linux :
119
+
120
+ # Run unit tests (Linux)
121
+ linux-unit :
122
+ if : github.event_name == 'pull_request'
61
123
strategy :
62
124
fail-fast : false
63
125
matrix :
@@ -68,46 +130,39 @@ jobs:
68
130
- mariadb:10.7
69
131
- percona:8.0
70
132
runner :
71
- - swift:5.5-focal
133
+ - swift:5.5-bionic
72
134
- swift:5.6-focal
73
- - swiftlang/swift:nightly-main-focal
135
+ - swift:5.7-jammy
136
+ - swiftlang/swift:nightly-main-jammy
74
137
container : ${{ matrix.runner }}
75
138
runs-on : ubuntu-latest
76
139
services :
77
- mysql :
140
+ mysql-a :
78
141
image : ${{ matrix.dbimage }}
79
142
env :
80
143
MYSQL_ALLOW_EMPTY_PASSWORD : " true"
81
- MYSQL_USER : vapor_username
82
- MYSQL_PASSWORD : vapor_password
83
- MYSQL_DATABASE : vapor_database
144
+ MYSQL_USER : test_username
145
+ MYSQL_PASSWORD : test_password
146
+ MYSQL_DATABASE : test_database
84
147
steps :
85
148
- name : Check out code
86
149
uses : actions/checkout@v3
87
150
- name : Run tests with Thread Sanitizer
88
151
run : swift test --sanitize=thread
89
- env :
90
- MYSQL_HOSTNAME : mysql
91
- LOG_LEVEL : info
92
- macOS :
152
+
153
+ # Run unit tests (macOS). Don't bother with lots of variations, Linux will cover that.
154
+ macos-unit :
155
+ if : github.event_name == 'pull_request'
93
156
strategy :
94
157
fail-fast : false
95
158
matrix :
96
- formula :
97
- - mysql
98
- - mysql@5.7
99
- - percona-server
100
- - mariadb
159
+ formula :
160
+ - mysql@8.0
101
161
macos :
102
162
- macos-11
103
163
- macos-12
104
164
xcode :
105
- - latest
106
165
- latest-stable
107
- include :
108
- - username : root
109
- - formula : mariadb
110
- username : runner
111
166
runs-on : ${{ matrix.macos }}
112
167
steps :
113
168
- name : Select latest available Xcode
@@ -119,20 +174,18 @@ jobs:
119
174
- name : Start MySQL server
120
175
run : brew services start ${{ matrix.formula }}
121
176
- name : Wait for MySQL server to be ready
122
- run : until echo | mysql -u${{ matrix.username }} ; do sleep 1; done
177
+ run : until echo | mysql -uroot ; do sleep 1; done
123
178
timeout-minutes : 5
124
179
- name : Set up MySQL databases and privileges
125
180
run : |
126
- mysql -u${{ matrix.username }} --batch <<-'SQL'
127
- CREATE USER vapor_username @localhost IDENTIFIED BY 'vapor_password ';
128
- CREATE DATABASE vapor_database ;
129
- GRANT ALL PRIVILEGES ON vapor_database .* TO vapor_username @localhost;
181
+ mysql -uroot --batch <<-'SQL'
182
+ CREATE USER test_username @localhost IDENTIFIED BY 'test_password ';
183
+ CREATE DATABASE test_database ;
184
+ GRANT ALL PRIVILEGES ON test_database .* TO test_username @localhost;
130
185
SQL
131
186
- name : Check out code
132
187
uses : actions/checkout@v3
133
188
- name : Run tests with Thread Sanitizer
134
189
run : swift test --sanitize=thread
135
190
env :
136
191
MYSQL_HOSTNAME : ' 127.0.0.1'
137
- MYSQL_DATABASE : vapor_database
138
- LOG_LEVEL : info
0 commit comments