Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split codecov uploading into separate repo #3084

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 57 additions & 63 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: test
name: Test
on:
push:
branches:
Expand All @@ -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
Expand All @@ -66,16 +66,13 @@ jobs:
- '5.36'
resolver:
- snapshot
- metacpan
# - metacpan
container:
image: perl:${{ matrix.perl-version }}
env:
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'
Expand All @@ -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
Expand All @@ -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
64 changes: 64 additions & 0 deletions .github/workflows/upload-coverage.yml
Original file line number Diff line number Diff line change
@@ -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: ${{ }}