From b7596b27f15c41875df78d20ee4461fd82d9e529 Mon Sep 17 00:00:00 2001 From: leehk Date: Sun, 20 Apr 2025 15:45:20 +0800 Subject: [PATCH 01/21] try coverage --- .github/workflows/template_test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/template_test.yml b/.github/workflows/template_test.yml index bc27407..f6a03f0 100644 --- a/.github/workflows/template_test.yml +++ b/.github/workflows/template_test.yml @@ -238,6 +238,13 @@ jobs: report_paths: ${{ runner.temp }}/${{ inputs.testResultsFilename }} include_passed: true + - name: PublishCodeCoverageResults + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + report_files: ${{ inputs.testResultsPath }}/${{ inputs.testResultsFilename }} + github_token: ${{ secrets.GITHUB_TOKEN }} + minimum_coverage: 50 + - name: Docker Compose Down if: always() # Always run cleanup run: | From 7257abdcc83cc11792a5f488dcba33c55b7fc2ea Mon Sep 17 00:00:00 2001 From: leehk Date: Sun, 20 Apr 2025 16:52:38 +0800 Subject: [PATCH 02/21] update report path --- .github/workflows/template_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_test.yml b/.github/workflows/template_test.yml index f6a03f0..c54aeb5 100644 --- a/.github/workflows/template_test.yml +++ b/.github/workflows/template_test.yml @@ -241,7 +241,7 @@ jobs: - name: PublishCodeCoverageResults uses: irongut/CodeCoverageSummary@v1.3.0 with: - report_files: ${{ inputs.testResultsPath }}/${{ inputs.testResultsFilename }} + report_files: ${{ runner.temp }}/${{ inputs.testResultsFilename }} github_token: ${{ secrets.GITHUB_TOKEN }} minimum_coverage: 50 From fa2b90d4bf77e80a5f766ad87c808a15b1fd688a Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 10:24:04 +0800 Subject: [PATCH 03/21] update --- .github/workflows/build.yml | 3 - .github/workflows/template_test.yml | 2 +- .github/workflows/template_unit_pytest.yml | 84 ++++++++++++++++++++++ .github/workflows/unittest_backend.yml | 19 +++++ app/frontend/vite.config.ts | 2 +- 5 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/template_unit_pytest.yml create mode 100644 .github/workflows/unittest_backend.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1828ff..d3ef0f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,6 @@ on: pull_request: branches: - develop - # paths: - # - 'app/**' - # - '.github/workflows/**' # Concurrency control: Ensures only one run per branch at a time, Equivalent to batch: true concurrency: diff --git a/.github/workflows/template_test.yml b/.github/workflows/template_test.yml index c54aeb5..e4acc8d 100644 --- a/.github/workflows/template_test.yml +++ b/.github/workflows/template_test.yml @@ -1,4 +1,4 @@ -name: Reusable Test Workflow +name: Reusable Integration Test Template on: workflow_call: diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml new file mode 100644 index 0000000..74f5107 --- /dev/null +++ b/.github/workflows/template_unit_pytest.yml @@ -0,0 +1,84 @@ +name: Reusable Unit Test with Pytest Template + +on: + workflow_call: + inputs: + projectName: + description: 'Name of the project' + required: true + type: string + workingDir: + description: 'Working directory for the component' + required: true + type: string + testsFolderName: + description: 'Tests folder name' + required: true + type: string + +jobs: + build_and_test: + name: Build and Test ${{ inputs.projectName }} + runs-on: ubuntu-latest + timeout-minutes: 120 + + # Define environment variables based on inputs, similar to Azure variables + env: + SRC_PATH: ${{ github.workspace }}/${{ inputs.workingDir }} + TESTS_PATH: ${{ github.workspace }}/${{ inputs.workingDir }}/${{ inputs.testsFolderName }} + TESTS_RESULTS_PATH: ${{ github.workspace }}/${{ inputs.workingDir }}/results.xml + TESTS_COVERAGE_REPORT_PATH: ${{ github.workspace }}/${{ inputs.workingDir }}/coverage.xml + # Use the working directory input for commands that need it + WORKING_DIR: ${{ inputs.workingDir }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 # Use latest stable version + with: + python-version: '3.11' + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install pipenv + + - name: Install environment including dev dependencies + working-directory: ${{ env.WORKING_DIR }} + run: | + echo "Current directory:" + pwd + echo "Listing files:" + ls -al + echo "Pipfile content:" + cat Pipfile + pipenv sync -d + + - name: Run tests with pytest + working-directory: ${{ env.WORKING_DIR }} + run: | + pipenv run pytest --version + # Use the environment variables defined above for paths + pipenv run pytest -v -s -o log_cli=true --junitxml=results.xml --cov=${{ env.SRC_PATH }} --cov-report=xml:${{ env.TESTS_COVERAGE_REPORT_PATH }} ${{ env.TESTS_PATH }} + echo "Listing results in working directory:" + ls -al ${{ github.workspace }}/${{ env.WORKING_DIR }} + + + # Use a popular action for publishing test results for better GitHub integration + - name: Publish Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() # always run even if tests fail + with: + name: ${{ inputs.projectName }} Test Results + path: ${{ env.TESTS_RESULTS_PATH }} + reporter: java-junit # Specify JUnit format + + # Upload coverage report as an artifact + - name: Upload coverage report artifact + uses: actions/upload-artifact@v4 + if: success() || failure() # always run + with: + name: ${{ inputs.projectName }}-coverage-report + path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} \ No newline at end of file diff --git a/.github/workflows/unittest_backend.yml b/.github/workflows/unittest_backend.yml new file mode 100644 index 0000000..bdccb7b --- /dev/null +++ b/.github/workflows/unittest_backend.yml @@ -0,0 +1,19 @@ +name: Unit Tests - Backend + +# Triggers: Equivalent to ADO trigger block +on: + pull_request: + branches: + - develop + + +jobs: + run_backend_tests: + name: Run Backend unit tests + uses: ./.github/workflows/template_unit_pytest.yml + # Pass parameters as inputs to the reusable workflow + with: + projectName: Backend # Value defined in original variables + workingDir: app/backend + testsFolderName: tests + # secrets: inherit # Inherit secrets from the parent workflow \ No newline at end of file diff --git a/app/frontend/vite.config.ts b/app/frontend/vite.config.ts index 915b45e..041bc3d 100644 --- a/app/frontend/vite.config.ts +++ b/app/frontend/vite.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ server: { host: true, strictPort: true, - port: 5173 + port: }, test: { globals: true, From bc71d74aeac9510547d6e2aac9eba1b9f88804e9 Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 10:28:28 +0800 Subject: [PATCH 04/21] included permission checks with write --- .github/workflows/build.yml | 1 + .github/workflows/unittest_backend.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d3ef0f7..0e5c9e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,7 @@ concurrency: jobs: # This job defines the matrix and calls the reusable workflow for each image build build: + needs: run_backend_tests name: Build ${{ matrix.image_config.IMAGE_NAME }} # Define necessary permissions if needed (e.g., for GitHub Packages) permissions: diff --git a/.github/workflows/unittest_backend.yml b/.github/workflows/unittest_backend.yml index bdccb7b..11a3e62 100644 --- a/.github/workflows/unittest_backend.yml +++ b/.github/workflows/unittest_backend.yml @@ -10,6 +10,8 @@ on: jobs: run_backend_tests: name: Run Backend unit tests + permissions: + checks: write uses: ./.github/workflows/template_unit_pytest.yml # Pass parameters as inputs to the reusable workflow with: From 565fc013fc3007a2fe5349f6491e1a01d950d1fc Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 10:33:03 +0800 Subject: [PATCH 05/21] include unit test in the workflow --- .github/workflows/build.yml | 17 +++++++++++++++-- .github/workflows/unittest_backend.yml | 21 --------------------- 2 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 .github/workflows/unittest_backend.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e5c9e1..e39d0a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build + CI +name: Unittest and Build + CI # Triggers: Equivalent to ADO trigger block on: @@ -12,9 +12,22 @@ concurrency: cancel-in-progress: true jobs: + run_backend_unittests: + name: Run Backend unit tests + permissions: + checks: write + # Call the reusable workflow for unit tests + uses: ./.github/workflows/template_unit_pytest.yml + # Pass parameters as inputs to the reusable workflow + with: + projectName: Backend # Value defined in original variables + workingDir: app/backend + testsFolderName: tests + # secrets: inherit # Inherit secrets from the parent workflow + # This job defines the matrix and calls the reusable workflow for each image build build: - needs: run_backend_tests + needs: run_backend_unittests name: Build ${{ matrix.image_config.IMAGE_NAME }} # Define necessary permissions if needed (e.g., for GitHub Packages) permissions: diff --git a/.github/workflows/unittest_backend.yml b/.github/workflows/unittest_backend.yml deleted file mode 100644 index 11a3e62..0000000 --- a/.github/workflows/unittest_backend.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Unit Tests - Backend - -# Triggers: Equivalent to ADO trigger block -on: - pull_request: - branches: - - develop - - -jobs: - run_backend_tests: - name: Run Backend unit tests - permissions: - checks: write - uses: ./.github/workflows/template_unit_pytest.yml - # Pass parameters as inputs to the reusable workflow - with: - projectName: Backend # Value defined in original variables - workingDir: app/backend - testsFolderName: tests - # secrets: inherit # Inherit secrets from the parent workflow \ No newline at end of file From 784a711554148d9a4e8059b5ae7fbf62b498cf8a Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 10:39:41 +0800 Subject: [PATCH 06/21] show the coverage table on action result --- .github/workflows/template_unit_pytest.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 74f5107..6980210 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -81,4 +81,9 @@ jobs: if: success() || failure() # always run with: name: ${{ inputs.projectName }}-coverage-report - path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} \ No newline at end of file + path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} + + - name: Report Coverage + uses: codecov/report@v2 + with: + files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} \ No newline at end of file From 0023e3f96c66ed9fafc32c987a424790a2a3ae3f Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 10:41:56 +0800 Subject: [PATCH 07/21] change report to latest --- .github/workflows/template_unit_pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 6980210..5549c5b 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -84,6 +84,6 @@ jobs: path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - name: Report Coverage - uses: codecov/report@v2 + uses: codecov/report@latest with: files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} \ No newline at end of file From e88ede52fdc93e84afd9f83d6d62735160f29e3e Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 10:43:51 +0800 Subject: [PATCH 08/21] change report format tool --- .github/workflows/template_unit_pytest.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 5549c5b..e620858 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -83,7 +83,10 @@ jobs: name: ${{ inputs.projectName }}-coverage-report path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - - name: Report Coverage - uses: codecov/report@latest + - name: Generate coverage report + uses: dawidd6/action-coverage-report@v1.6.0 with: - files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} \ No newline at end of file + path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} + output_format: markdown + github_token: ${{ github.token }} + minimum_coverage: 0 \ No newline at end of file From e39d7c31ee6da85263f474e6b39a139424aff897 Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 10:48:16 +0800 Subject: [PATCH 09/21] try codecov --- .github/workflows/template_unit_pytest.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index e620858..d5ad80a 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -83,10 +83,8 @@ jobs: name: ${{ inputs.projectName }}-coverage-report path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - - name: Generate coverage report - uses: dawidd6/action-coverage-report@v1.6.0 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 with: - path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - output_format: markdown - github_token: ${{ github.token }} - minimum_coverage: 0 \ No newline at end of file + files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} + fail_ci_if_error: true \ No newline at end of file From 2b343c9a0d24567fa93b411a98870d24b2810846 Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 11:25:37 +0800 Subject: [PATCH 10/21] update readme --- .github/workflows/template_test.yml | 7 ------- .github/workflows/template_unit_pytest.yml | 2 +- README.md | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/template_test.yml b/.github/workflows/template_test.yml index e4acc8d..b5646fe 100644 --- a/.github/workflows/template_test.yml +++ b/.github/workflows/template_test.yml @@ -238,13 +238,6 @@ jobs: report_paths: ${{ runner.temp }}/${{ inputs.testResultsFilename }} include_passed: true - - name: PublishCodeCoverageResults - uses: irongut/CodeCoverageSummary@v1.3.0 - with: - report_files: ${{ runner.temp }}/${{ inputs.testResultsFilename }} - github_token: ${{ secrets.GITHUB_TOKEN }} - minimum_coverage: 50 - - name: Docker Compose Down if: always() # Always run cleanup run: | diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index d5ad80a..8b37036 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -84,7 +84,7 @@ jobs: path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} fail_ci_if_error: true \ No newline at end of file diff --git a/README.md b/README.md index 7611cb0..89d48c8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build + CI](https://github.com/aimingmed/aimingmed-ai/actions/workflows/build.yml/badge.svg)](https://github.com/aimingmed/aimingmed-ai/actions/workflows/build.yml) +[![Unittest and Build + CI](https://github.com/aimingmed/aimingmed-ai/actions/workflows/build.yml/badge.svg)](https://github.com/aimingmed/aimingmed-ai/actions/workflows/build.yml) ## Important note: From 0ba26d35f1a2b475f94a1e4c20675cf483f924d4 Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 11:47:45 +0800 Subject: [PATCH 11/21] update with token --- .github/workflows/build.yml | 1 + .github/workflows/template_unit_pytest.yml | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e39d0a3..57618ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ jobs: name: Run Backend unit tests permissions: checks: write + secrets: inherit # Inherit secrets from the parent workflow # Call the reusable workflow for unit tests uses: ./.github/workflows/template_unit_pytest.yml # Pass parameters as inputs to the reusable workflow diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 8b37036..3976008 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -87,4 +87,10 @@ jobs: uses: codecov/codecov-action@v5 with: files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - fail_ci_if_error: true \ No newline at end of file + fail_ci_if_error: true + flags: unittests + name: codecov-coverage + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + From bb5c7505f1583f89b5db8604100655bfc745e75c Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 12:07:12 +0800 Subject: [PATCH 12/21] revert to v3 --- .github/workflows/template_unit_pytest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 3976008..5bf3912 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -84,13 +84,13 @@ jobs: path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 + + uses: codecov/codecov-action@v3 with: files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} fail_ci_if_error: true flags: unittests name: codecov-coverage verbose: true - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + From f65b9befc4a3a6197ef8172ff0e1bbcee5937c85 Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 12:24:53 +0800 Subject: [PATCH 13/21] verbose = false --- .github/workflows/template_unit_pytest.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 5bf3912..a83d2a6 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -91,6 +91,4 @@ jobs: fail_ci_if_error: true flags: unittests name: codecov-coverage - verbose: true - From 8cec43fe4df57d01f98301a2f4103f96a42f3a8b Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 12:27:09 +0800 Subject: [PATCH 14/21] include token --- .github/workflows/template_unit_pytest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index a83d2a6..2bf8b06 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -91,4 +91,5 @@ jobs: fail_ci_if_error: true flags: unittests name: codecov-coverage + token: ${{ secrets.CODECOV_TOKEN }} # Set this secret in your repository settings From 6c6ffb3a69b74eb0e80b2a3aacbd8e77d5b83ad1 Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 12:38:25 +0800 Subject: [PATCH 15/21] v4 --- .github/workflows/template_unit_pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 2bf8b06..a2e8c05 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -85,7 +85,7 @@ jobs: - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} fail_ci_if_error: true From f45d3262d5ea9585461c5d6c793f06674a6958cb Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 12:50:48 +0800 Subject: [PATCH 16/21] try new solution --- .github/workflows/template_unit_pytest.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index a2e8c05..1ddf58d 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -83,13 +83,10 @@ jobs: name: ${{ inputs.projectName }}-coverage-report path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - - name: Upload coverage to Codecov - - uses: codecov/codecov-action@v4 + - name: Report Coverage + uses: dawidd6/action-coverage-report@v1.6.0 with: - files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - fail_ci_if_error: true - flags: unittests - name: codecov-coverage - token: ${{ secrets.CODECOV_TOKEN }} # Set this secret in your repository settings - + path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} + output_format: markdown + github_token: ${{ github.token }} + minimum_coverage: 0 From 5bb3d63adc3f55d0a36a3c8d8c26eb4b669a8dd4 Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 12:53:09 +0800 Subject: [PATCH 17/21] try --- .github/workflows/template_unit_pytest.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 1ddf58d..b23aacc 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -56,12 +56,12 @@ jobs: cat Pipfile pipenv sync -d - - name: Run tests with pytest + - name: Run tests with pytest and generate coverage report working-directory: ${{ env.WORKING_DIR }} run: | pipenv run pytest --version # Use the environment variables defined above for paths - pipenv run pytest -v -s -o log_cli=true --junitxml=results.xml --cov=${{ env.SRC_PATH }} --cov-report=xml:${{ env.TESTS_COVERAGE_REPORT_PATH }} ${{ env.TESTS_PATH }} + pipenv run pytest -v -s -o log_cli=true --junitxml=results.xml --cov=${{ env.SRC_PATH }} --cov-report term ${{ env.TESTS_PATH }} echo "Listing results in working directory:" ls -al ${{ github.workspace }}/${{ env.WORKING_DIR }} @@ -82,11 +82,3 @@ jobs: with: name: ${{ inputs.projectName }}-coverage-report path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - - - name: Report Coverage - uses: dawidd6/action-coverage-report@v1.6.0 - with: - path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - output_format: markdown - github_token: ${{ github.token }} - minimum_coverage: 0 From 3fa7ffe951a2ff392aa80b21afe3627170f70cba Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 13:01:00 +0800 Subject: [PATCH 18/21] use codecov again --- .github/workflows/template_unit_pytest.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index b23aacc..4cdabca 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -56,12 +56,12 @@ jobs: cat Pipfile pipenv sync -d - - name: Run tests with pytest and generate coverage report + - name: Run tests with pytest working-directory: ${{ env.WORKING_DIR }} run: | pipenv run pytest --version # Use the environment variables defined above for paths - pipenv run pytest -v -s -o log_cli=true --junitxml=results.xml --cov=${{ env.SRC_PATH }} --cov-report term ${{ env.TESTS_PATH }} + pipenv run pytest -v -s -o log_cli=true --junitxml=results.xml --cov=${{ env.SRC_PATH }} --cov-report=xml:${{ env.TESTS_COVERAGE_REPORT_PATH }} ${{ env.TESTS_PATH }} echo "Listing results in working directory:" ls -al ${{ github.workspace }}/${{ env.WORKING_DIR }} @@ -82,3 +82,12 @@ jobs: with: name: ${{ inputs.projectName }}-coverage-report path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} + + - name: Upload coverage to Codecov + if: success() || failure() # always run + uses: codecov/codecov-action@v3 + with: + files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} + fail_ci_if_error: true + + From cb76fb5bdc62a25e6af9639662728f2db779ec7a Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 13:49:01 +0800 Subject: [PATCH 19/21] token included --- .github/workflows/template_unit_pytest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index 4cdabca..c4f0be0 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -89,5 +89,6 @@ jobs: with: files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} From 52e01359ccad777b24fc20ae0e1e8f506626b34e Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 14:05:15 +0800 Subject: [PATCH 20/21] use codecov v2 --- .github/workflows/template_unit_pytest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index c4f0be0..e5dbc1b 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -84,11 +84,11 @@ jobs: path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - name: Upload coverage to Codecov - if: success() || failure() # always run - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v2 with: + token: ${{ secrets.CODECOV_TOKEN }} + version: "v0.1.15" files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} From 5ef89072c294accf076b3fb41f1a6d09e6c2faec Mon Sep 17 00:00:00 2001 From: leehk Date: Mon, 21 Apr 2025 14:22:07 +0800 Subject: [PATCH 21/21] v5 --- .github/workflows/template_unit_pytest.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/template_unit_pytest.yml b/.github/workflows/template_unit_pytest.yml index e5dbc1b..81344d1 100644 --- a/.github/workflows/template_unit_pytest.yml +++ b/.github/workflows/template_unit_pytest.yml @@ -84,10 +84,9 @@ jobs: path: ${{ env.TESTS_COVERAGE_REPORT_PATH }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} - version: "v0.1.15" files: ${{ env.TESTS_COVERAGE_REPORT_PATH }} fail_ci_if_error: true