From f972ddf4df73c0afbb2ca6242e611007dedcd8da Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Wed, 31 Dec 2025 12:07:19 +0100 Subject: [PATCH 1/4] ci: add code coverage support --- .../workflows/continuous-integration.yml.tpl | 35 +++++++++++++++++++ README.md | 5 +++ 2 files changed, 40 insertions(+) diff --git a/.github/workflows/continuous-integration.yml.tpl b/.github/workflows/continuous-integration.yml.tpl index e787dbb..3e2490e 100644 --- a/.github/workflows/continuous-integration.yml.tpl +++ b/.github/workflows/continuous-integration.yml.tpl @@ -1,5 +1,8 @@ name: "Continuous integration" +# To enable code coverage reporting, +# ensure that the project variable "CODE_COVERAGE" is set to "true" + on: push: branches: @@ -33,3 +36,35 @@ jobs: glpi-version: "${{ matrix.glpi-version }}" php-version: "${{ matrix.php-version }}" db-image: "${{ matrix.db-image }}" + code-coverage: ${{ vars.CODE_COVERAGE == 'true' }} # Value is obtained from project variables + + coverage-report: + needs: "ci" + if: vars.CODE_COVERAGE == 'true' && github.event_name == 'pull_request' + runs-on: "ubuntu-latest" + name: "Coverage report" + steps: + - name: "Download coverage report" + uses: "actions/download-artifact@v4" + with: + name: "coverage-report" + + - name: "Generate coverage summary" + uses: "irongut/CodeCoverageSummary@v1.3.0" + with: + filename: cobertura.xml + badge: true + fail_below_min: false + format: markdown + hide_branch_rate: false + hide_complexity: true + indicators: true + output: both + thresholds: '50 75' + + - name: "Add coverage comment" + uses: "marocchino/sticky-pull-request-comment@v2" + if: ${{ github.event_name == 'pull_request' }} + with: + header: coverage + path: code-coverage-results.md diff --git a/README.md b/README.md index 47f13e4..ed8fa34 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,11 @@ You can also provide a destination path (ie. if your `empty` directory is not in * `{UNAME}` will be replaced by the uppercased name, * `{YEAR}` will be replaced by the current year. +## Enabling Code coverage +By default, code coverage is disabled. + +If you want to enable it, you have to set your project environment variable `CODE_COVERAGE` to `true`. + ## Updating Your Plugin To import the changes made to the _pluginsGLPI empty_ template into your project, From bd67a994a51307210179b33d01e65a2be3f51f51 Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Mon, 23 Feb 2026 10:21:02 +0100 Subject: [PATCH 2/4] ci: add code coverage support --- .github/workflows/continuous-integration.yml | 7 +++++++ .github/workflows/coverage-refresh.yml | 16 ++++++++++++++++ .glpi-coverage.json | 3 +++ 3 files changed, 26 insertions(+) create mode 100644 .github/workflows/coverage-refresh.yml create mode 100644 .glpi-coverage.json diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 6fb4f4e..a5f78ca 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,3 +34,10 @@ jobs: php-version: "${{ matrix.php-version }}" db-image: "${{ matrix.db-image }}" init-script: "./.github/workflows/create-plugin.sh" + + coverage-report: + needs: "ci" + uses: "glpi-project/plugin-ci-workflows/.github/workflows/coverage-report.yml@v1" + with: + plugin-key: "empty" + diff --git a/.github/workflows/coverage-refresh.yml b/.github/workflows/coverage-refresh.yml new file mode 100644 index 0000000..13d01ce --- /dev/null +++ b/.github/workflows/coverage-refresh.yml @@ -0,0 +1,16 @@ +name: "Coverage refresh" + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + coverage-refresh: + uses: "glpi-project/plugin-ci-workflows/.github/workflows/coverage-refresh.yml@v1" + with: + plugin-key: "empty" diff --git a/.glpi-coverage.json b/.glpi-coverage.json new file mode 100644 index 0000000..010732b --- /dev/null +++ b/.glpi-coverage.json @@ -0,0 +1,3 @@ +{ + "enabled": false +} From 9f01d7b0260d812ecaa711effffe03c2a1d2b0e4 Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Wed, 3 Jun 2026 11:53:23 +0200 Subject: [PATCH 3/4] Update documentation and refresh template to match released version --- .../workflows/continuous-integration.yml.tpl | 36 +++---------------- .github/workflows/coverage-refresh.yml | 16 --------- README.md | 4 ++- 3 files changed, 8 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/coverage-refresh.yml diff --git a/.github/workflows/continuous-integration.yml.tpl b/.github/workflows/continuous-integration.yml.tpl index 3e2490e..5fbc455 100644 --- a/.github/workflows/continuous-integration.yml.tpl +++ b/.github/workflows/continuous-integration.yml.tpl @@ -1,7 +1,7 @@ name: "Continuous integration" -# To enable code coverage reporting, -# ensure that the project variable "CODE_COVERAGE" is set to "true" +# Code coverage is automatically enabled when a `.glpi-coverage.json` file +# is present at the root of the plugin directory. on: push: @@ -36,35 +36,9 @@ jobs: glpi-version: "${{ matrix.glpi-version }}" php-version: "${{ matrix.php-version }}" db-image: "${{ matrix.db-image }}" - code-coverage: ${{ vars.CODE_COVERAGE == 'true' }} # Value is obtained from project variables coverage-report: needs: "ci" - if: vars.CODE_COVERAGE == 'true' && github.event_name == 'pull_request' - runs-on: "ubuntu-latest" - name: "Coverage report" - steps: - - name: "Download coverage report" - uses: "actions/download-artifact@v4" - with: - name: "coverage-report" - - - name: "Generate coverage summary" - uses: "irongut/CodeCoverageSummary@v1.3.0" - with: - filename: cobertura.xml - badge: true - fail_below_min: false - format: markdown - hide_branch_rate: false - hide_complexity: true - indicators: true - output: both - thresholds: '50 75' - - - name: "Add coverage comment" - uses: "marocchino/sticky-pull-request-comment@v2" - if: ${{ github.event_name == 'pull_request' }} - with: - header: coverage - path: code-coverage-results.md + uses: "glpi-project/plugin-ci-workflows/.github/workflows/coverage-report.yml@v1" + with: + plugin-key: "{LNAME}" diff --git a/.github/workflows/coverage-refresh.yml b/.github/workflows/coverage-refresh.yml deleted file mode 100644 index 13d01ce..0000000 --- a/.github/workflows/coverage-refresh.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "Coverage refresh" - -on: - schedule: - - cron: "0 0 * * *" - workflow_dispatch: - -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - coverage-refresh: - uses: "glpi-project/plugin-ci-workflows/.github/workflows/coverage-refresh.yml@v1" - with: - plugin-key: "empty" diff --git a/README.md b/README.md index ed8fa34..8662b32 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ You can also provide a destination path (ie. if your `empty` directory is not in ## Enabling Code coverage By default, code coverage is disabled. -If you want to enable it, you have to set your project environment variable `CODE_COVERAGE` to `true`. +You can enable it by updating the `.glpi-coverage.json`. + +Configuration defaults and explanations are available [here](https://github.com/glpi-project/plugin-ci-workflows#code-coverage). ## Updating Your Plugin From 099eaf63b19b72601ca5667193802b4f68f67e52 Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Wed, 3 Jun 2026 11:54:52 +0200 Subject: [PATCH 4/4] Update documentation and refresh template to match released version --- .github/workflows/continuous-integration.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a5f78ca..6fb4f4e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,10 +34,3 @@ jobs: php-version: "${{ matrix.php-version }}" db-image: "${{ matrix.db-image }}" init-script: "./.github/workflows/create-plugin.sh" - - coverage-report: - needs: "ci" - uses: "glpi-project/plugin-ci-workflows/.github/workflows/coverage-report.yml@v1" - with: - plugin-key: "empty" -