From dfec6ad0e35ed07f5c37f0b3ad2650bd2224fa76 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Fri, 15 Mar 2024 10:05:17 +0800 Subject: [PATCH 1/4] ci: Re-enable Coverage Coverage only worked on branches within the project, due to restrictions around pull_request permissions. It is unsafe to allow pull_request_target when using checked out code, thus splitting the workflow is required. Currently pointed at my fork, which adds the necessary functionality to support workflow_run. --- .github/workflows/coverage-build.yml | 33 ++++++++++++++++++++++++++ .github/workflows/coverage-report.yml | 28 ++++++++++++++++++++++ .github/workflows/coverage.yml | 34 --------------------------- 3 files changed, 61 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..f568e1f --- /dev/null +++ b/.github/workflows/coverage-build.yml @@ -0,0 +1,33 @@ +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" + - 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 }} From 4b53afda77b78137132663b2cb6373df6921c2b2 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Fri, 15 Mar 2024 10:08:33 +0800 Subject: [PATCH 2/4] ci: Bump actions/setup-python v1 is quite old, bumping to v5 --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 30f3b72..d45c268 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -63,7 +63,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: 3.11 - name: Install Dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 122d6ed..3a3cd76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: 3.11 - name: Install test dependencies From 2073eaab917a15a7fd8c63665ce1bdd453828ae6 Mon Sep 17 00:00:00 2001 From: Leon Wright Date: Fri, 15 Mar 2024 10:09:22 +0800 Subject: [PATCH 3/4] ci: Add caching Newer versions of setup python include caching, which improves the speed of test/build/coverage reporting --- .github/workflows/coverage-build.yml | 2 ++ .github/workflows/deploy.yml | 2 ++ .github/workflows/test.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/coverage-build.yml b/.github/workflows/coverage-build.yml index f568e1f..8073b2f 100644 --- a/.github/workflows/coverage-build.yml +++ b/.github/workflows/coverage-build.yml @@ -17,6 +17,8 @@ jobs: 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 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d45c268..ce3ea24 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -66,6 +66,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.11 + cache: pip + cache-dependency-path: netkan/setup.py - name: Install Dependencies run: | pip install netkan/. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a3cd76..e5c9f45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.11 + cache: pip + cache-dependency-path: netkan/setup.py - name: Install test dependencies working-directory: netkan run: pip install .[test] From b6f58a62d8bc9f7c63a0482e904d3215a0b0e373 Mon Sep 17 00:00:00 2001 From: HebaruSan Date: Sat, 23 Mar 2024 09:56:09 -0500 Subject: [PATCH 4/4] YAMLize --- .github/workflows/coverage-report.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage-report.yml b/.github/workflows/coverage-report.yml index aed4389..6dc7791 100644 --- a/.github/workflows/coverage-report.yml +++ b/.github/workflows/coverage-report.yml @@ -2,7 +2,8 @@ name: Report Coverage on: workflow_run: - workflows: ["Build Coverage"] + workflows: + - Build Coverage types: - completed