From c57a058224952edace2fbbd915d03343e6e3092b Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Thu, 4 Apr 2024 15:25:52 +0200 Subject: [PATCH 1/3] Try to implement coverage action instead of using codecov. See #1753 --- .github/workflows/coverage.yml | 23 +++++++++++++++++++ .github/workflows/tests.yml | 41 +++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..1dd824c78 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,23 @@ +name: Post coverage comment + +on: + workflow_run: + workflows: ["continuous-integration"] + types: + - completed + +jobs: + test: + name: Run tests & display coverage + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + permissions: + pull-requests: write + contents: write + actions: read + steps: + - name: Post comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6a7ca6164..66170aa17 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,7 +44,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11"] sphinx-version: [""] include: # macos test @@ -92,6 +92,13 @@ jobs: nox -s compile - name: Run tests run: pytest -m "not a11y" --color=yes --cov --cov-report=xml + env: + COVERAGE_FILE: ".coverage.${{ matrix.python-version }}.${{ matrix.os }}.${{ matrix.sphinx-version }}" + - name: Store coverage file + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.sphinx-version }} + path: .coverage.${{ matrix.python-version }}.${{ matrix.os }}.${{ matrix.sphinx-version }} - name: Upload to Codecov if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev' uses: codecov/codecov-action@v4 @@ -117,6 +124,38 @@ jobs: nox -s a11y continue-on-error: true + coverage: + name: Collect Coverage + runs-on: ubuntu-latest + needs: run-pytest + # run both on previous step success and failure + if: "!cancelled()" + permissions: + pull-requests: write + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + id: download + with: + pattern: coverage-* + merge-multiple: true + + - name: Coverage comment + id: coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MERGE_COVERAGE_FILES: true + + - name: Store Pull Request comment to be posted + uses: actions/upload-artifact@v4 + if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' + with: + name: python-coverage-comment-action + path: python-coverage-comment-action.txt + # Build our site on the 3 major OSes and check for Sphinx warnings build-site: needs: [lint] diff --git a/pyproject.toml b/pyproject.toml index 8d674125d..10eaaa5e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,6 +119,7 @@ markers = "a11y: mark a test as an accessibility test" [tool.coverage.run] source = ["pydata_sphinx_theme"] branch = true +relative_files = true [tool.coverage.report] fail_under = 60 From 427e7b0cb1f062fe9b550ab17ce95a8c2587c0ea Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Fri, 5 Apr 2024 02:47:27 -0700 Subject: [PATCH 2/3] Update .github/workflows/tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 66170aa17..198fd3908 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,7 +44,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] sphinx-version: [""] include: # macos test From 95057dfc38e0eaefda89a5016cd4fd8261eabfe9 Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Tue, 7 May 2024 15:30:00 -0500 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Tania Allard --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1dd824c78..ecda6620a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,7 +13,7 @@ jobs: if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' permissions: pull-requests: write - contents: write + contents: write # needed to edit the comment vs opening multiple ones actions: read steps: - name: Post comment