Skip to content

Commit 5a24c8b

Browse files
committed
added github workflows
1 parent d64c3e6 commit 5a24c8b

3 files changed

Lines changed: 167 additions & 0 deletions

File tree

.github/workflows/tests.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
php-extensions: mbstring, intl, pdo_sqlsrv-5.9.0preview1
7+
php-tools: "composer:v2, pecl"
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: ['7.2', '7.3', '7.4', '8.0']
15+
16+
fail-fast: false
17+
18+
name: PHP ${{ matrix.php }} tests
19+
20+
services:
21+
mysql57:
22+
image: mysql:5.7
23+
env:
24+
MYSQL_DATABASE: nette_test
25+
MYSQL_ROOT_PASSWORD: root
26+
ports:
27+
- 3306:3306
28+
options: >-
29+
--health-cmd "mysqladmin ping -ppass"
30+
--health-interval 10s
31+
--health-start-period 10s
32+
--health-timeout 5s
33+
--health-retries 10
34+
35+
mysql80:
36+
image: mysql:8.0
37+
ports:
38+
- 3307:3306
39+
options: >-
40+
--health-cmd="mysqladmin ping -ppass"
41+
--health-interval=10s
42+
--health-timeout=5s
43+
--health-retries=5
44+
-e MYSQL_ROOT_PASSWORD=root
45+
-e MYSQL_DATABASE=nette_test
46+
--entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
47+
48+
postgres96:
49+
image: postgres:9.6
50+
env:
51+
POSTGRES_USER: postgres
52+
POSTGRES_PASSWORD: postgres
53+
POSTGRES_DB: nette_test
54+
ports:
55+
- 5432:5432
56+
options: >-
57+
--health-cmd pg_isready
58+
--health-interval 10s
59+
--health-timeout 5s
60+
--health-retries 5
61+
62+
postgres13:
63+
image: postgres:13
64+
env:
65+
POSTGRES_USER: postgres
66+
POSTGRES_PASSWORD: postgres
67+
POSTGRES_DB: nette_test
68+
ports:
69+
- 5433:5432
70+
options: >-
71+
--health-cmd pg_isready
72+
--health-interval 10s
73+
--health-timeout 5s
74+
--health-retries 5
75+
76+
mssql:
77+
image: mcr.microsoft.com/mssql/server:latest
78+
env:
79+
ACCEPT_EULA: Y
80+
SA_PASSWORD: YourStrong!Passw0rd
81+
MSSQL_PID: Developer
82+
ports:
83+
- 1433:1433
84+
options: >-
85+
--name=mssql
86+
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'"
87+
--health-interval 10s
88+
--health-timeout 5s
89+
--health-retries 5
90+
91+
steps:
92+
- uses: actions/checkout@v2
93+
- uses: shivammathur/setup-php@v2
94+
with:
95+
php-version: ${{ matrix.php }}
96+
extensions: ${{ env.php-extensions }}
97+
tools: ${{ env.php-tools }}
98+
coverage: none
99+
100+
- name: Create databases.ini
101+
run: cp ./tests/databases.github.ini ./tests/Database/databases.ini
102+
103+
- name: Create MS SQL Database
104+
run: docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE nette_test'
105+
106+
- run: composer install --no-progress --prefer-dist
107+
- run: vendor/bin/tester -p phpdbg tests -s -C --coverage ./coverage.xml --coverage-src ./src
108+
- if: failure()
109+
uses: actions/upload-artifact@v2
110+
with:
111+
name: output
112+
path: tests/**/output
113+
114+
115+
- name: Save Code Coverage
116+
if: ${{ matrix.php == '8.0' }}
117+
env:
118+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
run: |
120+
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
121+
php php-coveralls.phar --verbose --config tests/.coveralls.yml
122+
123+
124+
lowest_dependencies:
125+
name: Lowest Dependencies
126+
runs-on: ubuntu-latest
127+
steps:
128+
- uses: actions/checkout@v2
129+
- uses: shivammathur/setup-php@v2
130+
with:
131+
php-version: 8.0
132+
coverage: none
133+
134+
- name: Create databases.ini
135+
run: cp ./tests/databases.sqlite.ini ./tests/Database/databases.ini
136+
137+
- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
138+
- run: vendor/bin/tester tests -s -C

tests/databases.github.ini

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[mysql 5.7]
2+
dsn = "mysql:host=127.0.0.1;port=3306;dbname=nette_test"
3+
user = root
4+
password = root
5+
6+
[mysql 8.0]
7+
dsn = "mysql:host=127.0.0.1;port=3307;dbname=nette_test"
8+
user = root
9+
password = root
10+
11+
[postgresql 9.6]
12+
dsn = "pgsql:host=127.0.0.1;port=5432;dbname=nette_test"
13+
user = postgres
14+
password = postgres
15+
16+
[postgresql 13]
17+
dsn = "pgsql:host=127.0.0.1;port=5433;dbname=nette_test"
18+
user = postgres
19+
password = postgres
20+
21+
[sqlsrv]
22+
dsn = "sqlsrv:Server=localhost,1433;Database=nette_test"
23+
user = SA
24+
password = "YourStrong!Passw0rd"
25+
26+
[sqlite]
27+
dsn = "sqlite::memory:"

tests/databases.sqlite.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[sqlite]
2+
dsn = "sqlite::memory:"

0 commit comments

Comments
 (0)