Skip to content

Docs: fix typo in resources.md #10019

Docs: fix typo in resources.md

Docs: fix typo in resources.md #10019

Workflow file for this run

name: CI
on:
push:
branches:
- trunk
pull_request:
jobs:
# This step:
# * Warms up the node_modules cache
# * Performs linting and typechecking
#
# The linting tasks take ~5s to complete and it doesn't
# make sense to separate them into separate steps that would
# take ~25s just to run git clone and restore node_modules.
lint-and-typecheck:
name: 'Lint and typecheck'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- run: npx nx affected --target=lint
- run: npx nx affected --target=typecheck
test-unit-asyncify:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: test-unit-asyncify (1/8)
target: test
- name: test-unit-asyncify (2/8)
target: test-asyncify
- name: test-unit-asyncify (3/8)
target: test-php-file-get-contents-asyncify
- name: test-unit-asyncify (4/8)
target: test-php-fopen-asyncify
- name: test-unit-asyncify (5/8)
target: test-php-fsockopen-asyncify
- name: test-unit-asyncify (6/8)
target: test-php-gethostbyname-asyncify
- name: test-unit-asyncify (7/8)
target: test-php-mysqli-asyncify
- name: test-unit-asyncify (8/8)
target: test-php-sqlite3-asyncify
name: ${{ matrix.name }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
with:
node-version: 20
- run: node --expose-gc node_modules/nx/bin/nx affected --target=${{ matrix.target }}
env:
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: password
test-unit-jspi:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: test-unit-jspi (1/7)
target: test-jspi
- name: test-unit-jspi (2/7)
target: test-php-file-get-contents-jspi
- name: test-unit-jspi (3/7)
target: test-php-fopen-jspi
- name: test-unit-jspi (4/7)
target: test-php-fsockopen-jspi
- name: test-unit-jspi (5/7)
target: test-php-gethostbyname-jspi
- name: test-unit-jspi (6/7)
target: test-php-mysqli-jspi
- name: test-unit-jspi (7/7)
target: test-php-sqlite3-jspi
name: ${{ matrix.name }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
with:
node-version: 23
- run: node --expose-gc node_modules/nx/bin/nx affected --target=${{ matrix.target }}
env:
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: password
test-playground-cli:
strategy:
matrix:
# NOTE: macOS is currently skipped because tests were running into
# "EMFILE: too many open files" errors when running within the GH runner.
# It would be great to fix the issue and add macOS testing here.
# In the meantime, many of the current developers test locally on macOS.
# @TODO: Fix issues and re-enable macOS testing.
os: [ubuntu-latest, windows-latest]
continue-on-error: true
runs-on: ${{ matrix.os }}
name: 'test-playground-cli (${{ matrix.os }})'
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
with:
node-version: 22
- name: Run full test suite
if: runner.os != 'Windows'
run: node node_modules/nx/bin/nx affected --target=test-for-node-22-and-above
# NOTE: We currently have to reduce the number of tests we run on Windows,
# and we do so by using Vitest's test.only() function. In order to use this
# within the `nx affected` command, we need to pass the Vitest arg --allowOnly.
- name: Run limited test suite on Windows
if: runner.os == 'Windows'
run: node node_modules/nx/bin/nx affected --target=test-for-node-22-and-above -- --allowOnly
test-e2e:
runs-on: ubuntu-latest
# Run as root to allow node to bind to port 80
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- run: sudo ./node_modules/.bin/cypress install --force
- run: sudo CYPRESS_CI=1 npx nx e2e playground-website --configuration=ci --verbose
# Upload the Cypress screenshots as artifacts if the job fails
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: cypress-screenshots
path: dist/cypress/packages/playground/website/screenshots
test-e2e-playwright-prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- name: Install Playwright Browsers
run: sudo npx playwright install --with-deps
- name: Prepare app deploy and offline mode
run: CORS_PROXY_URL=http://127.0.0.1:5263/cors-proxy.php? npx nx e2e:playwright:prepare-app-deploy-and-offline-mode playground-website
- name: Zip dist
run: zip -r dist.zip dist
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: playwright-dist
path: dist.zip
test-e2e-playwright:
runs-on: ubuntu-latest
needs: [test-e2e-playwright-prepare]
strategy:
fail-fast: false
matrix:
# WebKit runner is disabled in CI – it used to be enabled but the tests
# failed randomly without any obvious reason.
# @see https://github.com/WordPress/wordpress-playground/pull/2475
part: ['chromium', 'firefox']
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- name: Download dist
uses: actions/download-artifact@v4
with:
name: playwright-dist
- name: Unzip dist
run: unzip dist.zip
- name: Install Playwright Browser
run: sudo npx playwright install ${{ matrix.part }} --with-deps
- name: Run Playwright tests - ${{ matrix.part }}
run: |
if [ "${{ matrix.part }}" = "firefox" ]; then
sudo -E HOME=/root XDG_RUNTIME_DIR=/root CI=true npx playwright test --config=packages/playground/website/playwright/playwright.ci.config.ts --project=${{ matrix.part }}
else
sudo CI=true npx playwright test --config=packages/playground/website/playwright/playwright.ci.config.ts --project=${{ matrix.part }}
fi
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ matrix.part }}
path: packages/playground/website/playwright-report/
if-no-files-found: ignore
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-snapshots-${{ matrix.part }}
path: packages/playground/website/playwright/e2e/deployment.spec.ts-snapshots/
if-no-files-found: ignore
test-e2e-playwright-cleanup:
runs-on: ubuntu-latest
needs: [test-e2e-playwright]
steps:
- name: Delete playwright-dist artifact
uses: geekyeggo/delete-artifact@v5
if: ${{ success() }}
with:
name: playwright-dist
test-e2e-components:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests for components
run: npx nx e2e playground-components
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-components-report
path: packages/playground/components/playwright-report/
if-no-files-found: ignore
test-built-npm-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
with:
node-version: 22
- name: Generate a mock version number (for releasing the packages in a local registry) and store it as a global variable
run: |
VERSION=$(date +%s)
PORT=9934
PACKAGE_BASE_URL=http://127.0.0.1:$PORT/$VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PORT=$PORT" >> $GITHUB_ENV
echo "PACKAGE_BASE_URL=$PACKAGE_BASE_URL" >> $GITHUB_ENV
echo "PACKAGE_URL=$PACKAGE_BASE_URL/v$VERSION/@wp-playground-cli-$VERSION.tar.gz" >> $GITHUB_ENV
echo "HOST_PATH=./dist/packages-for-self-hosting/http%3A%2F%2F127.0.0.1%3A$PORT%2F$VERSION" >> $GITHUB_ENV
- name: Update package.json versions
run: |
VERSION=$(date +%s)
for package in packages/*/*/package.json; do
jq --arg version "$VERSION" '.version = $version' "$package" > "$package.tmp"
mv "$package.tmp" "$package"
done
- name: Package repository
run: |
npx nx run-many --all --target=package-for-self-hosting -- --hostingBaseUrl="$PACKAGE_BASE_URL"
- name: Start a local node package registry server
run: |
source ~/.nvm/nvm.sh;
nvm install 22;
cd $HOST_PATH
RUNNER_TRACKING_ID="" && ( \
nohup python3 -c "import http.server
import socketserver
from urllib.parse import unquote
class PrefixHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path.startswith('/${{ env.VERSION }}/'):
self.path = self.path[len('/${{ env.VERSION }}'):]
elif self.path == '/${{ env.VERSION }}':
self.path = '/'
super().do_GET()
with socketserver.TCPServer(('127.0.0.1', ${{ env.PORT }}), PrefixHTTPRequestHandler) as httpd:
httpd.serve_forever()
"&
);
- name: Wait for the package server to be ready
run: |
for i in {1..60}; do
curl_output=$(curl -v $PACKAGE_URL 2>&1)
if [ $? -eq 0 ]; then
break
fi
sleep 1
done
- name: Run integration tests in an ES Modules project
run: |
cd packages/playground/test-built-npm-packages/es-modules-and-vitest
jq --arg package_url "$PACKAGE_URL" '.devDependencies["@wp-playground/cli"] = $package_url' package.json > package.json.tmp
mv package.json.tmp package.json
npm install
INSTALLED_VERSION=$(npm ls @wp-playground/cli version --depth=0 | tail -n 2 | head -n 1 | cut -d ' ' -f 2)
if [ "$INSTALLED_VERSION" != "@wp-playground/cli@$VERSION" ]; then
echo "The installed version of @wp-playground/cli is not the same as the expected version."
echo "Expected: $VERSION"
echo "Installed: $INSTALLED_VERSION"
exit 1
fi
npm run test
- name: Run integration tests in a CommonJS project
run: |
cd packages/playground/test-built-npm-packages/commonjs-and-jest
jq --arg package_url "$PACKAGE_URL" '.devDependencies["@wp-playground/cli"] = $package_url' package.json > package.json.tmp
mv package.json.tmp package.json
npm install
INSTALLED_VERSION=$(npm ls @wp-playground/cli version --depth=0 | tail -n 2 | head -n 1 | cut -d ' ' -f 2)
if [ "$INSTALLED_VERSION" != "@wp-playground/cli@$VERSION" ]; then
echo "The installed version of @wp-playground/cli is not the same as the expected version."
echo "Expected: $VERSION"
echo "Installed: $INSTALLED_VERSION"
exit 1
fi
npm run test
test-running-unbuilt-playground-cli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- run: packages/playground/cli/tests/test-running-unbuilt-cli.sh
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- run: |
if ADDITIONAL_REMOTE_ORIGINS=invalid-origin npx nx build playground-client; then
echo "The Playground client build should have failed due to an invalid additional origin."
echo "The build does not appear to be applying ADDITIONAL_REMOTE_ORIGINS."
exit 1
fi
npx nx affected --target=build --parallel=3 --verbose
# Deploy documentation job
deploy_docs:
# Only deploy docs when pushing to the WordPress/wordpress-playground repository
if: >
github.repository == 'WordPress/wordpress-playground' &&
github.ref == 'refs/heads/trunk' &&
github.event_name == 'push'
# Add a dependency to the build job
needs: [test-unit-asyncify, test-e2e, test-e2e-components, build]
name: 'Deploy doc site'
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/prepare-playground
- run: npm run build:docs
- uses: actions/upload-pages-artifact@v3
with: { path: dist/docs/build }
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4