-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathaction.yml
288 lines (269 loc) · 11 KB
/
action.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: 'Matomo Tests'
description: 'Runs Matomo Tests'
inputs:
test-type:
type: choice
description: "Type of tests to run"
required: true
options:
- UI
- PluginTests
- JS
- Client
- UnitTests
- SystemTestsPlugins
- SystemTestsCore
- IntegrationTestsCore
- IntegrationTestsPlugins
default: PluginTests
artifacts-pass:
description: "UI upload pass"
required: false
artifacts-protected:
type: boolean
description: "protect uploaded artifacts"
required: false
default: false
plugin-name:
description: "Name of the plugin to test"
required: false
mysql-driver:
description: "Mysql driver to use for testing. (Will be placed as config.ini.php setting)"
required: false
options:
- PDO_MYSQL
- MYSQLI
default: 'PDO_MYSQL'
ui-test-options:
description: "Additional options to run UI tests with"
required: false
phpunit-test-options:
description: "Additional options to run PHPUnit with"
required: false
php-version:
description: 'PHP version to set up for testing. Can be any version supported by shivammathur/setup-php'
required: true
default: ''
node-version:
description: 'Node version to set up for testing'
required: false
default: ''
redis-service:
type: boolean
description: "If true a redis master and sentinel will be set up before testing"
required: false
default: false
mysql-service:
type: boolean
description: "If true a MySQL engine will be set up. "
required: false
default: true
mysql-engine:
description: "MySQL database engine to use. Can be 'Mysql', 'Mariadb' or 'Tidb'"
options:
- Mysql
- Mariadb
- Tidb
required: false
default: 'Mysql'
matomo-test-branch:
description: "Branch or tag name of Matomo to run plugin tests for. This can be either a specific name or maximum_supported_matomo or minimum_required_matomo."
required: false
default: ''
dependent-plugins:
description: "Additional plugins to checkout before testing. space separated list of github slugs. e.g. matomo-org/pluginTasksTimetable"
required: false
default: ''
github-token:
description: "Token used to checkout dependent plugins. Only required if private repo needs to be checked out"
required: false
default: ''
upload-artifacts:
type: boolean
description: "Defines if produced build artifacts should be uploaded or not. Only relevant for System, Plugins and UI tests"
required: false
default: false
setup-script:
description: "Additional setup script to run before starting tests. Can be used by plugin to e.g. set up LDAP or similar."
required: false
default: ''
testomatio:
description: "To enable Testomat.io reporter for tests, Testomat.io token should be set via this input"
required: false
default: ''
runs:
using: "composite"
steps:
- name: start mysql services
if: inputs.mysql-service == 'true' && inputs.mysql-engine == 'Mysql'
shell: bash
run: |
docker run -d --tmpfs /var/lib/mysql:rw --tmpfs /bitnami/mysql/data:rw -v ${{ github.action_path }}/artifacts/my.cnf:/opt/bitnami/mysql/conf/my_custom.cnf:ro --name mysql -p 3306:3306 -e ALLOW_EMPTY_PASSWORD=yes -e MYSQL_DATABASE=matomo_tests bitnami/mysql:5.7
sleep 10
mysql -h127.0.0.1 -uroot -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';SET GLOBAL wait_timeout = 36000;SET GLOBAL max_allowed_packet = 134209536;"
- name: start mariadb services
if: inputs.mysql-service == 'true' && inputs.mysql-engine == 'Mariadb'
shell: bash
run: |
docker run -d --tmpfs /var/lib/mariadb:rw --tmpfs /bitnami/mariadb/data:rw -v ${{ github.action_path }}/artifacts/my.cnf:/opt/bitnami/mariadb/conf/my_custom.cnf:ro --name mariadb -p 3306:3306 -e ALLOW_EMPTY_PASSWORD=yes -e MARIADB_DATABASE=matomo_tests bitnami/mariadb:latest
sleep 10
mysql -h127.0.0.1 -uroot -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';SET GLOBAL wait_timeout = 36000;SET GLOBAL max_allowed_packet = 134209536;"
- name: start tidb services
if: inputs.mysql-service == 'true' && inputs.mysql-engine == 'Tidb'
shell: bash
run: |
docker run -d -p 3306:4000 pingcap/tidb:latest
sleep 10
mysql -h127.0.0.1 -uroot -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';SET GLOBAL wait_timeout = 36000;SET GLOBAL max_allowed_packet = 134209536;CREATE DATABASE matomo_tests;"
- name: start redis serivces
if: inputs.redis-service == 'true'
shell: bash
run: |
docker run -d --name redis -e ALLOW_EMPTY_PASSWORD=yes -p 6379:6379 bitnami/redis:latest
docker run -d --name mymaster -e REDIS_MASTER_HOST=localhost -p 26379:26379 bitnami/redis-sentinel:latest
- name: Setup PHP
if: inputs.php-version != ''
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
extensions: bcmath, ldap, curl, zip, pdo_mysql, mysqli, gd, redis, zlib, opcache
ini-values: |
post_max_size=8M,
memory_limit=768M,
max_execution_time=10000,
always_populate_raw_post_data=-1,
error_reporting=E_ALL,
log_errors=on,
error_log=${{ github.workspace }}/php-errors.log,
display_errors=on,
allow_url_fopen=on,
zend.exception_ignore_args=Off,
mysqli.allow_local_infile=On,
opcache.enable=0
tools: composer:v2
coverage: none
- name: Setup Node
if: inputs.node-version != '' && inputs.plugin-name == ''
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
# Caching doesn't work for plugins as older Matomo releases might not have contained a lock file
- name: Setup Node
if: inputs.node-version != '' && inputs.plugin-name != ''
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
- name: "Add PHPUnit matcher"
if: inputs.test-type != 'UI' && inputs.test-type != 'JS' && inputs.test-type != 'Client'
shell: bash
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
# setup apache etc
- name: checkout matomo for plugin builds
shell: bash
run: ${{ github.action_path }}/scripts/bash/checkout_matomo.sh
if: inputs.plugin-name != ''
env:
PLUGIN_NAME: ${{ inputs.plugin-name }}
WORKSPACE: ${{ github.workspace }}
ACTION_PATH: ${{ github.action_path }}
MATOMO_TEST_TARGET: ${{ inputs.matomo-test-branch }}
TEST_SUITE: ${{ inputs.test-type }}
- name: Get composer cache directory
id: composer-cache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
working-directory: ${{ github.workspace }}/matomo
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-${{ inputs.php-version }}
# setup apache etc
- name: prepare setup
shell: bash
run: ${{ github.action_path }}/scripts/bash/prepare.sh
env:
PHP_VERSION: ${{ inputs.php-version }}
TEST_SUITE: ${{ inputs.test-type }}
MATOMO_TEST_TARGET: ${{ inputs.matomo-test-branch }}
MYSQL_ADAPTER: ${{ inputs.mysql-driver }}
MYSQL_ENGINE: ${{ inputs.mysql-engine }}
PLUGIN_NAME: ${{ inputs.plugin-name }}
WORKSPACE: ${{ github.workspace }}
ACTION_PATH: ${{ github.action_path }}
- name: checkout additional plugins
if: inputs.dependent-plugins != ''
shell: bash
run: ${{ github.action_path }}/scripts/bash/checkout_dependent_plugins.sh
working-directory: ${{ github.workspace }}/matomo
env:
DEPENDENT_PLUGINS: ${{ inputs.dependent-plugins }}
GITHUB_USER_TOKEN: ${{ inputs.github-token }}
TARGET_BRANCH: ${{ github.base_ref || github.ref_name }}
- name: run additional setup script
if: inputs.setup-script != ''
shell: bash
run: ${{ github.workspace }}/${{ inputs.setup-script }}
working-directory: ${{ github.workspace }}/matomo
env:
PHP_VERSION: ${{ inputs.php-version }}
TEST_SUITE: ${{ inputs.test-type }}
MATOMO_TEST_TARGET: ${{ inputs.matomo-test-branch }}
PLUGIN_NAME: ${{ inputs.plugin-name }}
WORKSPACE: ${{ github.workspace }}
ACTION_PATH: ${{ github.action_path }}
- name: Install package ripgrep
shell: bash
run: sudo apt-get install ripgrep
working-directory: ${{ github.workspace }}/matomo
- name: Run tests
working-directory: ${{ github.workspace }}/matomo
shell: bash
run: ${{ github.action_path }}/scripts/bash/run_tests.sh
env:
TEST_SUITE: ${{ inputs.test-type }}
PLUGIN_NAME: ${{ inputs.plugin-name }}
UITEST_EXTRA_OPTIONS: ${{ inputs.ui-test-options }}
PHPUNIT_EXTRA_OPTIONS: ${{ inputs.phpunit-test-options }}
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_IS_TRIGGERED_BY_PUSH: ${{ github.event_name == 'push' && 'true' || 'false' }}
MYSQL_ADAPTER: ${{ inputs.mysql-driver }}
MYSQL_ENGINE: ${{ inputs.mysql-engine }}
TESTOMATIO: ${{ inputs.testomatio }}
TESTOMATIO_CREATE: 1
TESTOMATIO_ENV: PHP-${{ inputs.php-version }}, ${{ inputs.mysql-driver }}, ${{ inputs.mysql-engine }}
TRAVIS: '1'
- name: Debug informations
if: always()
working-directory: ${{ github.workspace }}/matomo
shell: bash
run: |
echo "::group::PHP configuration"
php -i || true
echo "::endgroup::"
echo "::group::Matomo configuration file"
cat config/config.ini.php || true
echo "::endgroup::"
echo "::group::Matomo error log file"
cat tmp/logs/matomo.log || true
echo "::endgroup::"
echo "::group::PHP error log file"
cat ${{ github.workspace }}/php-errors.log || true
echo "::endgroup::"
- name: upload processed screenshots
if: always() && inputs.upload-artifacts == 'true' && (inputs.test-type == 'UI' || inputs.test-type == 'SystemTestsPlugins' || inputs.test-type == 'SystemTestsCore' || inputs.test-type == 'PluginTests')
shell: bash
run: ${{ github.action_path }}/scripts/bash/upload_artifacts.sh
env:
ARTIFACTS_PASS: ${{ inputs.artifacts-pass }}
ARTIFACTS_PROTECTED: ${{ inputs.artifacts-protected == 'true' }}
TEST_SUITE: ${{ inputs.test-type }}
PLUGIN_NAME: ${{ inputs.plugin-name }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_RUN_ID: ${{ github.run-id }}
GITHUB_RUN_NUMBER: ${{ github.run-number }}
WORKSPACE: ${{ github.workspace }}/matomo