From e7be8073a3dc15d154ce7d71749386b13a1370ff Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Mon, 22 Jul 2024 13:31:57 +1000 Subject: [PATCH] test for github code coverage --- .github/workflows/build.yml | 23 ++++++++++++++++++++++- codecov.yml | 9 +++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 codecov.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 45eee5e..15eae32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ name: build on: push - + jobs: set_status_in_progress: name: set_status_in_progress @@ -20,6 +20,27 @@ jobs: with: module_build: true runner: biggy-tide + phpunit_coverage: + name: phpunit_coverage + needs: tide_build + runs-on: biggy-tide + steps: + - name: Run PHPUnit with coverage using phpdbg + run: | + phpdbg -qrr vendor/bin/phpunit ./dpc-sdp --coverage-html ./coverage-report + - name: Check coverage + run: | + coverage=$(grep -Po '(?<=)[0-9.]+(?=%)' ./coverage-report/index.html | head -n 1) + if (( $(echo "$coverage < 80" | bc -l) )); then + echo "Code coverage is below 80%: $coverage%" + exit 1 + fi + shell: bash + - name: Archive code coverage results + uses: actions/upload-artifact@v2 + with: + name: code-coverage-report + path: coverage-report export_config: name: export_config secrets: inherit diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..cdb5911 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,9 @@ +coverage: + status: + project: + default: + target: 80% + threshold: 5% + patch: + default: + target: 80%