test: make legacy strict-level coverage independent of php.ini #30
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: QA and reproducible package | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| qa: | |
| name: PHP ${{ matrix.php }} QA | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['7.4', '8.3', '8.5'] | |
| steps: | |
| - name: Check out source | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: dom, json, mbstring, openssl, zip | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Install locked development tools | |
| run: composer install --no-interaction --prefer-dist | |
| - name: Run complete source QA | |
| run: composer qa | |
| wordpress-integration: | |
| name: WordPress ${{ matrix.wordpress }} / PHP ${{ matrix.php }} | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.4 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping --host=127.0.0.1 --user=root --password=root" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=10 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - wordpress: '6.2.0' | |
| php: '7.4' | |
| - wordpress: '7.0.2' | |
| php: '7.4' | |
| - wordpress: '7.0.2' | |
| php: '8.3' | |
| - wordpress: '7.0.2' | |
| php: '8.5' | |
| steps: | |
| - name: Check out source | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: mysqli, openssl | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Install locked development tools | |
| run: composer install --no-interaction --prefer-dist | |
| - name: Install WordPress test suite | |
| run: bash scripts/install-wp-tests.sh wordpress_test root root 127.0.0.1:3306 ${{ matrix.wordpress }} | |
| - name: Run WordPress integration tests | |
| env: | |
| WP_TESTS_DIR: /tmp/wordpress-tests-lib | |
| run: vendor/bin/phpunit --configuration tests/integration/phpunit.xml.dist | |
| package: | |
| name: Build and inspect installation ZIP | |
| runs-on: ubuntu-latest | |
| needs: [qa, wordpress-integration] | |
| steps: | |
| - name: Check out source | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| extensions: zip | |
| coverage: none | |
| tools: none | |
| - name: Build deterministic package | |
| run: php scripts/build-release.php | |
| - name: Test ZIP integrity | |
| run: | | |
| unzip -t dist/codegenie-pulse-connector-1.2.2.zip | |
| unzip -t dist/codegenie-pulse-connector-wordpress-1.2.2-source.zip | |
| - name: Verify reproducibility | |
| run: | | |
| first_install="$(sha256sum dist/codegenie-pulse-connector-1.2.2.zip | cut -d ' ' -f 1)" | |
| first_source="$(sha256sum dist/codegenie-pulse-connector-wordpress-1.2.2-source.zip | cut -d ' ' -f 1)" | |
| php scripts/build-release.php | |
| second_install="$(sha256sum dist/codegenie-pulse-connector-1.2.2.zip | cut -d ' ' -f 1)" | |
| second_source="$(sha256sum dist/codegenie-pulse-connector-wordpress-1.2.2-source.zip | cut -d ' ' -f 1)" | |
| test "$first_install" = "$second_install" | |
| test "$first_source" = "$second_source" | |
| - name: Extract built package for Plugin Check | |
| run: unzip -q dist/codegenie-pulse-connector-1.2.2.zip -d plugin-build | |
| - name: Run official Plugin Check against built package | |
| uses: wordpress/plugin-check-action@v1 | |
| with: | |
| build-dir: plugin-build/codegenie-pulse-connector | |
| slug: codegenie-pulse-connector | |
| wp-version: latest | |
| strict: true | |
| - name: Upload reviewed installation artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codegenie-pulse-connector-1.2.2-release-candidate | |
| path: | | |
| dist/codegenie-pulse-connector-1.2.2.zip | |
| dist/codegenie-pulse-connector-1.2.2.files.txt | |
| dist/codegenie-pulse-connector-1.2.2.sha256 | |
| dist/codegenie-pulse-connector-wordpress-1.2.2-source.zip | |
| dist/codegenie-pulse-connector-wordpress-1.2.2-source.files.txt | |
| dist/codegenie-pulse-connector-wordpress-1.2.2-source.sha256 | |
| if-no-files-found: error | |
| retention-days: 14 | |
| release: | |
| name: Publish GitHub release | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| needs: package | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check out source | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| extensions: zip | |
| coverage: none | |
| tools: none | |
| - name: Resolve release identity | |
| id: release | |
| env: | |
| VERSION: '1.2.2' | |
| run: | | |
| set -euo pipefail | |
| php scripts/check-release-version.php "$VERSION" | |
| tag="v$VERSION" | |
| git fetch --tags --force | |
| if git rev-parse "$tag" >/dev/null 2>&1; then | |
| tagged_commit="$(git rev-list --max-count=1 "$tag")" | |
| if [[ "$tagged_commit" != "$GITHUB_SHA" ]]; then | |
| echo "Version $tag is already released at $tagged_commit; no new release is required for this commit." | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$tag" "$GITHUB_SHA" -m "$tag" | |
| git push origin "$tag" | |
| fi | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| echo "publish=true" >> "$GITHUB_OUTPUT" | |
| - name: Rebuild reviewed release artifacts | |
| if: steps.release.outputs.publish == 'true' | |
| run: php scripts/build-release.php | |
| - name: Create or repair GitHub release | |
| if: steps.release.outputs.publish == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| TAG: ${{ steps.release.outputs.tag }} | |
| run: | | |
| set -euo pipefail | |
| assets=( | |
| dist/codegenie-pulse-connector-1.2.2.zip | |
| dist/codegenie-pulse-connector-1.2.2.files.txt | |
| dist/codegenie-pulse-connector-1.2.2.sha256 | |
| dist/codegenie-pulse-connector-wordpress-1.2.2-source.zip | |
| dist/codegenie-pulse-connector-wordpress-1.2.2-source.files.txt | |
| dist/codegenie-pulse-connector-wordpress-1.2.2-source.sha256 | |
| ) | |
| if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then | |
| gh release upload "$TAG" "${assets[@]}" --repo "$GITHUB_REPOSITORY" --clobber | |
| exit 0 | |
| fi | |
| gh release create "$TAG" "${assets[@]}" \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --target "$TAG" \ | |
| --title "$TAG" \ | |
| --notes-file docs/releases/1.2.2.md |