Skip to content

Commit ef430d8

Browse files
committed
Added Github actions.
1 parent f946cb9 commit ef430d8

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Actions CI
2+
3+
on: ['push', 'pull_request']
4+
5+
jobs:
6+
testsuite:
7+
runs-on: ubuntu-20.04
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
12+
13+
steps:
14+
- name: Setup MySQL latest
15+
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password
16+
17+
- name: Setup PostgreSQL latest
18+
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=test -p 5432:5432 -d postgres
19+
20+
- uses: actions/checkout@v2
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-version }}
26+
ini-values: memory_limit=512M, xdebug.mode=off, phar.readonly=off
27+
coverage: pcov
28+
29+
- name: Get composer cache directory
30+
id: composer-cache
31+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
32+
33+
- name: Get date part for cache key
34+
id: key-date
35+
run: echo "::set-output name=date::$(date +'%Y-%m')"
36+
37+
- name: Cache composer dependencies
38+
uses: actions/cache@v1
39+
with:
40+
path: ${{ steps.composer-cache.outputs.dir }}
41+
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
42+
43+
- name: Composer install
44+
run: composer update --no-interaction --prefer-dist --no-progress
45+
46+
- name: Setup Database
47+
run: |
48+
n=0
49+
until [ "$n" -ge 5 ]
50+
do
51+
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE test_db;' && break || :
52+
n=$((n+1))
53+
sleep 2
54+
done
55+
mysql -h 127.0.0.1 -u root -proot -D test_db -e 'SELECT 1;'
56+
psql -c 'CREATE DATABASE test_db;' postgresql://postgres:[email protected]
57+
58+
- name: Run tests
59+
run: |
60+
export SKIP_DB_TESTS=0;
61+
export POSTGRESQL_USER='postgres';
62+
export POSTGRESQL_PASSWORD='postgres';
63+
export MYSQL_USER='root';
64+
export MYSQL_PASSWORD='root';
65+
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
66+
export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
67+
else
68+
vendor/bin/phpunit --verbose
69+
fi
70+
71+
- name: Submit code coverage
72+
if: matrix.php-version == '7.4'
73+
uses: codecov/codecov-action@v1

0 commit comments

Comments
 (0)