From 5d8ed3d1aa424ca160dff260e315c3101f3a9c49 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Wed, 13 Mar 2024 10:36:14 +0800 Subject: [PATCH] ci: Re-enable Coverage 'contents' appears to be required for the coverage action. I've enabled this on a couple of other repos and this appears to work. --- .github/workflows/coverage-build.yml | 35 +++++++++++++++++++++++++++ .github/workflows/coverage-report.yml | 28 +++++++++++++++++++++ .github/workflows/coverage.yml | 34 -------------------------- 3 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/coverage-build.yml create mode 100644 .github/workflows/coverage-report.yml delete mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage-build.yml b/.github/workflows/coverage-build.yml new file mode 100644 index 0000000..8073b2f --- /dev/null +++ b/.github/workflows/coverage-build.yml @@ -0,0 +1,35 @@ +name: Build Coverage + +on: + pull_request: + branches: + - master + +jobs: + coverage-build: + runs-on: ubuntu-latest + defaults: + run: + working-directory: netkan + steps: + - uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + cache: pip + cache-dependency-path: netkan/setup.py + - name: Install test dependencies + run: pip install .[test] + - name: force our git config + run: cp .gitconfig ~/. + - name: Run Coverage + run: | + coverage run -m pytest + coverage xml + - name: Upload Coverage + uses: actions/upload-artifact@v4 + with: + name: coverage.xml + path: netkan/coverage.xml + retention-days: 1 diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml new file mode 100644 index 0000000..aed4389 --- /dev/null +++ b/.github/workflows/coverage-report.yml @@ -0,0 +1,28 @@ +name: Report Coverage + +on: + workflow_run: + workflows: ["Build Coverage"] + types: + - completed + +permissions: + actions: read + contents: read + pull-requests: write + +jobs: + coverage-report: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/download-artifact@v4 + with: + name: coverage.xml + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Get Cover + uses: techman83/coverage@feat/workflow_run + with: + coverageFile: coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index f6dd7dd..0000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Coverage - -on: - - pull_request - -permissions: - pull-requests: write - -jobs: - coverage: - if: false - runs-on: ubuntu-latest - defaults: - run: - working-directory: netkan - steps: - - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: 3.11 - - name: Install test dependencies - run: pip install .[test] - - name: force our git config - run: cp .gitconfig ~/. - - name: Run Coverage - run: coverage run -m pytest - - name: Generate report - run: coverage xml - - name: Get Cover - uses: orgoro/coverage@v3 - with: - coverageFile: netkan/coverage.xml - token: ${{ secrets.GITHUB_TOKEN }}