Skip to content

Commit ccb30cc

Browse files
Revert "Merge branch 'core' into feat/snippet-lock"
This reverts commit 85a135a, reversing changes made to a501c3c.
1 parent 70350fa commit ccb30cc

File tree

12 files changed

+172
-750
lines changed

12 files changed

+172
-750
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
outputs:
2828
version: ${{ steps.build.outputs.version }}
29-
artifact_name: ${{ steps.build.outputs.artifact_name }}
29+
artifact_name: ${{ steps.build.outputs.name }}
3030
artifact_url: ${{ steps.artifacts.outputs.artifact-url }}
3131
artifact_id: ${{ steps.artifacts.outputs.artifact-id }}
3232
steps:
@@ -51,12 +51,8 @@ jobs:
5151
npm install && npm run bundle
5252
5353
name=$(jq -r .name package.json)
54-
version=$(jq -r .version package.json)
55-
artifact_name="${name}.${version}"
56-
5754
echo "name=$name" >> $GITHUB_OUTPUT
58-
echo "version=$version" >> $GITHUB_OUTPUT
59-
echo "artifact_name=$artifact_name" >> $GITHUB_OUTPUT
55+
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
6056
6157
mkdir -p ./upload/$name
6258
mv ./bundle/* ./upload/$name/ 2>/dev/null || true
@@ -65,5 +61,5 @@ jobs:
6561
id: artifacts
6662
uses: actions/upload-artifact@v4
6763
with:
68-
name: ${{ steps.build.outputs.artifact_name }}
64+
name: ${{ steps.build.outputs.name }}
6965
path: ./upload

.github/workflows/playwright-test.yml

Lines changed: 15 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,11 @@ on:
1111
required: true
1212
type: string
1313
description: 'Playwright project name to run'
14-
multisite:
15-
required: false
16-
type: boolean
17-
default: false
18-
description: 'If true, convert the site to multisite and create a subsite.'
1914

2015
jobs:
2116
playwright-test:
2217
name: Playwright tests (${{ inputs.test-mode == 'default' && 'Default Mode' || 'File-based Execution' }})
2318
runs-on: ubuntu-22.04
24-
services:
25-
mysql:
26-
image: mysql:8.0
27-
env:
28-
MYSQL_DATABASE: wordpress
29-
MYSQL_USER: wordpress
30-
MYSQL_PASSWORD: wordpress
31-
MYSQL_ROOT_PASSWORD: root
32-
options: >-
33-
--health-cmd="mysqladmin ping -h localhost -proot"
34-
--health-interval=10s
35-
--health-timeout=5s
36-
--health-retries=10
37-
38-
wordpress:
39-
image: wordpress:php8.1-apache
40-
env:
41-
WORDPRESS_DB_HOST: mysql:3306
42-
WORDPRESS_DB_USER: wordpress
43-
WORDPRESS_DB_PASSWORD: wordpress
44-
WORDPRESS_DB_NAME: wordpress
45-
WORDPRESS_DEBUG: 1
46-
WORDPRESS_CONFIG_EXTRA: |
47-
define( 'FS_METHOD', 'direct' );
48-
define( 'WP_DEBUG_LOG', true );
49-
define( 'WP_DEBUG_DISPLAY', false );
50-
define( 'SCRIPT_DEBUG', true );
51-
define( 'WP_ENVIRONMENT_TYPE', 'local' );
52-
ports:
53-
- 8888:80
5419
steps:
5520
- name: Checkout source code
5621
uses: actions/checkout@v4
@@ -90,153 +55,45 @@ jobs:
9055
path: |
9156
node_modules
9257
src/vendor
93-
key: ${{ runner.os }}-${{ inputs.test-mode }}-deps-${{ steps.deps-hash.outputs.deps_hash }}-${{ github.run_id }}-${{ github.job }}
58+
key: ${{ runner.os }}-deps-${{ steps.deps-hash.outputs.deps_hash }}
9459
restore-keys: |
95-
${{ runner.os }}-${{ inputs.test-mode }}-deps-${{ steps.deps-hash.outputs.deps_hash }}-
60+
${{ runner.os }}-deps-
9661
97-
- name: Install workflow dependencies
98-
if: steps.deps-cache.outputs.cache-matched-key == ''
62+
- name: Install workflow dependencies (wp-env, playwright)
63+
if: steps.deps-cache.outputs.cache-hit != 'true'
9964
run: npm run prepare-environment:ci && npm run bundle
10065

10166
- name: Save vendor and node_modules cache
102-
if: steps.deps-cache.outputs.cache-matched-key == ''
67+
if: steps.deps-cache.outputs.cache-hit != 'true'
10368
uses: actions/cache/save@v4
10469
with:
10570
path: |
10671
src/vendor
10772
node_modules
108-
key: ${{ steps.deps-cache.outputs.cache-primary-key }}
73+
key: ${{ runner.os }}-deps-${{ steps.deps-hash.outputs.deps_hash }}
10974

110-
- name: Wait for WordPress to be reachable
111-
run: |
112-
for i in $(seq 1 60); do
113-
if curl -fsS http://localhost:8888/wp-login.php >/dev/null; then
114-
echo "WordPress is reachable."
115-
exit 0
116-
fi
117-
echo "Waiting for WordPress... ($i/60)"
118-
sleep 2
119-
done
120-
121-
echo "WordPress did not start in time."
122-
echo "::group::WordPress container logs"
123-
docker logs "${{ job.services.wordpress.id }}" || true
124-
echo "::endgroup::"
125-
exit 1
126-
127-
- name: Download WP-CLI
128-
run: |
129-
curl -fsSL -o "${RUNNER_TEMP}/wp-cli.phar" https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
130-
131-
- name: "Install WordPress: ${{ inputs.multisite && 'Multisite' || 'Single Site' }}"
132-
env:
133-
WP_CONTAINER: ${{ job.services.wordpress.id }}
134-
WP_URL: http://localhost:8888
135-
WP_ADMIN_USER: admin
136-
WP_ADMIN_PASSWORD: password
137-
WP_ADMIN_EMAIL: admin@example.org
75+
- name: Start WordPress environment
13876
run: |
139-
set -euo pipefail
140-
141-
docker cp "${RUNNER_TEMP}/wp-cli.phar" "$WP_CONTAINER:/tmp/wp-cli.phar"
142-
143-
# Install WordPress if it isn't already installed.
144-
if ! docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar core is-installed --allow-root >/dev/null 2>&1; then
145-
docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar core install \
146-
--url="$WP_URL" \
147-
--title="Test Blog" \
148-
--admin_user="$WP_ADMIN_USER" \
149-
--admin_password="$WP_ADMIN_PASSWORD" \
150-
--admin_email="$WP_ADMIN_EMAIL" \
151-
--skip-email \
152-
--allow-root
153-
fi
154-
155-
if [ "${{ inputs.multisite }}" = "true" ]; then
156-
# Convert single site -> multisite (subdirectory). Subdomains don't work with localhost.
157-
if ! docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar core is-installed --network --allow-root >/dev/null 2>&1; then
158-
docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar core multisite-convert \
159-
--title="Test Network" \
160-
--base=/ \
161-
--allow-root
162-
fi
163-
164-
# Create a subsite for future multisite test coverage.
165-
if ! docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar site list --field=path --allow-root | grep -qx "/subsite/"; then
166-
docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar site create \
167-
--slug=subsite \
168-
--title="Subsite" \
169-
--email="$WP_ADMIN_EMAIL" \
170-
--allow-root
171-
fi
172-
fi
173-
174-
- name: Install plugin into WordPress container
175-
env:
176-
WP_CONTAINER: ${{ job.services.wordpress.id }}
177-
run: |
178-
set -euo pipefail
179-
180-
docker exec -u root -w /var/www/html "$WP_CONTAINER" rm -rf wp-content/plugins/code-snippets
181-
docker cp src "$WP_CONTAINER:/var/www/html/wp-content/plugins/code-snippets"
182-
docker exec -u root -w /var/www/html "$WP_CONTAINER" chown -R www-data:www-data wp-content/plugins/code-snippets
77+
npx wp-env start
18378
18479
- name: Activate code-snippets plugin
185-
env:
186-
WP_CONTAINER: ${{ job.services.wordpress.id }}
187-
run: |
188-
set -euo pipefail
189-
if [ "${{ inputs.multisite }}" = "true" ]; then
190-
docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar plugin activate code-snippets --network --allow-root
191-
else
192-
docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar plugin activate code-snippets --allow-root
193-
fi
80+
run: npx wp-env run cli wp plugin activate code-snippets
19481

19582
- name: WordPress debug information
196-
env:
197-
WP_CONTAINER: ${{ job.services.wordpress.id }}
19883
run: |
199-
docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar core version --allow-root
200-
docker exec -u root -w /var/www/html "$WP_CONTAINER" php /tmp/wp-cli.phar --allow-root --info
201-
202-
- name: Restore Playwright browsers cache
203-
id: playwright-browsers-cache
204-
uses: actions/cache/restore@v4
205-
with:
206-
path: |
207-
~/.cache/ms-playwright
208-
key: ${{ runner.os }}-playwright-browsers-${{ hashFiles('package-lock.json') }}-${{ github.run_id }}-${{ github.job }}
209-
restore-keys: |
210-
${{ runner.os }}-playwright-browsers-${{ hashFiles('package-lock.json') }}-
84+
npx wp-env run cli wp core version
85+
npx wp-env run cli wp --info
21186
21287
- name: Install playwright/test
213-
if: steps.playwright-browsers-cache.outputs.cache-matched-key == ''
21488
run: |
21589
npx playwright install chromium
21690
217-
- name: Save Playwright browsers cache
218-
if: steps.playwright-browsers-cache.outputs.cache-matched-key == ''
219-
uses: actions/cache/save@v4
220-
with:
221-
path: |
222-
~/.cache/ms-playwright
223-
key: ${{ steps.playwright-browsers-cache.outputs.cache-primary-key }}
224-
22591
- name: Run Playwright tests
226-
env:
227-
WP_E2E_WPCLI_MODE: gh-actions-ci
228-
WP_E2E_WPCLI_PHAR: /tmp/wp-cli.phar
229-
WP_E2E_WPCLI_URL: http://localhost:8888
230-
WP_E2E_WP_CONTAINER: ${{ job.services.wordpress.id }}
231-
WP_E2E_MULTISITE_MODE: ${{ inputs.multisite }}
23292
run: npm run test:playwright -- --project=${{ inputs.project-name }}
233-
234-
- name: Print WordPress logs on failure
235-
if: failure()
236-
run: |
237-
echo "::group::WordPress container logs"
238-
docker logs "${{ job.services.wordpress.id }}" || true
239-
echo "::endgroup::"
93+
94+
- name: Stop WordPress environment
95+
if: always()
96+
run: npx wp-env stop
24097

24198
- uses: actions/upload-artifact@v4
24299
if: always()

.github/workflows/playwright.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,23 @@ permissions:
2020
actions: read
2121

2222
concurrency:
23-
group: playwright-${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}-${{ (github.event_name != 'pull_request' || (contains(github.event.pull_request.labels.*.name, 'run-tests') && (github.event.action != 'labeled' || github.event.label.name == 'run-tests' || github.event.label.name == 'multisite'))) && 'tests' || github.run_id }}
24-
cancel-in-progress: ${{ github.event_name != 'pull_request' || (contains(github.event.pull_request.labels.*.name, 'run-tests') && (github.event.action != 'labeled' || github.event.label.name == 'run-tests' || github.event.label.name == 'multisite')) }}
23+
group: playwright-${{ github.event_name }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
24+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2525

2626
jobs:
2727
playwright-default:
28-
if: github.event_name != 'pull_request' || (contains(github.event.pull_request.labels.*.name, 'run-tests') && (github.event.action != 'labeled' || github.event.label.name == 'run-tests' || github.event.label.name == 'multisite'))
28+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests')
2929
uses: ./.github/workflows/playwright-test.yml
3030
with:
3131
test-mode: 'default'
3232
project-name: 'chromium-db-snippets'
33-
multisite: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-tests') && contains(github.event.pull_request.labels.*.name, 'multisite') }}
3433

3534
playwright-file-based-execution:
36-
if: github.event_name != 'pull_request' || (contains(github.event.pull_request.labels.*.name, 'run-tests') && (github.event.action != 'labeled' || github.event.label.name == 'run-tests' || github.event.label.name == 'multisite'))
35+
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests')
3736
uses: ./.github/workflows/playwright-test.yml
3837
with:
3938
test-mode: 'file-based-execution'
4039
project-name: 'chromium-file-based-snippets'
41-
multisite: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-tests') && contains(github.event.pull_request.labels.*.name, 'multisite') }}
4240

4341
test-result:
4442
needs: [playwright-default, playwright-file-based-execution]

0 commit comments

Comments
 (0)