From c1463a5bbed7de4865c5a2967d02c81dccbf9036 Mon Sep 17 00:00:00 2001 From: Aman Pandey Date: Tue, 7 May 2024 18:55:19 +0530 Subject: [PATCH] New coverage.yml for code coverage (#1912) * new coverage.yml * match the job name * remove upload code coverage config --- .github/workflows/coverage.yml | 33 +++++++++++++++++++++++ .github/workflows/test.yml | 49 ---------------------------------- 2 files changed, 33 insertions(+), 49 deletions(-) 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..a0722f0ac --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,33 @@ +# .github/workflows/coverage.yml +name: Post coverage comment + +on: + workflow_run: + workflows: ["Test"] + 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: + # Gives the action the necessary permissions for publishing new + # comments in pull requests. + pull-requests: write + # Gives the action the necessary permissions for editing existing + # comments (to avoid publishing multiple comments in the same PR) + contents: write + # Gives the action the necessary permissions for looking up the + # workflow that launched this workflow, and download the related + # artifact that contains the comment to be published + actions: read + steps: + # DO NOT run actions/checkout here, for security reasons + # For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ + - 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/test.yml b/.github/workflows/test.yml index 72b40d010..cd5d8dd8b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,11 +66,6 @@ jobs: DB_HOST: 127.0.0.1 DB_PORT: 3306 - - name: Upload coverage data - uses: actions/upload-artifact@v4 - with: - name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-mysql - path: ".coverage.*" postgres: runs-on: ubuntu-latest @@ -144,12 +139,6 @@ jobs: DB_HOST: localhost DB_PORT: 5432 - - name: Upload coverage data - uses: actions/upload-artifact@v4 - with: - name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.database }} - path: ".coverage.*" - sqlite: runs-on: ubuntu-latest strategy: @@ -192,44 +181,6 @@ jobs: DB_BACKEND: sqlite3 DB_NAME: ":memory:" - - name: Upload coverage data - uses: actions/upload-artifact@v4 - with: - name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-sqlite - path: ".coverage.*" - - coverage: - name: Check coverage. - runs-on: "ubuntu-latest" - needs: [sqlite, mysql, postgres] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - # Use latest, so it understands all syntax. - python-version: "3.11" - - - run: python -m pip install --upgrade coverage[toml] - - - name: Download coverage data. - uses: actions/download-artifact@v4 - with: - pattern: coverage-data-* - merge-multiple: true - - - name: Combine coverage & check percentage - run: | - python -m coverage combine - python -m coverage html - python -m coverage report - - - name: Upload HTML report if check failed. - uses: actions/upload-artifact@v4 - with: - name: html-report - path: htmlcov - if: ${{ failure() }} - lint: runs-on: ubuntu-latest strategy: