mirror of
https://github.com/Cacti/cacti.git
synced 2026-10-23 03:27:02 +09:00
88 lines
3.4 KiB
YAML
88 lines
3.4 KiB
YAML
name: Changed PHP Coverage
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- '**.php'
|
|
- 'tests/phpunit.xml'
|
|
- 'tests/e2e/**'
|
|
- 'tests/Helpers/RequestCoverage.php'
|
|
- 'tests/tools/check_changed_php_coverage.py'
|
|
- 'tests/tools/test_check_changed_php_coverage.py'
|
|
- 'tests/tools/run_request_coverage.sh'
|
|
- 'tests/tools/test_request_coverage_dispatch.py'
|
|
- '.github/workflows/pr-php-coverage.yml'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: changed-php-coverage-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
coverage:
|
|
name: Changed PHP lines >= 80%
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3
|
|
with:
|
|
tool_versions: node 22.22.2
|
|
install_args: node
|
|
- uses: ./.github/actions/setup-php-composer
|
|
with:
|
|
php-version: '8.3'
|
|
coverage: xdebug
|
|
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring
|
|
ini-values: memory_limit=2G
|
|
dependency-mode: locked-pr-coverage
|
|
install-args: --prefer-dist --no-progress --no-interaction
|
|
- name: Validate the coverage gate and include every changed PHP file
|
|
env:
|
|
BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
python3 tests/tools/test_check_changed_php_coverage.py
|
|
python3 tests/tools/test_request_coverage_dispatch.py
|
|
python3 tests/tools/check_changed_php_coverage.py --base "$BASE_COMMIT" \
|
|
--prepare-config tests/phpunit.xml --output-config phpunit-changed.xml
|
|
- name: Exercise unit and integration contracts with statement coverage
|
|
env:
|
|
XDEBUG_MODE: coverage
|
|
run: include/vendor/bin/pest --configuration=phpunit-changed.xml --testsuite=Unit,Integration --coverage-clover=coverage-changed.xml
|
|
- name: Exercise applicable browser and database contracts
|
|
env:
|
|
BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
|
|
CACTI_TEST_COVERAGE: '1'
|
|
CACTI_PR_RAW_COVERAGE: /tmp/cacti-pr-coverage
|
|
CACTI_PR_COVERAGE_OUTPUT: ${{ runner.temp }}/request-coverage
|
|
run: bash tests/tools/run_request_coverage.sh
|
|
- name: Require at least 80 percent of changed executable PHP lines
|
|
env:
|
|
BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
request_args=()
|
|
if compgen -G "${{ runner.temp }}/request-coverage/*.json" > /dev/null; then
|
|
request_args=(--request-reports "${{ runner.temp }}/request-coverage")
|
|
fi
|
|
python3 tests/tools/check_changed_php_coverage.py --base "$BASE_COMMIT" \
|
|
--report coverage-changed.xml "${request_args[@]}" \
|
|
--minimum 80 --json-output coverage-changed.json
|
|
- name: Preserve coverage evidence
|
|
if: always()
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
|
|
with:
|
|
name: changed-php-coverage
|
|
path: |
|
|
coverage-changed.xml
|
|
coverage-changed.json
|
|
${{ runner.temp }}/request-coverage
|
|
if-no-files-found: warn
|