-
Notifications
You must be signed in to change notification settings - Fork 66
163 lines (135 loc) · 5.38 KB
/
Copy pathpr-checks.yml
File metadata and controls
163 lines (135 loc) · 5.38 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
name: Run checks
on:
pull_request:
push:
branches:
- trunk
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
uses: php-actions/composer@v6
with:
args: --ignore-platform-reqs
- name: Install Dependencies
run: npm i
- name: Run PHP Lint
run: npm run lint:php
- name: Run JS Lint
if: success() || failure()
run: npm run lint:js
- name: Run CSS Lint
if: success() || failure()
run: npm run lint:css
- name: Run Markdown Lint
if: success() || failure()
run: npm run lint:md-docs
- name: Run package.json Lint
if: success() || failure()
run: npm run lint:pkg-json
compute-previous-wordpress-version:
name: Compute previous WordPress version
runs-on: ubuntu-latest
permissions: {}
outputs:
previous-wordpress-version: ${{ steps.get-previous-wordpress-version.outputs.previous-wordpress-version }}
steps:
- name: Get previous WordPress version
id: get-previous-wordpress-version
run: |
curl \
-H "Accept: application/json" \
-o versions.json \
"http://api.wordpress.org/core/stable-check/1.0/"
LATEST_WP_VERSION="$(jq --raw-output 'with_entries(select(.value=="latest"))|keys[]' versions.json)"
# shellcheck disable=SC2034
IFS='.' read -r LATEST_WP_MAJOR LATEST_WP_MINOR LATEST_WP_PATCH <<< "${LATEST_WP_VERSION}"
if [[ "${LATEST_WP_MINOR}" == "0" ]]; then
PREVIOUS_WP_SERIES="$((LATEST_WP_MAJOR - 1)).9"
else
PREVIOUS_WP_SERIES="${LATEST_WP_MAJOR}.$((LATEST_WP_MINOR - 1))"
fi
PREVIOUS_WP_VERSION="$(jq --raw-output --arg series "${PREVIOUS_WP_SERIES}" 'with_entries(select(.key|startswith($series)))|keys[-1]' versions.json)"
echo "previous-wordpress-version=${PREVIOUS_WP_VERSION}" >> "$GITHUB_OUTPUT"
rm versions.json
tests:
name: PHP ${{ matrix.php }}${{ matrix.wordpress != '' && format( ' (WP {0})', matrix.wordpress ) || '' }}
needs: [compute-previous-wordpress-version]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
wordpress: ['', 'previous major version']
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.wordpress == '' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', needs.compute-previous-wordpress-version.outputs.previous-wordpress-version ) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Composer
uses: php-actions/composer@v6
with:
args: --ignore-platform-reqs
- name: Install Node Dependencies
run: npm i
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
ini-file: development
coverage: none
- name: Docker debug information
run: docker -v
- name: Start Docker environment
run: npm run wp-env start
- name: Docker container debug information
run: npm run wp-env run tests-cli wp core version
- name: Log running Docker containers
run: docker ps -a
- name: Run PHP tests
run: npm run test:unit:php:base
- name: Run API PHP tests in multisite
run: npm run test:unit:php:multisite-api
e2e:
name: E2E Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Node Dependencies
run: npm i
- name: Build JavaScript
run: npm run build
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Start wp-env
run: npm run test:unit:php:setup
- name: Run E2E tests
run: npm run test:e2e
- name: Upload test artifacts on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-artifacts
path: artifacts/
if-no-files-found: ignore