Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ jobs:
strategy:
fail-fast: false
# Uncomment this on private runners, which can't run multiple wp-env instances in parallel.
Comment thread
dipankardas011 marked this conversation as resolved.
max-parallel: 1
matrix:
php: ['8.4', '8.3', '8.2']
wp: ['latest']
Expand Down
58 changes: 6 additions & 52 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,19 @@ on:

jobs:
build:
runs-on: [public-repo]
container:
image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /tmp/wp-env:/tmp/wp-env

runs-on: [self-hosted]
permissions:
contents: read

env:
WP_ENV_PORT: 8889
WP_ENV_HOME: /tmp/wp-env
# Must live on the shared work emptyDir mounted by ARC's dind containerMode
# so the dind sidecar can resolve the bind-mount source paths wp-env generates.
WP_ENV_HOME: /home/runner/_work/_temp/wp-env-home
Comment thread
dipankardas011 marked this conversation as resolved.

timeout-minutes: 30

steps:
- name: Magic thing needed becuase of github as it bind mounts __temp
run: |
sudo apt update && sudo apt install -y acl
sudo setfacl -R -m u:runner:rwX /__w /github/home /github/workflow /tmp/wp-env
sudo setfacl -R -d -m u:runner:rwX /__w /github/home /github/workflow /tmp/wp-env

- name: Configure Docker group permissions
run: |
SOCK_GID=$(stat -c '%g' /var/run/docker.sock)
sudo groupmod -g $SOCK_GID -o docker
sudo usermod -aG $SOCK_GID runner

- name: Set up Docker Compose
uses: docker/setup-compose-action@4eb059ff7f16592f9c84d5ca339c53cb7c5064e2 # v2.3.0
with:
Expand Down Expand Up @@ -77,23 +61,11 @@ jobs:
- name: Build plugin for release
run: npm run build:prod

- name: Fix wp-env host mapping
- name: Pin plugin folder name in wp-env config
run: |
# Get the host path for the workspace by inspecting the container's own mounts
HOST_WORKSPACE_PATH=$(docker inspect $(hostname) --format '{{ range .Mounts }}{{ if eq .Destination "/__w" }}{{ .Source }}{{ end }}{{ end }}')

# Construct the full host path for the current plugin directory
RELATIVE_PATH=$(pwd | sed 's|^/__w||')
PLUGIN_HOST_PATH="${HOST_WORKSPACE_PATH}${RELATIVE_PATH}"

echo "Host Workspace: $HOST_WORKSPACE_PATH"
echo "Plugin Host Path: $PLUGIN_HOST_PATH"

# Update .wp-env.json (default env)
jq --arg path "$PLUGIN_HOST_PATH" \
jq --arg path "$(pwd)" \
'del(.plugins) | .mappings["wp-content/plugins/plugin-skeleton-d"] = $path' \
.wp-env.json > .wp-env.json.tmp && mv .wp-env.json.tmp .wp-env.json

cat .wp-env.json

- name: Start the Docker testing environment
Expand All @@ -120,21 +92,3 @@ jobs:
if: always()
run: npm run wp-env destroy -- --force

- name: Cleanup Workspace & Home to avoid pollution
if: always()
run: |
# Wipes the actual code, build artifacts, and hidden files
sudo rm -rf ./* .[!.]* 2>/dev/null || true

# Deletes everything inside _temp EXCEPT the locked mount points
sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} +

# Empties the contents of the locked directories without deleting the folders themselves
sudo rm -rf /github/home/* || true
sudo rm -rf /github/home/.* 2>/dev/null || true

sudo rm -rf /github/workflow/* || true
sudo rm -rf /github/workflow/.* 2>/dev/null || true

# Empty the wp-env directory
sudo rm -rf /tmp/wp-env/* || true
85 changes: 7 additions & 78 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,17 @@ permissions:
jobs:
e2e:
name: Playwright E2E Tests
runs-on: [public-repo]
container:
image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0
# We use --add-host to get the host IP, and we will use socat to forward
# localhost:8889 to the host so Playwright and WordPress agree on "localhost".
options: --add-host=host.docker.internal:host-gateway
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /tmp/wp-env:/tmp/wp-env
- /tmp/playwright-cache:/tmp/playwright-cache

runs-on: [self-hosted]
timeout-minutes: 30

env:
WP_ENV_PORT: 8889
WP_ENV_HOME: /tmp/wp-env
PLAYWRIGHT_BROWSERS_PATH: /tmp/playwright-cache
# Must live on the shared work emptyDir mounted by ARC's dind containerMode
# so the dind sidecar can resolve the bind-mount source paths wp-env generates.
WP_ENV_HOME: /home/runner/_work/_temp/wp-env-home
Comment thread
dipankardas011 marked this conversation as resolved.

steps:
- name: Magic thing needed becuase of github as it bind mounts __temp
run: |
sudo apt update && sudo apt install -y acl socat
sudo setfacl -R -m u:runner:rwX /__w /github/home /github/workflow /tmp/wp-env /tmp/playwright-cache
sudo setfacl -R -d -m u:runner:rwX /__w /github/home /github/workflow /tmp/wp-env /tmp/playwright-cache

- name: Configure Docker group permissions
run: |
SOCK_GID=$(stat -c '%g' /var/run/docker.sock)
sudo groupmod -g $SOCK_GID -o docker
sudo usermod -aG $SOCK_GID runner

- name: Set up Docker Compose
uses: docker/setup-compose-action@4eb059ff7f16592f9c84d5ca339c53cb7c5064e2 # v2.3.0
with:
Expand Down Expand Up @@ -79,23 +59,11 @@ jobs:
- name: Build development assets
run: npm run build:dev

- name: Fix wp-env host mapping
- name: Pin plugin folder name in wp-env config
run: |
# Get the host path for the workspace by inspecting the container's own mounts
HOST_WORKSPACE_PATH=$(docker inspect $(hostname) --format '{{ range .Mounts }}{{ if eq .Destination "/__w" }}{{ .Source }}{{ end }}{{ end }}')

# Construct the full host path for the current plugin directory
RELATIVE_PATH=$(pwd | sed 's|^/__w||')
PLUGIN_HOST_PATH="${HOST_WORKSPACE_PATH}${RELATIVE_PATH}"

echo "Host Workspace: $HOST_WORKSPACE_PATH"
echo "Plugin Host Path: $PLUGIN_HOST_PATH"

# Update .wp-env.test.json
jq --arg path "$PLUGIN_HOST_PATH" \
jq --arg path "$(pwd)" \
'del(.plugins) | .mappings["wp-content/plugins/plugin-skeleton-d"] = $path' \
.wp-env.test.json > .wp-env.test.json.tmp && mv .wp-env.test.json.tmp .wp-env.test.json

cat .wp-env.test.json

- name: Start the Docker testing environment
Expand All @@ -111,27 +79,7 @@ jobs:
npx playwright install

- name: Run E2E tests
run: |
# Forward localhost traffic from the CI container to the Host machine
# where the WordPress Docker container is actually listening.
# This ensures Playwright and WordPress both agree the domain is "localhost:8889".
if ss -tlnp | grep -q ":${WP_ENV_PORT} "; then
echo "ERROR: Port ${WP_ENV_PORT} already in use"
exit 1
fi

socat TCP4-LISTEN:${WP_ENV_PORT},fork,bind=127.0.0.1 TCP4:host.docker.internal:${WP_ENV_PORT} &
SOCAT_PID=$!

sleep 2
if ! kill -0 "$SOCAT_PID" 2>/dev/null; then
echo "ERROR: socat failed to start"
exit 1
fi

echo "socat running (PID: $SOCAT_PID) on port ${WP_ENV_PORT}"

npm run test:e2e
run: npm run test:e2e

- name: Upload E2E test results as artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand All @@ -146,22 +94,3 @@ jobs:
if: always()
run: npm run wp-env:test destroy -- --force

- name: Cleanup Workspace & Home to avoid pollution
if: always()
run: |
# Wipes the actual code, build artifacts, and hidden files
sudo rm -rf ./* .[!.]* 2>/dev/null || true

# Deletes everything inside _temp EXCEPT the locked mount points
sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} +

# Empties the contents of the locked directories without deleting the folders themselves
sudo rm -rf /github/home/* || true
sudo rm -rf /github/home/.* 2>/dev/null || true

sudo rm -rf /github/workflow/* || true
sudo rm -rf /github/workflow/.* 2>/dev/null || true

# Empty the wp-env directory
sudo rm -rf /tmp/wp-env/* || true
sudo rm -rf /tmp/playwright-cache/* || true
19 changes: 1 addition & 18 deletions .github/workflows/reusable-jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ permissions:
jobs:
jest:
name: Jest Unit Tests${{ inputs.coverage && ' with coverage' || '' }}
runs-on: [public-repo]
container:
image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0
runs-on: [self-hosted]
timeout-minutes: 10

steps:
Expand Down Expand Up @@ -58,18 +56,3 @@ jobs:
retention-days: 7
if-no-files-found: ignore

- name: Cleanup Workspace & Home to avoid pollution
if: always()
run: |
# Wipes the actual code, build artifacts, and hidden files
sudo rm -rf ./* .[!.]* 2>/dev/null || true

# Deletes everything inside _temp EXCEPT the locked mount points
sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} +

# Empties the contents of the locked directories without deleting the folders themselves
sudo rm -rf /github/home/* || true
sudo rm -rf /github/home/.* 2>/dev/null || true

sudo rm -rf /github/workflow/* || true
sudo rm -rf /github/workflow/.* 2>/dev/null || true
19 changes: 1 addition & 18 deletions .github/workflows/reusable-lint-css-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ permissions:
jobs:
lint-js:
name: JS Lint & TypeScript
runs-on: [public-repo]
container:
image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0
runs-on: [self-hosted]
timeout-minutes: 20

steps:
Expand Down Expand Up @@ -57,18 +55,3 @@ jobs:
echo "One or more checks failed. See logs above for details."
exit 1

- name: Cleanup Workspace & Home to avoid pollution
if: always()
run: |
# Wipes the actual code, build artifacts, and hidden files
sudo rm -rf ./* .[!.]* 2>/dev/null || true

# Deletes everything inside _temp EXCEPT the locked mount points
sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} +

# Empties the contents of the locked directories without deleting the folders themselves
sudo rm -rf /github/home/* || true
sudo rm -rf /github/home/.* 2>/dev/null || true

sudo rm -rf /github/workflow/* || true
sudo rm -rf /github/workflow/.* 2>/dev/null || true
19 changes: 1 addition & 18 deletions .github/workflows/reusable-phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ permissions:
jobs:
phpcs:
name: PHPCS Coding Standards
runs-on: [public-repo]
container:
image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0
runs-on: [self-hosted]
timeout-minutes: 20

steps:
Expand Down Expand Up @@ -57,18 +55,3 @@ jobs:
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr ./tests/_output/phpcs-report.xml

- name: Cleanup Workspace & Home to avoid pollution
if: always()
run: |
# Wipes the actual code, build artifacts, and hidden files
sudo rm -rf ./* .[!.]* 2>/dev/null || true

# Deletes everything inside _temp EXCEPT the locked mount points
sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} +

# Empties the contents of the locked directories without deleting the folders themselves
sudo rm -rf /github/home/* || true
sudo rm -rf /github/home/.* 2>/dev/null || true

sudo rm -rf /github/workflow/* || true
sudo rm -rf /github/workflow/.* 2>/dev/null || true
19 changes: 1 addition & 18 deletions .github/workflows/reusable-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ permissions:
jobs:
phpstan:
name: PHPStan Static Analysis
runs-on: [public-repo]
container:
image: ghcr.io/actions/actions-runner@sha256:1ad983536759ceec39ed75a2c8f007ca8c37b66eee35ed86f13623b29a4db97d # v2.333.0
runs-on: [self-hosted]
timeout-minutes: 20

steps:
Expand Down Expand Up @@ -60,18 +58,3 @@ jobs:
path: tests/_output
key: phpstan-result-cache-${{ runner.os }}-date-${{ steps.get-date.outputs.date }}

- name: Cleanup Workspace & Home to avoid pollution
if: always()
run: |
# Wipes the actual code, build artifacts, and hidden files
sudo rm -rf ./* .[!.]* 2>/dev/null || true

# Deletes everything inside _temp EXCEPT the locked mount points
sudo find /__w/_temp/ -mindepth 1 -maxdepth 1 ! -name '_github_home' ! -name '_github_workflow' -exec rm -rf {} +

# Empties the contents of the locked directories without deleting the folders themselves
sudo rm -rf /github/home/* || true
sudo rm -rf /github/home/.* 2>/dev/null || true

sudo rm -rf /github/workflow/* || true
sudo rm -rf /github/workflow/.* 2>/dev/null || true
Loading
Loading