From ec71d95b2ab2f1d490c07649b7c2da81326f89c8 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 20 May 2024 21:22:27 +0200 Subject: [PATCH 1/3] split codecov uploading into separate repo Some PRs run with lowered permissions that don't have access to secrets. This is generally good, but means they don't have a token to upload to Codecov. Split out the uploading to a separate workflow that is triggered by the completion of the test workflow. --- .github/workflows/test.yml | 26 +++++------ .github/workflows/upload-coverage.yml | 64 +++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/upload-coverage.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3708a617ef..d56ccde8c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ --- -name: test +name: Test on: push: branches: @@ -73,9 +73,6 @@ jobs: DEVEL_COVER_OPTIONS: '-ignore,^local/' steps: - uses: actions/checkout@v4 - if: matrix.resolver == 'snapshot' - - uses: actions/checkout@v4 - if: matrix.resolver != 'snapshot' - uses: actions/setup-node@v4 with: node-version: '22' @@ -95,11 +92,6 @@ jobs: --resolver ${{ matrix.resolver }} - name: Build assets run: npm run build - - name: Run tests without coverage - if: matrix.resolver != 'snapshot' - run: carton exec prove -lr --jobs 2 t - env: - TEST_TIDYALL_VERBOSE: 1 - name: Install Codecovbash if: matrix.resolver == 'snapshot' uses: perl-actions/install-with-cpm@v1 @@ -108,17 +100,19 @@ jobs: Devel::Cover Devel::Cover::Report::Codecovbash sudo: false - - name: Run tests with coverage + - name: Configure Code Coverage + id: coverage if: matrix.resolver == 'snapshot' + run: > + echo "switches=-MDevel::Cover=+ignore,^t/" >> "$GITHUB_OUTPUT" + - name: Run tests run: carton exec prove -lr --jobs 2 t env: - HARNESS_PERL_SWITCHES: -MDevel::Cover=+ignore,^t/ + HARNESS_PERL_SWITCHES: $${ steps.coverage.outputs.switches }} - name: Generate Codecov report if: matrix.resolver == 'snapshot' run: cover -report codecovbash - - uses: codecov/codecov-action@v4 - if: matrix.resolver == 'snapshot' + - uses: actions/upload-artifact@v4 with: - fail_ci_if_error: true - file: ./cover_db/codecov.json - token: ${{ secrets.CODECOV_TOKEN }} + name: codecov.json + path: ./cover_db/codecov.json diff --git a/.github/workflows/upload-coverage.yml b/.github/workflows/upload-coverage.yml new file mode 100644 index 0000000000..abc8f2331a --- /dev/null +++ b/.github/workflows/upload-coverage.yml @@ -0,0 +1,64 @@ +name: Upload Coverage Report + +on: + workflow_run: + workflows: ["Test"] + types: + - completed + +jobs: + upload: + name: Upload + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + steps: + - uses: actions/download-artifact@v4 + with: + pattern: codecov.json + id: ${{ github.event.workflow_run.id }} + - uses: actions/checkout@v4 + name: Checkout codecov.yml + with: + path: repo + sparse-checkout: | + codecov.yml + sparse-checkout-cone-mode: false + - uses: actions/github-script@v7 + name: Find associated pull request + id: pr + with: + script: | + const response = await github.rest.search.issuesAndPullRequests({ + q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}', + per_page: 1, + }) + const items = response.data.items + if (items.length < 1) { + console.error('No PRs found') + return + } + const pullRequest = items[0] + console.info("Pull request number is", pullRequest.number) + return pullRequest + - name: + env: + PR_DATA: ${{ steps.id.outputs.result }} + EVENT_DATA: ${{ toJson(github.event) }} + run: 'printf "pr:\n%s\nevent:\n%s\n" "$PR_DATA" "$EVENT_DATA"' +# - uses: codecov/codecov-action@v4 +# if: hashFiles('codecov.json') +# with: +# codecov_yml_path: repo/codecov.yml +# disable_search: true +# file: codecov.json +# token: ${{ secrets.CODECOV_TOKEN }} +# commit_parent: ${{ }} +# job_code: ${{ github.event.workflow.name }} +# os: ${{ }} +# override_branch: ${{ }} +# override_build: ${{ }} +# override_build_url: ${{ }} +# override_commit: ${{ }} +# override_pr: ${{ }} From e942d0a6be038ac74680e67d20fad508331bdaa9 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 20 May 2024 21:29:50 +0200 Subject: [PATCH 2/3] remove some tests for now --- .github/workflows/test.yml | 94 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d56ccde8c3..a20335dd97 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,52 +10,52 @@ on: workflow_dispatch: jobs: - code-formatting: - runs-on: ubuntu-22.04 - name: Code Formatting - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Fetch base ref - if: ${{ github.event.pull_request }} - run: git fetch origin ${{ github.base_ref }}:upstream - - run: npm install - - name: Install Carton - uses: perl-actions/install-with-cpm@v1 - with: - install: Carton - - name: Install CPAN deps - uses: perl-actions/install-with-cpm@v1 - with: - cpanfile: 'cpanfile' - args: > - --resolver=snapshot - --without-runtime - --without-test - --without-build - --with-develop - - name: Install precious - run: ./bin/install-precious /usr/local/bin - - name: Lint modified files - if: ${{ github.event.pull_request }} - run: precious lint --git-diff-from upstream - - name: Lint all files - if: ${{ ! github.event.pull_request }} - run: precious lint --all - docker: - runs-on: ubuntu-22.04 - name: Docker - steps: - - name: Build test image - id: docker-build-test - uses: docker/build-push-action@v5 - with: - target: test - push: false - load: true - - name: Run Perl tests - run: docker run -i ${{ steps.docker-build-test.outputs.imageid }} +# code-formatting: +# runs-on: ubuntu-22.04 +# name: Code Formatting +# steps: +# - uses: actions/checkout@v4 +# with: +# fetch-depth: 0 +# - name: Fetch base ref +# if: ${{ github.event.pull_request }} +# run: git fetch origin ${{ github.base_ref }}:upstream +# - run: npm install +# - name: Install Carton +# uses: perl-actions/install-with-cpm@v1 +# with: +# install: Carton +# - name: Install CPAN deps +# uses: perl-actions/install-with-cpm@v1 +# with: +# cpanfile: 'cpanfile' +# args: > +# --resolver=snapshot +# --without-runtime +# --without-test +# --without-build +# --with-develop +# - name: Install precious +# run: ./bin/install-precious /usr/local/bin +# - name: Lint modified files +# if: ${{ github.event.pull_request }} +# run: precious lint --git-diff-from upstream +# - name: Lint all files +# if: ${{ ! github.event.pull_request }} +# run: precious lint --all +# docker: +# runs-on: ubuntu-22.04 +# name: Docker +# steps: +# - name: Build test image +# id: docker-build-test +# uses: docker/build-push-action@v5 +# with: +# target: test +# push: false +# load: true +# - name: Run Perl tests +# run: docker run -i ${{ steps.docker-build-test.outputs.imageid }} test: runs-on: ubuntu-20.04 name: Dockerless @@ -66,7 +66,7 @@ jobs: - '5.36' resolver: - snapshot - - metacpan +# - metacpan container: image: perl:${{ matrix.perl-version }} env: From ef9d46853c53c3e1d1acbc5dd7b95191971cc6a7 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 20 May 2024 21:30:05 +0200 Subject: [PATCH 3/3] fix workflow syntax --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a20335dd97..7229248312 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -108,7 +108,7 @@ jobs: - name: Run tests run: carton exec prove -lr --jobs 2 t env: - HARNESS_PERL_SWITCHES: $${ steps.coverage.outputs.switches }} + HARNESS_PERL_SWITCHES: ${{ steps.coverage.outputs.switches }} - name: Generate Codecov report if: matrix.resolver == 'snapshot' run: cover -report codecovbash