-
-
Notifications
You must be signed in to change notification settings - Fork 213
170 lines (149 loc) · 6.29 KB
/
test-unit.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Unit Tests
on:
push:
pull_request:
env:
MYSQL_DATABASE: app
MYSQL_ROOT_PASSWORD: 'Database Password for Continuous Integration'
#CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_ID: 8948074581c1ffe7f4e47995c65d7d303882310256edd73536723d7c92adb1e3
jobs:
test-unit:
strategy:
fail-fast: false
matrix:
interpreter:
- image: php:7.4
- image: php:8.1
- image: php:8.2
- image: php:8.3
db:
- image: mysql:5.5
- image: bitnami/mysql:8.0
- image: mariadb:10.0
- image: mariadb:10.6
- image: mariadb:10.11
runs-on: ubuntu-latest
container:
image: ${{ matrix.interpreter.image }}
services:
db:
image: ${{ matrix.db.image }}
env:
MYSQL_ROOT_PASSWORD: 'Database Password for Continuous Integration'
MYSQL_DATABASE: 'app'
MYSQL_AUTHENTICATION_PLUGIN: 'mysql_native_password'
MYSQL_CHARACTER_SET: 'utf8mb3'
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Enable Debian backports
run: |
if ! apt-get update; then
sed -i 's#/\(deb\|security\)\.debian\.org/#/archive.debian.org/#g' /etc/apt/sources.list
sed -r -i '/^[^\s#]*[^\s]+\s+[^\s]+\s+[^#]*-updates/d' /etc/apt/sources.list
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99ignore-obsolete
echo 'Acquire::AllowInsecureRepositories "true";' >> /etc/apt/apt.conf.d/99ignore-obsolete
echo 'APT::Get::AllowUnauthenticated "true";' >> /etc/apt/apt.conf.d/99ignore-obsolete
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y full-upgrade
fi
apt-get install -y debian-archive-keyring
grep -m1 -P '^deb http://(deb|archive).debian.org/debian [a-z]+ main' /etc/apt/sources.list |
awk '$3 = $3"-backports"' >> /etc/apt/sources.list
- name: Update operating system software repository
run: apt-get update
- name: Install operating system dependencies
run: |
. /etc/os-release
DEBIAN_RELEASE="$(echo "$VERSION" | grep -oP '^[^(]+\(\K[^)]+')"
USE_GIT_BPO="$(test $VERSION_ID -lt 10 && echo "-t ${DEBIAN_RELEASE}-backports" || echo)"
apt-get $USE_GIT_BPO install -y git zip libzip-dev libbz2-dev libpng-dev libjpeg-dev libwebp-dev libvpx-dev libicu-dev
- name: Configure PHP gd extension with default bundle
run: |
if [ $(php -r 'printf(version_compare(PHP_VERSION, "7.4.0", ">=") ? 1 : 0);') = '1' ]
then
docker-php-ext-configure gd --with-jpeg --with-webp
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "7.0.0", ">=") ? 1 : 0);') = '1' ]
then
docker-php-ext-configure gd --with-jpeg-dir=/usr --with-webp-dir=/usr
else
docker-php-ext-configure gd --with-jpeg-dir=/usr --with-vpx-dir=/usr
fi
- name: Install necessary PHP extensions
run: |
docker-php-ext-install -j "$(nproc)" \
zip bz2 gd pdo_mysql mysqli intl
- name: PECL install xdebug
run: |
if [ $(php -r 'printf(version_compare(PHP_VERSION, "8.2.99", ">=") ? 1 : 0);') = '1' ]
then
pecl install https://xdebug.org/files/xdebug-3.3.0alpha2.tgz
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "8.0.0", ">=") ? 1 : 0);') = '1' ]
then
pecl install xdebug
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "7.2.0", ">=") ? 1 : 0);') = '1' ]
then
pecl install xdebug-3.1.6
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "7.1.0", ">=") ? 1 : 0);') = '1' ]
then
pecl install xdebug-2.9.8
elif [ $(php -r 'printf(version_compare(PHP_VERSION, "7.0.0", ">=") ? 1 : 0);') = '1' ]
then
pecl install xdebug-2.7.2
else
pecl install xdebug-2.5.5
fi
docker-php-ext-enable xdebug
- uses: actions/checkout@v3
- name: Install Composer
run: curl -sSL https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
- name: Install test dependencies
run: composer update --prefer-dist --no-progress
working-directory: ./e107_tests/
- name: Opt out of CVE-2022-24765 mitigation
run: git config --global safe.directory '*'
- name: Download Git submodule dependencies
run: git submodule update --init --recursive --remote
- name: Install the CI test configuration file
run: cp ./e107_tests/lib/ci/config.unit.ci.yml ./e107_tests/config.yml
- name: Download Code Climate test reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
working-directory: ./e107_tests/vendor/bin/
continue-on-error: true
- name: Code Climate report before build
run: ./e107_tests/vendor/bin/cc-test-reporter before-build
continue-on-error: true
- name: Build Codeception
run: php ./vendor/bin/codecept build
working-directory: ./e107_tests/
continue-on-error: false
- name: Run unit tests
run: |
if [ $(php -r 'printf(extension_loaded("xdebug") ? 1 : 0);') = '1' ]
then
php -d xdebug.mode=coverage ./vendor/bin/codecept run unit --steps --debug --coverage --coverage-xml #--coverage-html
else
echo "Warning: xdebug not available; skipping coverage..."
php ./vendor/bin/codecept run unit --steps --debug
fi
working-directory: ./e107_tests/
- name: Send code coverage report to Code Climate
run: |
./e107_tests/vendor/bin/cc-test-reporter format-coverage \
--input-type clover \
--output ./e107_tests/tests/_output/coverage/codeclimate.json \
./e107_tests/tests/_output/coverage.xml
./e107_tests/vendor/bin/cc-test-reporter upload-coverage \
--input ./e107_tests/tests/_output/coverage/codeclimate.json
continue-on-error: true
- name: Upload test output
uses: actions/upload-artifact@v4
with:
name: tests_output_${{ github.run_id }}
path: ./e107_tests/tests/_output/