From eaf8967e9572850d1f53e4420dc616d825912351 Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Wed, 31 Dec 2025 12:07:19 +0100 Subject: [PATCH 1/2] 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 b54f9473a0125c05323157ed0df78ee378390610 Mon Sep 17 00:00:00 2001 From: Benoit VIGNAL Date: Mon, 23 Feb 2026 10:21:02 +0100 Subject: [PATCH 2/2] 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 +}