Harden GitHub Actions workflows (#47) #143
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: Test (PHP ${{ matrix.php }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| php: ["8.2", "8.3", "8.4", "8.5"] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| coverage: none | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Run tests | |
| run: ./vendor/bin/pest | |
| format-check: | |
| name: Check Code Style | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 | |
| with: | |
| php-version: "8.2" | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Check formatting | |
| run: composer format:check | |
| production-build: | |
| name: Production Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 | |
| with: | |
| php-version: "8.2" | |
| coverage: none | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Build production dependencies | |
| run: composer build | |
| - name: Verify production vendor contents | |
| run: | | |
| test -f vendor/autoload.php | |
| for package in vendor/pestphp vendor/phpunit vendor/mockery vendor/friendsofphp vendor/php-stubs; do | |
| if [ -e "$package" ]; then | |
| echo "Unexpected development package in production vendor: $package" | |
| exit 1 | |
| fi | |
| done | |
| - name: Verify release package layout | |
| run: | | |
| mkdir -p release | |
| rsync -av --exclude-from=.distignore . release/hellotext-wordpress/ | |
| test -f release/hellotext-wordpress/hellotext.php | |
| test -d release/hellotext-wordpress/src | |
| test -f release/hellotext-wordpress/vendor/autoload.php | |
| for path in \ | |
| release/hellotext-wordpress/tests \ | |
| release/hellotext-wordpress/composer.json \ | |
| release/hellotext-wordpress/composer.lock \ | |
| release/hellotext-wordpress/.github \ | |
| release/hellotext-wordpress/.php-cs-fixer.cache \ | |
| release/hellotext-wordpress/.php-cs-fixer.php \ | |
| release/hellotext-wordpress/DEVELOPMENT.md \ | |
| release/hellotext-wordpress/API.md \ | |
| release/hellotext-wordpress/release; do | |
| if [ -e "$path" ]; then | |
| echo "Unexpected development file in release package: $path" | |
| exit 1 | |
| fi | |
| done |