Skip to content

Commit 3832fe3

Browse files
authored
Merge branch 'trunk' into disable-legacy-shipping-features
2 parents ad45bb2 + 37794ab commit 3832fe3

17 files changed

Lines changed: 930 additions & 15 deletions

.github/workflows/build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build
2+
on:
3+
workflow_call:
4+
inputs:
5+
plugin_name:
6+
required: true
7+
type: string
8+
description: 'The name of the plugin (e.g. woocommerce-services)'
9+
outputs:
10+
plugin_name:
11+
description: "The name of the plugin"
12+
value: ${{ jobs.build.outputs.plugin_name }}
13+
14+
jobs:
15+
build:
16+
name: Build plugin artifact (zip file)
17+
runs-on: ubuntu-latest
18+
outputs:
19+
plugin_name: ${{ inputs.plugin_name }}
20+
env:
21+
PLUGIN_NAME: ${{ inputs.plugin_name }}
22+
steps:
23+
- name: Set Git to use HTTPS instead of SSH
24+
run: git config --global url.https://github.com/.insteadOf git://github.com/
25+
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: recursive
30+
31+
- uses: actions/setup-node@v3
32+
with:
33+
node-version-file: '.nvmrc'
34+
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: '8.2'
39+
40+
- name: Install NPM dependencies
41+
run: npm ci
42+
43+
- name: Build plugin zip
44+
run: npm run build
45+
46+
- name: Unzip woocommerce-services.zip
47+
run: unzip woocommerce-services.zip -d woocommerce-services
48+
49+
- name: Re-zip woocommerce-services folder
50+
run: zip -r woocommerce-services.zip woocommerce-services
51+
52+
- name: Upload plugin zip
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ env.PLUGIN_NAME }}
56+
path: ${{ env.PLUGIN_NAME }}.zip

.github/workflows/cron_qit.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Cron QIT
2+
3+
on:
4+
schedule:
5+
# Run at 02:00 on Sundays.
6+
- cron: '0 2 * * 0'
7+
8+
jobs:
9+
10+
build:
11+
name: Build project
12+
uses: ./.github/workflows/build.yml
13+
with:
14+
plugin_name: woocommerce-services
15+
16+
qit-tests:
17+
name: QIT
18+
needs: build
19+
uses: ./.github/workflows/qit_runner.yml
20+
secrets: inherit
21+
with:
22+
extension: ${{ needs.build.outputs.plugin_name }}
23+
artifact: ${{ needs.build.outputs.plugin_name }}
24+
wp-version: 'stable'
25+
wc-version: 'nightly'
26+
test-activation: true
27+
test-security: true
28+
test-phpcompatibility: true
29+
test-validation: true
30+
test-phpstan: false # TODO: Enable this once we've fixed the PHPStan issues.
31+
test-woo-api: true
32+
test-woo-e2e: true
33+
test-malware: true
34+
test-plugin-check: false # only run for WPORG
35+
36+
handle-success:
37+
if: ${{ success() }}
38+
needs: qit-tests
39+
name: Handle success
40+
runs-on: ubuntu-latest
41+
env:
42+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
43+
steps:
44+
- uses: act10ns/slack@v2
45+
with:
46+
status: success
47+
message: 'Scheduled workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> passed.'
48+
49+
handle-error:
50+
if: ${{ failure() }}
51+
needs: qit-tests
52+
name: Handle failure
53+
runs-on: ubuntu-latest
54+
env:
55+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
56+
steps:
57+
- uses: act10ns/slack@v2
58+
with:
59+
status: failure
60+
message: 'Scheduled workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> failed. You can find the results in the artifacts section.'

.github/workflows/e2e_runner.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: E2E Tests Runner
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php_version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
e2e_build_and_test:
12+
name: Build Container and Run E2E Tests
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Set Git to use HTTPS instead of SSH
16+
run: git config --global url.https://github.com/.insteadOf git://github.com/
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: recursive
20+
- uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ inputs.php_version }}
23+
tools: composer
24+
extensions: mysql
25+
coverage: none
26+
- uses: actions/setup-node@v3
27+
with:
28+
node-version-file: '.nvmrc'
29+
- name: Kill process running on port 8084 to unblock it
30+
shell: bash
31+
run: |
32+
echo "::group::Kill webserver running on port 8084"
33+
set +e #
34+
sudo fuser -k -n tcp 8084 > /dev/null 2>&1
35+
EXIT_CODE=$?
36+
set -e
37+
if [ $EXIT_CODE -eq 1 ]; then
38+
echo "No process found on port 8084, ignoring exit code 1."
39+
exit 0
40+
fi
41+
if [ $EXIT_CODE -ne 0 ]; then
42+
echo "fuser encountered an error with exit code $EXIT_CODE."
43+
exit $EXIT_CODE
44+
fi
45+
echo "::endgroup::"
46+
- name: Build WCS&T
47+
run: |
48+
composer install
49+
npm ci
50+
npm run dist
51+
- name: Install docker-compose
52+
run: |
53+
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
54+
sudo chmod +x /usr/local/bin/docker-compose
55+
- name: Setup E2E container
56+
run: |
57+
npm run test:e2e-docker-up
58+
npm run test:e2e-docker-ping
59+
- name: Run E2E tests
60+
run: npm run test:e2e
61+
- name: Stop E2E container
62+
run: npm run test:e2e-docker-down

.github/workflows/manual_qit.yml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: Manual Test Runner
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
wp-version:
7+
description: 'WordPress Version to be tested: `latest` or a specific version number.'
8+
type: string
9+
default: 'latest'
10+
wc-version:
11+
description: 'WooCommerce Version to be tested: `latest`, `nightly` or a specific version number.'
12+
type: string
13+
default: 'latest'
14+
php-version:
15+
description: |
16+
PHP version. Default is `8.4`.
17+
type: string
18+
default: '8.4'
19+
extension-tests:
20+
description: 'Extension Tests'
21+
type: choice
22+
default: 'All'
23+
options:
24+
# - 'E2E Tests' // enable this once we have E2E tests
25+
- 'Unit Tests'
26+
- 'All'
27+
- 'None'
28+
- 'E2E'
29+
qit-tests:
30+
description: 'QIT Tests'
31+
type: choice
32+
options:
33+
- 'WooCommerce Pre-Release Tests (includes Activation, WooCommerce E2E and API tests)'
34+
- 'Code Quality Checks (includes Security, Validation, Malware, PHPStan, and PHP Compatibility tests)'
35+
- 'Activation'
36+
- 'Security'
37+
- 'Validation'
38+
- 'Malware'
39+
- 'PHPStan'
40+
- 'PHP Compatibility'
41+
- 'WooCommerce E2E and API tests'
42+
- 'Plugin Checks (for dotOrg metadata)'
43+
- 'None'
44+
qit-wait:
45+
description: 'Wait for QIT? Requires additional time for the QIT tests to complete within GHA.'
46+
type: boolean
47+
default: true
48+
options:
49+
description: 'QIT Additional options for `qit` command, like `--optional_features=hpos`.'
50+
type: string
51+
default: ''
52+
53+
run-name: Tests with WP-${{ inputs.wp-version }} - WC-${{ inputs.wc-version }} - PHP ${{ inputs.php-version }} - Tests ${{ inputs.extension-tests }} - QIT ${{ inputs.qit-tests }}
54+
55+
jobs:
56+
find_latest_versions:
57+
name: Get supported WP & WC versions
58+
runs-on: ubuntu-latest
59+
outputs:
60+
wc_versions: ${{ steps.get_wc_versions_for_matrix.outputs.wc_versions }}
61+
wp_versions: ${{ steps.get_wp_versions_for_matrix.outputs.wp_versions }}
62+
wc_rc_version: ${{ steps.get_wc_rc_versions_for_matrix.outputs.wc_rc_version }}
63+
steps:
64+
- name: Checkout WooCommerce Shipping
65+
uses: actions/checkout@v4
66+
- name: Get current branch
67+
id: get_branch
68+
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
69+
- name: Get WordPress versions
70+
id: get_wp_versions_for_matrix
71+
run: |
72+
if [ "${{ steps.get_branch.outputs.branch }}" == "trunk" ]; then
73+
echo "wp_versions=$(git ls-remote --tags --refs https://github.com/WordPress/WordPress.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 3)" >> $GITHUB_OUTPUT
74+
else
75+
echo "wp_versions=$(git ls-remote --tags --refs https://github.com/WordPress/WordPress.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 1)" >> $GITHUB_OUTPUT
76+
fi
77+
- name: Get WooCommerce versions
78+
id: get_wc_versions_for_matrix
79+
run: |
80+
if [ "${{ steps.get_branch.outputs.branch }}" == "trunk" ]; then
81+
echo "wc_versions=$(git ls-remote --tags --refs https://github.com/woocommerce/woocommerce.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 3)" >> $GITHUB_OUTPUT
82+
else
83+
echo "wc_versions=$(git ls-remote --tags --refs https://github.com/woocommerce/woocommerce.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 1)" >> $GITHUB_OUTPUT
84+
fi
85+
- name: Get WooCommerce RC versions
86+
id: get_wc_rc_versions_for_matrix
87+
run: |
88+
echo "wc_rc_version=$(curl -s https://api.github.com/repos/woocommerce/woocommerce/releases | jq -r '[.[] | select(.tag_name | ascii_downcase | contains("rc"))] | sort_by(.published_at) | reverse | .[0].tag_name')" >> $GITHUB_OUTPUT
89+
90+
js-tests:
91+
if: contains(inputs.extension-tests, 'All') || contains(inputs.extension-tests, 'Unit')
92+
name: JS ESLint Tests
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v4
96+
with:
97+
submodules: recursive
98+
- uses: actions/setup-node@v3
99+
with:
100+
node-version-file: '.nvmrc'
101+
- run: git config --global url.https://github.com/.insteadOf git://github.com/
102+
- run: npm ci
103+
- run: npm run eslint
104+
- run: npm run test
105+
106+
php-tests:
107+
if: contains(inputs.extension-tests, 'All') || contains(inputs.extension-tests, 'Unit')
108+
name: PHP Tests
109+
needs: find_latest_versions
110+
uses: ./.github/workflows/unit_test_runner.yml
111+
with:
112+
wp_version: ${{ inputs.wp-version == 'latest' && fromJSON(needs.find_latest_versions.outputs.wp_versions)[0] || inputs.wp-version }}
113+
wc_version: ${{ inputs.wc-version == 'latest' && fromJSON(needs.find_latest_versions.outputs.wc_versions)[0] || inputs.wc-version == 'rc' && needs.find_latest_versions.outputs.wc_rc_version || inputs.wc-version }}
114+
php_version: ${{ inputs.php-version }}
115+
116+
build_project:
117+
name: Package
118+
uses: ./.github/workflows/build.yml
119+
with:
120+
plugin_name: woocommerce-services
121+
122+
qit-tests:
123+
name: QIT
124+
needs: build_project
125+
uses: ./.github/workflows/qit_runner.yml
126+
with:
127+
extension: ${{ needs.build_project.outputs.plugin_name }}
128+
artifact: ${{ needs.build_project.outputs.plugin_name }}
129+
wp-version: ${{ inputs.wp-version == 'latest' && 'stable' || inputs.wp-version }}
130+
wc-version: ${{ inputs.wc-version == 'latest' && 'stable' || contains( inputs.wc-version, 'rc' ) && 'rc' || inputs.wc-version }}
131+
php-version: ${{ inputs.php-version }}
132+
test-activation: ${{ contains(inputs.qit-tests, 'Activation') && true || false }}
133+
test-security: ${{ contains(inputs.qit-tests, 'Security') && true || false }}
134+
test-phpcompatibility: ${{ contains(inputs.qit-tests, 'Compatibility') && true || false }}
135+
test-phpstan: ${{ contains(inputs.qit-tests, 'PHPStan') && true || false }}
136+
test-woo-api: ${{ contains(inputs.qit-tests, 'API') && true || false }}
137+
test-woo-e2e: ${{ contains(inputs.qit-tests, 'WooCommerce E2E') && true || false }}
138+
test-malware: ${{ contains(inputs.qit-tests, 'Malware') && true || false }}
139+
test-validation: ${{ contains(inputs.qit-tests, 'Validation') && true || false }}
140+
test-plugin-check: ${{ contains(inputs.qit-tests, 'dotOrg') && true || false }}
141+
options: ${{ inputs.options }}
142+
wait: ${{ inputs.qit-wait }}
143+
secrets: inherit
144+
145+
e2e-tests:
146+
if: contains(inputs.extension-tests, 'All') || contains(inputs.extension-tests, 'E2E')
147+
name: E2E tests
148+
needs: build_project
149+
uses: ./.github/workflows/e2e_runner.yml
150+
with:
151+
php_version: ${{ inputs.php-version }}
152+
secrets: inherit
153+
154+
handle-success:
155+
if: |
156+
always() &&
157+
(needs.qit-tests.result == 'success' || needs.qit-tests.result == 'skipped') &&
158+
(needs.php-tests.result == 'success' || needs.php-tests.result == 'skipped') &&
159+
(needs.js-tests.result == 'success' || needs.js-tests.result == 'skipped') &&
160+
(needs.e2e-tests.result == 'success' || needs.e2e-tests.result == 'skipped')
161+
needs: [qit-tests, php-tests, js-tests, e2e-tests]
162+
name: Handle success
163+
runs-on: ubuntu-latest
164+
env:
165+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
166+
steps:
167+
- uses: act10ns/slack@v2
168+
with:
169+
status: success
170+
message: 'Test Runner Workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> passed.'
171+
172+
handle-cancelled:
173+
if: cancelled()
174+
needs: [qit-tests, php-tests, js-tests, e2e-tests]
175+
name: Handle cancellation
176+
runs-on: ubuntu-latest
177+
env:
178+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
179+
steps:
180+
- uses: act10ns/slack@v2
181+
with:
182+
status: cancelled
183+
message: 'Test Runner Workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> cancelled.'
184+
185+
handle-error:
186+
if: failure()
187+
needs: [qit-tests, php-tests, js-tests, e2e-tests]
188+
name: Handle failure
189+
runs-on: ubuntu-latest
190+
env:
191+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
192+
steps:
193+
- uses: act10ns/slack@v2
194+
with:
195+
status: failure
196+
message: 'Test Runner Workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> failed.'

0 commit comments

Comments
 (0)