From 22c739673ebe30d13a75febd4b0e127cf9cc547f Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Fri, 19 May 2023 23:19:22 +0200 Subject: [PATCH 1/9] Running unit tests with coverage and generating an XML coverage report. Signed-off-by: Mathis Richter --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02a887d7f..f29da8e75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,4 +68,5 @@ jobs: poetry run git lfs fetch poetry run git lfs pull # poetry run pytest - poetry run python -m unittest discover -s tests/ -t . -vv + poetry run coverage run -m unittest discover -s tests/ -t . -vv + poetry run coverage xml From 4c0527e7189e552464d338db4bba1f62235b538b Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Fri, 19 May 2023 23:19:52 +0200 Subject: [PATCH 2/9] Adding Github action to upload coverage report to Codacy. Signed-off-by: Mathis Richter --- .github/workflows/codacy_coverage_reporter.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/codacy_coverage_reporter.yml diff --git a/.github/workflows/codacy_coverage_reporter.yml b/.github/workflows/codacy_coverage_reporter.yml new file mode 100644 index 000000000..e15604b47 --- /dev/null +++ b/.github/workflows/codacy_coverage_reporter.yml @@ -0,0 +1,15 @@ +name: Codacy Coverage Reporter + +on: ["push"] + +jobs: + codacy-coverage-reporter: + runs-on: ubuntu-latest + name: codacy-coverage-reporter + steps: + - uses: actions/checkout@v2 + - name: Run codacy-coverage-reporter + uses: codacy/codacy-coverage-reporter-action@v1 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.xml \ No newline at end of file From bc2542ff9f0880fc78ca2ba1384ad85419c6a7d1 Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Fri, 19 May 2023 23:40:28 +0200 Subject: [PATCH 3/9] Updated checkout action Signed-off-by: Mathis Richter --- .github/workflows/codacy_coverage_reporter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codacy_coverage_reporter.yml b/.github/workflows/codacy_coverage_reporter.yml index e15604b47..5e8a9f4c5 100644 --- a/.github/workflows/codacy_coverage_reporter.yml +++ b/.github/workflows/codacy_coverage_reporter.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest name: codacy-coverage-reporter steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run codacy-coverage-reporter uses: codacy/codacy-coverage-reporter-action@v1 with: From 6783b8d2949b6c3cc1aa34e8bba59fc667f9843e Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Sat, 20 May 2023 00:19:23 +0200 Subject: [PATCH 4/9] Archiving coverage report as artifact Signed-off-by: Mathis Richter --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f29da8e75..f3bd79bca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,4 +69,13 @@ jobs: poetry run git lfs pull # poetry run pytest poetry run coverage run -m unittest discover -s tests/ -t . -vv - poetry run coverage xml + + - name: Generate coverage report + run: poetry run coverage xml + + - name: Archive coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage + path: coverage.xml + retention-days: 30 \ No newline at end of file From 0318b3639e8c93d9bdc0d5a95d732a7e0556cbec Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Sat, 20 May 2023 00:19:50 +0200 Subject: [PATCH 5/9] Dependency on unit tests and download of coverage report artifact. Signed-off-by: Mathis Richter --- .github/workflows/codacy_coverage_reporter.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/codacy_coverage_reporter.yml b/.github/workflows/codacy_coverage_reporter.yml index 5e8a9f4c5..7a543a7bc 100644 --- a/.github/workflows/codacy_coverage_reporter.yml +++ b/.github/workflows/codacy_coverage_reporter.yml @@ -6,7 +6,12 @@ jobs: codacy-coverage-reporter: runs-on: ubuntu-latest name: codacy-coverage-reporter + needs: unit-tests steps: + - uses: actions/download-artifact@master + with: + name: coverage + - uses: actions/checkout@v3 - name: Run codacy-coverage-reporter uses: codacy/codacy-coverage-reporter-action@v1 From b3b3e108819f3a4f2a2ee125d7b5d174157ffe83 Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Sat, 20 May 2023 00:20:43 +0200 Subject: [PATCH 6/9] Replaced download-artifact@master with @v3 Signed-off-by: Mathis Richter --- .github/workflows/codacy_coverage_reporter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codacy_coverage_reporter.yml b/.github/workflows/codacy_coverage_reporter.yml index 7a543a7bc..e492403e1 100644 --- a/.github/workflows/codacy_coverage_reporter.yml +++ b/.github/workflows/codacy_coverage_reporter.yml @@ -8,7 +8,7 @@ jobs: name: codacy-coverage-reporter needs: unit-tests steps: - - uses: actions/download-artifact@master + - uses: actions/download-artifact@v3 with: name: coverage From 58ffaedc7733ae2776dac8131e3da784845086cb Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Sat, 20 May 2023 00:25:47 +0200 Subject: [PATCH 7/9] Dependency on completed 'Run CI' workflow. Signed-off-by: Mathis Richter --- .github/workflows/codacy_coverage_reporter.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codacy_coverage_reporter.yml b/.github/workflows/codacy_coverage_reporter.yml index e492403e1..63acf346e 100644 --- a/.github/workflows/codacy_coverage_reporter.yml +++ b/.github/workflows/codacy_coverage_reporter.yml @@ -1,12 +1,15 @@ name: Codacy Coverage Reporter -on: ["push"] +on: + workflow_run: + workflows: ["Run CI"] + types: + - completed jobs: codacy-coverage-reporter: runs-on: ubuntu-latest name: codacy-coverage-reporter - needs: unit-tests steps: - uses: actions/download-artifact@v3 with: From cbe0de1cf93835c3f30951071748fcc292457b3c Mon Sep 17 00:00:00 2001 From: Marcus G K Williams <168222+mgkwill@users.noreply.github.com> Date: Fri, 19 May 2023 15:43:46 -0700 Subject: [PATCH 8/9] Add workflow_dispatch to codacy coverage job --- .github/workflows/codacy_coverage_reporter.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codacy_coverage_reporter.yml b/.github/workflows/codacy_coverage_reporter.yml index 63acf346e..5b677ab26 100644 --- a/.github/workflows/codacy_coverage_reporter.yml +++ b/.github/workflows/codacy_coverage_reporter.yml @@ -5,6 +5,7 @@ on: workflows: ["Run CI"] types: - completed + workflow_dispatch: jobs: codacy-coverage-reporter: @@ -20,4 +21,4 @@ jobs: uses: codacy/codacy-coverage-reporter-action@v1 with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: coverage.xml \ No newline at end of file + coverage-reports: coverage.xml From 7091091c8be4966b7cb8c67b8a0349750c128238 Mon Sep 17 00:00:00 2001 From: Mathis Richter Date: Sat, 20 May 2023 00:59:16 +0200 Subject: [PATCH 9/9] Generating coverage report only for Linux. Signed-off-by: Mathis Richter --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3bd79bca..67191a6ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,9 +71,11 @@ jobs: poetry run coverage run -m unittest discover -s tests/ -t . -vv - name: Generate coverage report + if: runner.os == 'Linux' run: poetry run coverage xml - name: Archive coverage report + if: runner.os == 'Linux' uses: actions/upload-artifact@v3 with: name: coverage