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
47 changes: 47 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PHPUnit Tests

on:
pull_request:
branches: [ trunk, develop ]

jobs:
phpunit:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Disable persisted checkout credentials.

actions/checkout should set persist-credentials: false so the job token is not left in local git config for subsequent steps.

Suggested hardening
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@v4
+        with:
+          persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
persist-credentials: false
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 13-13: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 13-13: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/phpunit.yml at line 13, The workflow step currently uses
actions/checkout@v4 without disabling credential persistence; update the
checkout step (actions/checkout@v4) to include persist-credentials: false so the
job token is not stored in local git config for later steps, e.g., add the
persist-credentials: false input under the checkout step.

Source: Linters/SAST tools


- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer

- name: Setup Node.js
uses: actions/setup-node@v4
with:
Comment on lines +13 to +23

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pin all GitHub Actions to full commit SHAs.

Using floating tags (@v4, @v2) violates the repository’s stated policy and weakens supply-chain integrity in CI.

Suggested hardening
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@<full_commit_sha>

-        uses: shivammathur/setup-php@v2
+        uses: shivammathur/setup-php@<full_commit_sha>

-        uses: actions/setup-node@v4
+        uses: actions/setup-node@<full_commit_sha>
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 13-13: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 13-13: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 16-16: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 22-22: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/phpunit.yml around lines 13 - 23, The workflow uses
floating tags for actions (actions/checkout@v4, shivammathur/setup-php@v2,
actions/setup-node@v4); update each "uses" invocation to a pinned full commit
SHA for actions/checkout, shivammathur/setup-php, and actions/setup-node to
comply with the repository policy and improve supply-chain integrity—locate the
three uses lines in the phpunit.yml and replace the tag versions with their
respective commit SHAs from the official repos.

Source: Linters/SAST tools

node-version: '20'
cache: 'npm'

# Dev dependencies required: test:php runs vendor/bin/phpunit.
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist

- name: Install npm dependencies
run: npm ci --force

# Build so register_block_type finds build/blocks; phpunit.xml.dist sets
# convertWarningsToExceptions, so a missing build dir would fail activation.
- name: Build plugin assets
run: npm run build

- name: Start wp-env
run: npx wp-env start

- name: Run PHPUnit tests
run: npm run test:php

- name: Stop wp-env
if: always()
run: npx wp-env stop
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build/*
# wp-env local overrides (per-machine ports etc. — never commit)
.wp-env.override.json

# Local manual WP-CLI test-data seeder (run by hand, never committed)
seed-test-events.php

# Playwright
test-results/
playwright-report/
Expand Down
Loading
Loading