-
Notifications
You must be signed in to change notification settings - Fork 8
88 lines (77 loc) · 3.11 KB
/
build.yaml
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
name: build
on:
push:
pull_request:
jobs:
tests:
name: Unit tests on PHP ${{ matrix.php }} and ${{ matrix.db }}
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '8.2.7' ]
db: [ 'MySQL', 'PostgreSQL', 'SQLite' ]
include:
- db: MySQL
phpunitArgs: "--exclude-group postgres,sqlite3"
phpunitEnv: db=mysql # from config/test/config.php
- db: PostgreSQL
phpunitArgs: "--exclude-group mysql,sqlite3"
phpunitEnv: db=postgres # from config/test/config.php
- db: SQLite
phpunitArgs: "--exclude-group mysql,postgres,non-sqlite3"
phpunitEnv: db=sqlite3 # from config/test/config.php
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: ouzo_test
MYSQL_ROOT_PASSWORD: password
# Set health checks to wait until mysql has started
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 3306:3306
postgres:
image: postgres:10.0
env:
POSTGRES_DB: ouzo_test
POSTGRES_USER: ouzo_user
POSTGRES_PASSWORD: password
# Set health checks to wait until postgres has started
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: "${{ matrix.coverage }}"
- name: Seed database (PostgreSQL)
if: "${{ matrix.db == 'PostgreSQL' }}"
run: PGPASSWORD=password psql -h 127.0.0.1 -U ouzo_user -v ON_ERROR_STOP=1 -e -f test/test-db/recreate_schema.sql ouzo_test
- name: Seed database (MySQL)
if: "${{ matrix.db == 'MySQL' }}"
run: |
mysql -h 127.0.0.1 -u root -ppassword -e "CREATE USER travis; GRANT ALL ON *.* TO travis;"
cat test/test-db/recreate_schema_mysql.sql | mysql -h 127.0.0.1 -u root -ppassword ouzo_test
- name: Seed database (SQLite)
if: "${{ matrix.db == 'SQLite' }}"
run: echo | sqlite3 ouzo_test -init test/test-db/recreate_schema_sqlite3.sql
# I don't know how to run sqlite without it going into interactive mode, so I piped empty stream to it
- name: Cache dependencies installed with Composer
uses: actions/cache@v1
with:
path: ~/.cache/composer
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php${{ matrix.php }}-composer-
- name: Install dependencies
run: composer install --no-progress;
- name: Run tests
run: ${{ matrix.phpunitEnv }} ./vendor/bin/phpunit ${{ matrix.phpunitArgs }} test
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v