diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index 3b5082b..721dc1b 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/quicktree + # 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 @@ -186,13 +188,23 @@ jobs: run: echo -n "${{ env.CACTI }}" | sudo tee ${{ github.workspace }}/cacti/plugins/quicktree/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/quicktree/phpunit.xml \ --coverage-clover=plugins/quicktree/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/quicktree + git config --global --add safe.directory ${{ github.workspace }}/cacti/plugins/quicktree + 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 7610df5..94c9014 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ locales/po/*.mo locales/LC_MESSAGES/*.mo vendor/ +locales/po/*.po diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b326a7..177ed3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ --- 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_quicktree_csp_nonce()`) to every inline `