diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index ec5ca1b..268c29b 100644 --- a/.github/workflows/plugin-ci-workflow.yml +++ b/.github/workflows/plugin-ci-workflow.yml @@ -74,6 +74,8 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: path: cacti/plugins/evidence + # patch-coverage.php diffs against the base branch below. + fetch-depth: 0 - name: Install PHP ${{ matrix.php }} uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 @@ -191,13 +193,23 @@ jobs: run: echo -n "${{ env.CACTI }}" | sudo tee ${{ github.workspace }}/cacti/plugins/evidence/tests/.cacti-version > /dev/null - name: Run Pest Unit Tests - env: - COMPOSER_ROOT_VERSION: 1.3.0-dev run: | cd ${{ github.workspace }}/cacti include/vendor/bin/pest --configuration=plugins/evidence/phpunit.xml \ --coverage-clover=plugins/evidence/coverage/clover.xml + # Whole-file coverage is meaningless here: most of the plugin only runs + # inside a live Cacti. What is enforceable is that a change covers the + # lines it adds. + - name: Enforce coverage of changed lines + if: github.event_name == 'pull_request' + env: + BASE_REF: ${{ github.event.pull_request.base.sha }} + run: | + cd ${{ github.workspace }}/cacti/plugins/evidence + git config --global --add safe.directory ${{ github.workspace }}/cacti/plugins/evidence + php tests/bin/patch-coverage.php coverage/clover.xml "$BASE_REF" 100 + - name: Upload coverage report if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/.gitignore b/.gitignore index 604f91f..5484c3e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ # Weblate after merge; only locales/po/cacti.pot should be committed in PRs. locales/po/*.mo locales/LC_MESSAGES/*.mo +locales/po/*.po diff --git a/CHANGELOG.md b/CHANGELOG.md index 5250a28..feb6a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog --- develop --- +* dev: Enforce patch coverage of changed lines in CI and remove the inert COMPOSER_ROOT_VERSION env from the Pest step * security: Add a version-safe CSP nonce (`plugin_evidence_csp_nonce()`) to every inline `