1
1
name : Test Matrix
2
+
2
3
on :
3
- - pull_request
4
+ pull_request :
5
+ push :
6
+ branches :
7
+ - master
8
+
9
+ defaults :
10
+ run :
11
+ shell : bash
12
+
4
13
jobs :
5
- linux :
14
+
15
+ Linux :
16
+ runs-on : ubuntu-latest
6
17
strategy :
7
18
fail-fast : false
8
19
matrix :
9
- dbimage :
10
- - postgres:11
11
- - postgres:12
12
- runner :
20
+ image :
13
21
# 5.2 Stable
14
22
- swift:5.2-xenial
15
23
- swift:5.2-bionic
@@ -25,30 +33,44 @@ jobs:
25
33
- swiftlang/swift:nightly-master-focal
26
34
- swiftlang/swift:nightly-master-centos8
27
35
- swiftlang/swift:nightly-master-amazonlinux2
28
- container : ${{ matrix.runner }}
29
- runs-on : ubuntu-latest
36
+ dbimage :
37
+ - postgres:11
38
+ - postgres:12
39
+ - postgres:13
40
+ include :
41
+ - depscmd : ' apt-get -q update && apt-get -q install -y postgresql-client'
42
+ - image : swiftlang/swift:nightly-master-centos8
43
+ depscmd : ' dnf install -y postgresql'
44
+ - image : swiftlang/swift:nightly-master-amazonlinux2
45
+ depscmd : ' yum install -y postgresql'
46
+ container : ${{ matrix.image }}
30
47
services :
31
48
postgres-a :
32
49
image : ${{ matrix.dbimage }}
33
- env :
34
- POSTGRES_USER : vapor_username
35
- POSTGRES_PASSWORD : vapor_password
36
- POSTGRES_DB : vapor_database
50
+ env : { POSTGRES_USER: vapor_username, POSTGRES_PASSWORD: vapor_password, POSTGRES_DB: vapor_database }
37
51
postgres-b :
38
52
image : ${{ matrix.dbimage }}
39
- env :
40
- POSTGRES_USER : vapor_username
41
- POSTGRES_PASSWORD : vapor_password
42
- POSTGRES_DB : vapor_database
53
+ env : { POSTGRES_USER: vapor_username, POSTGRES_PASSWORD: vapor_password, POSTGRES_DB: vapor_database }
54
+ env :
55
+ POSTGRES_HOSTNAME_A : postgres-a
56
+ POSTGRES_HOSTNAME_B : postgres-b
57
+ PGUSER : vapor_username
58
+ PGPASSWORD : vapor_password
43
59
steps :
44
- - name : Check out code
60
+ - name : Install dependencies
61
+ run : ${{ matrix.depscmd }}
62
+ - name : Compensate for AmazonLinux2's Postgres
63
+ if : ${{ endsWith(matrix.image, 'amazonlinux2') }}
64
+ run : printf '#!/bin/bash\nexec psql "$@" </dev/null\n' >/usr/bin/pg_isready && chmod 0755 /usr/bin/pg_isready
65
+ - name : Wait for database servers to be ready
66
+ run : until pg_isready -hpostgres-a -dvapor_database && pg_isready -hpostgres-b -dvapor_database; do sleep 1; done
67
+ timeout-minutes : 2
68
+ - name : Checkout code
45
69
uses : actions/checkout@v2
46
70
- name : Run tests with Thread Sanitizer
47
71
run : swift test --enable-test-discovery --sanitize=thread
48
- env :
49
- POSTGRES_HOSTNAME_A : postgres-a
50
- POSTGRES_HOSTNAME_B : postgres-b
51
- macos :
72
+
73
+ macOS :
52
74
strategy :
53
75
fail-fast : false
54
76
matrix :
@@ -57,35 +79,30 @@ jobs:
57
79
datadir : postgresql@11
58
80
- formula : postgresql@12
59
81
datadir : postgres
82
+ env :
83
+ POSTGRES_DATABASE_A : vapor_database_a
84
+ POSTGRES_DATABASE_B : vapor_database_b
60
85
runs-on : macos-latest
61
- env :
62
- PGPASSWORD : vapor_password
63
86
steps :
64
87
- name : Select latest available Xcode
65
88
uses :
maxim-lobanov/[email protected]
66
- with :
67
- xcode-version : latest
68
- - name : Blow away the default Postgres installation
69
- run : brew uninstall --force postgresql php && rm -rf /usr/local/{etc,var}/{postgres,pg}*
70
- - name : Install Postgres server from Homebrew
71
- run : brew install ${{ matrix.formula }} && brew link --force ${{ matrix.formula }}
72
- - name : Make sure Postgres has a database, Homebrew fails REALLY bad at this
73
- run : initdb --locale=C -E UTF-8 $(brew --prefix)/var/${{ matrix.datadir }}
74
- - name : Start Postgres server
75
- run : brew services start ${{ matrix.formula }}
76
- - name : Wait for Postgres server to be ready
77
- run : until echo | psql postgres; do sleep 1; done
78
- timeout-minutes : 5
79
- - name : Set up Postgres databases and privileges
89
+ with : { 'xcode-version': 'latest' }
90
+ - name : Replace Postgres install and start server
91
+ run : |
92
+ brew uninstall --force postgresql php && rm -rf /usr/local/{etc,var}/{postgres,pg}*
93
+ brew install ${{ matrix.formula }} && brew link --force ${{ matrix.formula }}
94
+ initdb --locale=C -E UTF-8 $(brew --prefix)/var/${{ matrix.datadir }}
95
+ brew services start ${{ matrix.formula }}
96
+ - name : Wait for server to be ready
97
+ run : until pg_isready; do sleep 1; done
98
+ timeout-minutes : 2
99
+ - name : Setup users and databases for Postgres
80
100
run : |
81
101
createuser --createdb --login vapor_username
82
- for db in vapor_{database_a,database_b }; do
102
+ for db in vapor_database_{a,b }; do
83
103
createdb -Ovapor_username $db && psql $db <<<"ALTER SCHEMA public OWNER TO vapor_username;"
84
104
done
85
- - name : Check out code
105
+ - name : Checkout code
86
106
uses : actions/checkout@v2
87
107
- name : Run tests with Thread Sanitizer
88
108
run : swift test --enable-test-discovery --sanitize=thread
89
- env :
90
- POSTGRES_DATABASE_A : vapor_database_a
91
- POSTGRES_DATABASE_B : vapor_database_b
0 commit comments