11name : Test Matrix
2+
23on :
3- - pull_request
4+ pull_request :
5+ push :
6+ branches :
7+ - master
8+
9+ defaults :
10+ run :
11+ shell : bash
12+
413jobs :
5- linux :
14+
15+ Linux :
16+ runs-on : ubuntu-latest
617 strategy :
718 fail-fast : false
819 matrix :
9- dbimage :
10- - postgres:11
11- - postgres:12
12- runner :
20+ image :
1321 # 5.2 Stable
1422 - swift:5.2-xenial
1523 - swift:5.2-bionic
@@ -25,30 +33,44 @@ jobs:
2533 - swiftlang/swift:nightly-master-focal
2634 - swiftlang/swift:nightly-master-centos8
2735 - 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 }}
3047 services :
3148 postgres-a :
3249 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 }
3751 postgres-b :
3852 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
4359 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
4569 uses : actions/checkout@v2
4670 - name : Run tests with Thread Sanitizer
4771 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 :
5274 strategy :
5375 fail-fast : false
5476 matrix :
@@ -57,35 +79,30 @@ jobs:
5779 datadir : postgresql@11
5880 - formula : postgresql@12
5981 datadir : postgres
82+ env :
83+ POSTGRES_DATABASE_A : vapor_database_a
84+ POSTGRES_DATABASE_B : vapor_database_b
6085 runs-on : macos-latest
61- env :
62- PGPASSWORD : vapor_password
6386 steps :
6487 - name : Select latest available Xcode
6588 uses : maxim-lobanov/setup-xcode@1.0
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
80100 run : |
81101 createuser --createdb --login vapor_username
82- for db in vapor_{database_a,database_b }; do
102+ for db in vapor_database_{a,b }; do
83103 createdb -Ovapor_username $db && psql $db <<<"ALTER SCHEMA public OWNER TO vapor_username;"
84104 done
85- - name : Check out code
105+ - name : Checkout code
86106 uses : actions/checkout@v2
87107 - name : Run tests with Thread Sanitizer
88108 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