-
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (125 loc) · 5.02 KB
/
Copy pathreusable-codeception.yml
File metadata and controls
143 lines (125 loc) · 5.02 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
name: Run Codeception Tests
on:
workflow_call:
inputs:
php-version:
description: 'PHP version to use'
required: true
type: string
wp-version:
description: 'WordPress version (latest, trunk, or X.Y)'
required: false
type: string
default: 'latest'
multisite:
description: 'Run multisite tests'
required: false
type: boolean
default: false
coverage:
description: 'Enable code coverage'
required: false
type: boolean
default: false
functional:
description: 'Run functional tests'
required: false
type: boolean
default: true
acceptance:
description: 'Run acceptance tests'
required: false
type: boolean
default: true
wpunit:
description: 'Run WPUnit tests'
required: false
type: boolean
default: true
secrets:
CODECOV_TOKEN:
description: 'Codecov upload token'
required: false
jobs:
codeception:
permissions: {}
name: Codeception (PHP ${{ inputs.php-version }}, WP ${{ inputs.wp-version }})${{ inputs.coverage && ' (coverage)' || '' }}
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
WP_ENV_PHP_VERSION: ${{ inputs.php-version }}
WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || inputs.wp-version == 'latest' && 'latest' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }}
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
- name: Set up PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
with:
php-version: ${{ inputs.php-version }}
coverage: ${{ inputs.coverage && 'xdebug' || 'none' }}
tools: composer:v2
- name: Install Composer dependencies
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4.0.0
- name: Setup Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Create cache directories
run: mkdir -p ~/.wp-env/downloads
- name: Cache WordPress downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.wp-env/downloads
key: ${{ runner.os }}-wp-env-downloads-${{ hashFiles('.wp-env.json') }}
restore-keys: |
${{ runner.os }}-wp-env-downloads-
- name: Start the Docker testing environment
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
with:
timeout_minutes: 10
max_attempts: 3
command: |
${{ inputs.coverage && 'PCOV_ENABLED=1 ' || '' }}npm run wp-env:test start --${{ inputs.multisite && ' --multisite' || '' }}${{ secrets.ACTIONS_STEP_DEBUG && ' --debug' || '' }}
- name: Log versions
run: |
npm run wp-env:test -- run cli php -- -v
npm run wp-env:test -- run cli wp core version
- name: Run Codeception acceptance tests
if: ${{ inputs.acceptance }}
run: npm run test:codecept run acceptance ${{ runner.debug == '1' && '--debug' || '' }}
- name: Run Codeception functional tests
if: ${{ inputs.functional }}
run: npm run test:codecept run functional ${{ runner.debug == '1' && '--debug' || '' }}
- name: Run Codeception integration tests${{ inputs.coverage && ' (coverage)' || '' }}
if: ${{ inputs.wpunit }}
run: npm run test:codecept run wpunit ${{ inputs.coverage && '--coverage --coverage-xml --coverage-html' || '' }} ${{ runner.debug == '1' && '--debug' || '' }}
- name: Upload test failure artifacts
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-failures-php${{ inputs.php-version }}-wp${{ inputs.wp-version }}
path: tests/_output/*.fail.html
if-no-files-found: ignore
- name: Upload HTML coverage report as artifact
if: ${{ inputs.coverage }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wp-code-coverage-${{ inputs.php-version }}-${{ inputs.wp-version }}
path: tests/_output/coverage
overwrite: true
if-no-files-found: ignore
- name: Upload code coverage report
if: ${{ inputs.coverage }}
continue-on-error: true
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