Merge pull request #613 from phparkitect/claude/review-issue-612-HHtZy #2567
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: Test | |
| on: | |
| push: | |
| pull_request: | |
| release: | |
| types: | |
| - published | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: "ubuntu-22.04" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-versions: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-versions }} | |
| coverage: pcov | |
| tools: composer:v2.2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Validate composer.json and composer.lock | |
| run: composer validate | |
| - name: Cache Composer packages | |
| id: composer-cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: vendor | |
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php- | |
| - name: Install dependencies | |
| run: composer install --prefer-dist | |
| - name: Static Analysis | |
| if: ${{ matrix.php-versions == '8.0' }} | |
| run: ./bin/psalm.phar --no-cache | |
| - name: Test with coverage | |
| if: ${{ matrix.php-versions == '8.0' }} | |
| run: ./bin/phpunit -d memory_limit=-1 --coverage-clover clover.xml | |
| - name: Test without coverage | |
| if: ${{ matrix.php-versions != '8.0' }} | |
| run: ./bin/phpunit -d memory_limit=-1 | |
| - name: Upload coverage to Codecov | |
| if: ${{ matrix.php-versions == '8.0' }} | |
| uses: codecov/codecov-action@v6 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| phar: | |
| runs-on: "ubuntu-22.04" | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.2 | |
| tools: composer:v2.2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Box 4.x requires PHP 8.2+ to run, but the released PHAR must still | |
| # support PHP 8.0+. Pin the resolver platform so composer installs the | |
| # PHP 8.0-compatible dependency set regardless of the runner's PHP. | |
| - name: "Pin composer platform to PHP 8.0 for the released PHAR" | |
| run: composer config platform.php 8.0 | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-dev -o | |
| - name: "Compile phparkitect phar" | |
| run: php bin/box.phar compile -c ./box.json | |
| - name: "Check phar" | |
| run: php ./phparkitect.phar | |
| - name: "Rename phar to avoid conflicts" | |
| run: mv ./phparkitect.phar phparkitect-${{ github.sha }}.phar | |
| - name: "Upload phar file artifact" | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: phar-artifact | |
| path: ./phparkitect-${{ github.sha }}.phar | |
| retention-days: 1 | |
| smoke-test-phar: | |
| needs: phar | |
| runs-on: "ubuntu-22.04" | |
| strategy: | |
| matrix: | |
| php-versions: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-versions }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: "Download phar ./phparkitect-${{ github.sha }}.phar" | |
| uses: actions/download-artifact@v8 | |
| with: | |
| # will download phar in project root | |
| name: phar-artifact | |
| - name: "Smoke test phar" | |
| run: php ./phparkitect-${{ github.sha }}.phar | |
| - name: "End-to-end test phar: run check on fixture" | |
| run: | | |
| php ./phparkitect-${{ github.sha }}.phar check \ | |
| --config tests/E2E/_fixtures/autoload/phparkitect.php \ | |
| --autoload tests/E2E/_fixtures/autoload/autoload.php | |
| publish_phar: | |
| needs: [build, smoke-test-phar] | |
| runs-on: "ubuntu-22.04" | |
| if: github.event_name == 'release' | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: "Download phar ./phparkitect-${{ github.sha }}.phar" | |
| uses: actions/download-artifact@v8 | |
| with: | |
| # will download phar in project root | |
| name: phar-artifact | |
| - name: Import GPG key | |
| uses: crazy-max/ghaction-import-gpg@v7 | |
| with: | |
| gpg_private_key: ${{ secrets.GPG_KEY_47CD54B6398FE21B3709D0A4D9C905CED1932CA2 }} | |
| passphrase: ${{ secrets.GPG_KEY_47CD54B6398FE21B3709D0A4D9C905CED1932CA2_PASSPHRASE }} | |
| - name: Rename phar | |
| run: mv ./phparkitect-${{ github.sha }}.phar phparkitect.phar | |
| - name: Sign the PHAR | |
| run: | | |
| gpg --local-user 47CD54B6398FE21B3709D0A4D9C905CED1932CA2 \ | |
| --batch \ | |
| --yes \ | |
| --passphrase="${{ secrets.GPG_KEY_47CD54B6398FE21B3709D0A4D9C905CED1932CA2_PASSPHRASE }}" \ | |
| --detach-sign \ | |
| --output ./phparkitect.phar.asc \ | |
| ./phparkitect.phar | |
| - name: Add phar to the release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| files: | | |
| phparkitect.phar | |
| phparkitect.phar.asc | |