-
Notifications
You must be signed in to change notification settings - Fork 629
155 lines (131 loc) · 5.32 KB
/
tests.yml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
on: [ push, pull_request ]
name: "Tests"
jobs:
run-tests:
name: PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest
env:
extensions: mbstring, intl, json, zip, phalcon-4.0.5, mysql, pgsql, xdebug-2.9.8
key: cache-v2.0~19.03.2020
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: devtools
MYSQL_ROOT_PASSWORD: root
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:10.8
ports:
- 5432/tcp
env:
POSTGRES_DB: devtools
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
strategy:
fail-fast: false
matrix:
php-versions: [ '7.2', '7.3', '7.4' ]
steps:
- uses: actions/checkout@v1
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v1
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
tools: pecl
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: |
composer install --prefer-dist --no-suggest
composer require --dev phpstan/phpstan
- name: Initialise DataBase
env:
MYSQL_DB_PASSWORD: 'root'
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
run: bash tests/_ci/setup_dbs_github.sh
- name: Symbolic link Phalcon devtools
run: sudo ln -s "$(pwd)/phalcon" /usr/local/bin/phalcon
- name: Init Webtools and add ports in database setup
env:
MYSQL_DB_PASSWORD: 'root'
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
run: |
rm -rf webtools
phalcon project --name=webtools
sed -i "s/database->charset/database->charset,\n\t\t'port' => \$config->database->port/g" webtools/app/config/services.php
cd webtools
phalcon webtools enable
phalcon serve &
- name: Setup tests
run: |
cp tests/.env.test .env
sed -i "s/MYSQL_DB_PORT=3306/MYSQL_DB_PORT=$MYSQL_DB_PORT/g" .env
sed -i "s/MYSQL_DB_PASSWORD=''/MYSQL_DB_PASSWORD='$MYSQL_DB_PASSWORD'/g" .env
sed -i "s/POSTGRES_DB_PORT=5432/POSTGRES_DB_PORT=$POSTGRES_DB_PORT/g" .env
mkdir .phalcon
vendor/bin/codecept build
vendor/bin/phpcs
- name: Run test suites
env:
MYSQL_DB_PASSWORD: 'root'
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
if: success()
run: |
vendor/bin/codecept run --ext DotReporter acceptance -g mysql --env mysql
vendor/bin/codecept run --ext DotReporter acceptance -g pgsql --env pgsql
vendor/bin/codecept run --ext DotReporter acceptance -g common --coverage-xml=coverage-common-${{ matrix.php-versions }}.xml
vendor/bin/codecept run --ext DotReporter unit --coverage-xml=coverage-unit-${{ matrix.php-versions }}.xml
vendor/bin/codecept run --ext DotReporter functional --coverage-xml=coverage-functional-${{ matrix.php-versions }}.xml
vendor/bin/codecept run --ext DotReporter console --coverage-xml=coverage-console-${{ matrix.php-versions }}.xml
- name: If fail - Check Config file
env:
MYSQL_DB_PORT: ${{ job.services.mysql.ports['3306'] }}
POSTGRES_DB_PORT: ${{ job.services.postgres.ports['5432'] }}
if: failure()
run: |
cat webtools/app/config/config.php
cat webtools/app/config/services.php
echo "<?php print_r(include('webtools/app/config/config.php')) ?>" > content_config.php
php content_config.php
php tests/debug.php
- uses: actions/upload-artifact@v1
if: failure()
with:
name: Codeception Logs
path: tests/_output
#- name: Check psalm
# run: vendor/bin/psalm --show-info=false
#- name: Check phpstan
# run: vendor/bin/phpstan analyse -l 5 -c phpstan.neon src -v
- name: Upload coverage to Codecov
if: success()
uses: codecov/codecov-action@v1
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./tests/_output/coverage-*.xml