-
-
Notifications
You must be signed in to change notification settings - Fork 25
206 lines (180 loc) · 6.44 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
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
#
# GitHub action executed when a PR is opened, asked for a review
# For debugging purposes, also when the assignment is modified.
#
# For now, runs only the UI tests.
#
# This action requires a secret called ARTIFACTS_PASS which is the key to upload on build-artifacts.
# This value can be found in the development keepass database.
#
name: Matomo for WordPress Tests
on: [push]
permissions:
actions: read
checks: none
contents: read
deployments: none
issues: read
packages: none
pull-requests: read
repository-projects: none
security-events: none
statuses: none
concurrency:
group: php-${{ github.ref }}
cancel-in-progress: true
env:
MYSQL_DOCKER_IMG: 'bitnami/mariadb:latest'
DB_NAME: 'wp_matomo_tests'
PHP_VERSION: '8.0'
jobs:
unit_tests:
runs-on: 'ubuntu-20.04'
strategy:
fail-fast: false
matrix:
wp-versions: [ 'latest' ]
php-versions: [ '7.2', '7.3', '7.4', '8.0' ]
include:
- wp-versions: '5.2'
php-versions: '7.2'
permissions:
contents: read # <--- allows to read repo
steps:
- name: Checkout plugin project
uses: actions/checkout@v3
with:
persist-credentials: true
path: wp-content/plugins/matomo
- name: Shutdown Ubuntu MySQL
run: sudo service mysql stop # Shutdown the Default MySQL, "sudo" is necessary, please not remove it
- name: Start MariaDB service
shell: bash
run: |
docker run -d --name mariadb --tmpfs /var/lib/mariadb:rw --tmpfs /bitnami/mariadb/data:rw -v /bitnami/mariadb -p 3306:3306 -e ALLOW_EMPTY_PASSWORD=yes ${{ env.MYSQL_DOCKER_IMG }} > /dev/null
sleep 10
mysql -h127.0.0.1 -uroot -e "CREATE DATABASE ${{ env.DB_NAME }}";
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: curl, dom, exif, fileinfo, hash, imagick, json, mbstring, mysqli, openssl, pcre, sodium, xml, zip
ini-values: |
post_max_size=8M,
memory_limit=256M,
max_execution_time=30,
always_populate_raw_post_data=-1,
error_reporting=E_ALL,
log_errors=on,
display_errors=on,
allow_url_fopen=on,
zend.exception_ignore_args=Off
tools: composer:v2
coverage: none
- name: Check PHP Version
run: php -v
- name: Install dependencies
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && composer install
- name: Install test environment
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && ./bin/install-wp-tests.sh ${{ env.DB_NAME }} root '' 127.0.0.1 ${{ matrix.wp-versions }} true
- name: Run unit tests in non multisite context
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && ./vendor/bin/phpunit
- name: Run unit tests in multisite context
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && WP_MULTISITE=1 ./vendor/bin/phpunit
e2e_tests:
runs-on: 'ubuntu-22.04'
strategy:
fail-fast: false
matrix:
wp-versions: [ 'latest', 'trunk' ]
php-versions: [ '7.2', '8.1' ]
permissions:
contents: read # <--- allows to read repo
steps:
- uses: actions/checkout@v3
with:
lfs: true
persist-credentials: false
# setup xvfb
- run: sudo apt-get update && sudo apt-get install -y xvfb x11-xserver-utils xauth unzip
# setup firefox
- uses: browser-actions/setup-firefox@v1
- run: firefox --version
# setup node
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: '**/package-lock.json'
- run: npm install
# docker-compose up
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('scripts/Dockerfile.local') }}
- run: ls ${{ github.workspace }}/scripts
- run: pwd
- run: docker buildx build --cache-to type=gha --cache-from type=gha --build-arg PHP_VERSION=${{ matrix.php-versions }} --build-context project="${{ github.workspace }}/scripts" --file=scripts/Dockerfile.local scripts
env:
PHP_VERSION: ${{ matrix.php-versions }}
WOOCOMMERCE: 1
WORDPRESS_FOLDER: test
RESET_DATABASE: 1
WORDPRESS_VERSION: ${{ matrix.wp-versions }}
- run: docker-compose up wordpress
env:
PHP_VERSION: ${{ matrix.php-versions }}
WOOCOMMERCE: 1
WORDPRESS_FOLDER: test
RESET_DATABASE: 1
WORDPRESS_VERSION: ${{ matrix.wp-versions }}
- run: sleep 15 # wait for docker-compose launch to finish
# run tests
- run: xvfb-run --auto-servernum npm run wdio
env:
PHP_VERSION: ${{ matrix.php-versions }}
WOOCOMMERCE: 1
WORDPRESS_FOLDER: test
RESET_DATABASE: 1
WORDPRESS_VERSION: ${{ matrix.wp-versions }}
# output docker-compose logs
- run: docker-compose logs --no-color
- run: docker-compose stop
checkstyle:
runs-on: 'ubuntu-20.04'
steps:
- name: Checkout plugin project
uses: actions/checkout@v3
with:
persist-credentials: true
path: wp-content/plugins/matomo
- name: Setup PHP for checkstyle
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: curl, dom, exif, fileinfo, hash, imagick, json, mbstring, mysqli, openssl, pcre, sodium, xml, zip
ini-values: |
post_max_size=8M,
memory_limit=256M,
max_execution_time=30,
always_populate_raw_post_data=-1,
error_reporting=E_ALL,
log_errors=on,
display_errors=on,
allow_url_fopen=on,
zend.exception_ignore_args=Off
tools: composer:v2
coverage: none
- name: Check PHP Version
run: php -v
- name: Install dependencies
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && composer install
- name: Run checkstyle
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && ./vendor/bin/phpcs