Skip to content

fix: use pnpm version from package.json packageManager field #4

fix: use pnpm version from package.json packageManager field

fix: use pnpm version from package.json packageManager field #4

Workflow file for this run

name: Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build Plugin
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@eae0cfeb286e66ffb5155f1a79b90583a127a68b # v2.4.1
# Version is automatically read from package.json packageManager field
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build frontend assets
run: pnpm run build
- name: Verify build output
run: |
if [ ! -f "build/index.tsx.js" ]; then
echo "Error: Build failed - build/index.tsx.js not found"
exit 1
fi
if [ ! -f "build/index.tsx.asset.php" ]; then
echo "Error: Build failed - build/index.tsx.asset.php not found"
exit 1
fi
echo "✅ Build successful!"
ls -lh build/
- name: Check plugin file syntax
run: |
# Check PHP syntax
if command -v php &> /dev/null; then
echo "Checking PHP syntax..."
ERRORS=$(find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; 2>&1 | grep -v "No syntax errors" || true)
if [ -n "$ERRORS" ]; then
echo "PHP syntax errors found:"
echo "$ERRORS"
exit 1
else
echo "✅ All PHP files have valid syntax"
fi
else
echo "PHP not installed, skipping syntax check"
fi
- name: Build Summary
run: |
echo "### Build Status ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All checks passed!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Build Artifacts:**" >> $GITHUB_STEP_SUMMARY
echo "- \`build/index.tsx.js\` ($(du -h build/index.tsx.js | cut -f1))" >> $GITHUB_STEP_SUMMARY
echo "- \`build/index.tsx.asset.php\`" >> $GITHUB_STEP_SUMMARY
- name: Upload build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: build-artifacts
path: build/
retention-days: 7