diff --git a/.github/workflows/rtcamp-standard.yml b/.github/workflows/rtcamp-standard.yml new file mode 100644 index 00000000..60e1757c --- /dev/null +++ b/.github/workflows/rtcamp-standard.yml @@ -0,0 +1,59 @@ +name: rtCamp Standard + +on: + workflow_call: + inputs: + build-artifact-paths: + description: 'Newline-separated paths whose contents must not be committed.' + required: false + type: string + default: | + assets/build/ + run-phpstan: + description: 'Whether to run the PHPStan job.' + required: false + type: boolean + default: true + +permissions: + contents: read + +jobs: + build-artifact-gate: + name: 'Block committed build artifacts' + if: ${{ github.event_name == 'pull_request' }} + uses: rtCamp/wp-shared-workflows/.github/workflows/ci-build-artifact-gate.yml@ff44a8745c5360e28a5316c39b4468c6cf5e0cb6 + with: + gated-paths: ${{ inputs.build-artifact-paths }} + + phpstan: + name: 'PHPStan' + runs-on: ubuntu-latest + if: ${{ inputs.run-phpstan }} + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + coverage: none + + - name: Get Composer Cache Directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Configure Composer cache + uses: actions/cache@v5.0.3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction --no-scripts + + - name: Run PHPStan + run: composer phpstan diff --git a/.github/workflows/test-measure.yml b/.github/workflows/test-measure.yml index 7ade3296..a8225dbf 100644 --- a/.github/workflows/test-measure.yml +++ b/.github/workflows/test-measure.yml @@ -61,7 +61,7 @@ jobs: MODIFIED_FILES_DATA=$(node .github/bin/determine-modified-files-count.js "$IGNORE_PATH_REGEX" "$MODIFIED_FILES" "all") CSS_FILE_COUNT=$(node .github/bin/determine-modified-files-count.js ".+\.s?css|package\.json|package-lock\.json" "$MODIFIED_FILES") JS_FILE_COUNT=$(node .github/bin/determine-modified-files-count.js ".+\.(js|snap)|package\.json|package-lock\.json" "$MODIFIED_FILES") - PHP_FILE_COUNT=$(node .github/bin/determine-modified-files-count.js ".+\.php|composer\.(json|lock)|phpstan\.neon\.dist" "$MODIFIED_FILES") + PHP_FILE_COUNT=$(node .github/bin/determine-modified-files-count.js ".+\.php|composer\.(json|lock)|phpstan\.neon\.dist|phpstan-baseline\.neon" "$MODIFIED_FILES") GHA_WORKFLOW_COUNT=$(node .github/bin/determine-modified-files-count.js "(\.github\/(workflows|actions)\/.+\.yml)" "$MODIFIED_FILES") echo "Changed file count: $MODIFIED_FILES_DATA" @@ -218,3 +218,11 @@ jobs: run: npm run build:prod env: CI: true + + rtcamp-standard: + name: 'rtCamp Standard' + needs: pre-run + if: ${{ github.event_name == 'pull_request' }} + uses: ./.github/workflows/rtcamp-standard.yml + with: + run-phpstan: ${{ fromJSON(needs.pre-run.outputs.changed-php-count) > 0 }}