Merge branch 'main' into claude/php7-deprecation-analysis-z2PjX #2204
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 | |
| 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: Coding Standard Checks | |
| if: ${{ matrix.php-versions == '8.0' }} | |
| run: PHP_CS_FIXER_IGNORE_ENV=1 ./bin/php-cs-fixer fix --dry-run --diff | |
| - 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@v5 | |
| 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.0 | |
| tools: composer:v2.2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - 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@v6 | |
| 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: | |
| - 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@v7 | |
| with: | |
| # will download phar in project root | |
| name: phar-artifact | |
| - name: "Smoke test phar" | |
| run: php ./phparkitect-${{ github.sha }}.phar | |
| 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@v7 | |
| with: | |
| # will download phar in project root | |
| name: phar-artifact | |
| - name: Import GPG key | |
| uses: crazy-max/ghaction-import-gpg@v6 | |
| 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@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| files: | | |
| phparkitect.phar | |
| phparkitect.phar.asc | |
| publish_docker_images: | |
| needs: [build, smoke-test-phar] | |
| runs-on: "ubuntu-22.04" | |
| if: github.ref == 'refs/heads/main' || github.event_name == 'release' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Docker meta | |
| id: meta | |
| uses: crazy-max/ghaction-docker-meta@v5 | |
| with: | |
| images: phparkitect/phparkitect | |
| tags: | | |
| type=raw,value=latest,enable=${{ endsWith(github.ref, 'main') }} | |
| type=ref,event=tag | |
| flavor: | | |
| latest=false | |
| - name: Login to DockerHub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: . | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |