-
-
Notifications
You must be signed in to change notification settings - Fork 31
190 lines (169 loc) · 6.72 KB
/
Copy pathcodeception.yml
File metadata and controls
190 lines (169 loc) · 6.72 KB
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
name: Codeception
on:
workflow_dispatch:
push:
branches:
- develop
- main
pull_request:
types:
- opened
- synchronize
- ready_for_review
paths:
- 'bin/**'
- 'src/**'
- 'tests/**'
- '.github/workflows/codeception.yml'
- '**.php'
- '.env.dist'
- '.nvmrc'
- '.wp-env.json'
- 'codecov.yml'
- 'codeception.dist.yml'
- 'composer.json'
- 'composer.lock'
- 'package-lock.json'
- 'package.json'
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
# Runs the Codeception tests for WordPress.
#
# Performs the following steps:
# - Sets environment variables.
# - Checks out the repository.
# - Sets up PHP.
# - Installs Composer dependencies.
# - Sets up Node.js.
# - Installs npm dependencies.
# - Starts the WordPress Docker testing environment (with or without pcov coverage).
# - Logs PHP and WordPress versions from the container.
# - Runs Codeception tests (with coverage if enabled).
# - Uploads code coverage report to Codecov.io (if coverage is enabled).
# - Uploads HTML coverage report as an artifact (if coverage is enabled).
codeception:
name: PHP ${{ matrix.php }} WP ${{ matrix.wordpress }}${{ matrix.coverage && ' (coverage)' || '' }}
runs-on: ubuntu-24.04
permissions:
contents: read
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
## GF 2.9.x only supports from WP 6.5, and we have no way to access earlier versions.
php: ['8.4', '8.3', '8.2', '8.1']
wordpress: ['6.9', '6.8', '6.7', '6.6', '6.5']
coverage: [0]
include:
- php: '8.4'
wordpress: '6.9'
coverage: '1'
# Unsupported combinated by wp-env
exclude:
- php: '8.4'
wordpress: ['6.5', '6.6']
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wordpress == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wordpress ) }}
steps:
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV"
echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
##
# This allows Composer dependencies to be installed using a single step.
#
# Since the tests are currently run within the Docker containers where the PHP version varies,
# the same PHP version needs to be configured for the action runner machine so that the correct
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: '${{ matrix.php }}'
tools: composer:v2
extensions: json, mbstring
- name: Install Composer dependencies
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4.0.0
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
cache: 'npm'
node-version-file: '.nvmrc'
- name: Install NPM dependencies
run: npm ci
- name: Create cache directories
run: mkdir -p ~/.wp-env/downloads tests/_data/plugins tests/_data/mu-plugins
- name: Cache WordPress downloads
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.wp-env/downloads
key: ${{ runner.os }}-wp-env-downloads-${{ hashFiles('.wp-env.json') }}
restore-keys: |
${{ runner.os }}-wp-env-downloads-
- name: Cache WordPress Plugins
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
tests/_data/plugins
tests/_data/mu-plugins
key: ${{ runner.os }}-wp-plugins-${{ hashFiles('.wp-env.json', 'bin/_lib.sh', 'bin/after-start.sh', 'bin/setup.sh') }}
restore-keys: |
${{ runner.os }}-wp-plugins-
- name: Setup .env file
run: |
cp .env.dist .env
echo GF_KEY=${{ secrets.GF_KEY }} >> .env
- name: Start the Docker testing environment
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 10
max_attempts: 3
command: |
${{ matrix.coverage && 'PCOV_ENABLED=1 ' || '' }}npm run wp-env start -- ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }}
- name: Log versions
run: |
npm run wp-env -- run cli php -- -v
npm run wp-env -- run cli wp core version
- name: Run Acceptance Tests
run: |
npm run test:codecept -- run acceptance ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }}
- name: Run Unit Tests
run: |
npm run test:codecept -- run unit ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }}
- name: Run WPUnit Tests ${{ matrix.coverage && ' with coverage report' || '' }}
run: |
npm run test:codecept -- run wpunit ${{ secrets.ACTIONS_STEP_DEBUG && '--debug' || '' }} ${{ matrix.coverage && '--coverage --coverage-xml --coverage-html' || '' }}
- name: Upload test failure artifacts
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-failures-php${{ matrix.php }}-wp${{ matrix.wordpress }}
path: tests/_output/*.fail.html
if-no-files-found: ignore
- name: Upload HTML coverage report as artifact
if: ${{ matrix.coverage }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wp-code-coverage-${{ matrix.php }}-${{ matrix.wordpress }}
path: tests/_output/coverage
overwrite: true
- name: Upload code coverage report
continue-on-error: true
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: tests/_output/coverage.xml
flags: wpunit
fail_ci_if_error: true