Skip to content

Codecov coverage report upload for PRs from external forks #14363

Codecov coverage report upload for PRs from external forks

Codecov coverage report upload for PRs from external forks #14363

name: Codecov coverage report upload for PRs from external forks
on:
workflow_run:
workflows: [main, sdk-testing]
types:
- completed
# Workflow-level permissions are denied by default; each job below declares
# the minimum scopes it needs (least privilege).
permissions: {}
jobs:
get-commit-tag:
if: github.event.workflow_run.head_repository.fork == true
runs-on: gha-lfdt-lineth-ss-ubuntu-24-amd64-small
name: get-commit-tag
permissions: {}
outputs:
commit-tag: ${{ steps.compute-commit-tag.outputs.COMMIT_TAG }}
sdk-commit-tag: ${{ steps.compute-commit-tag.outputs.SDK_COMMIT_TAG }}
steps:
- name: Compute commit tag
shell: bash
id: compute-commit-tag
env:
TRIGGERING_WORKFLOW: ${{ github.event.workflow_run.name }}
WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
WORKFLOW_RUN_PR_HEAD_SHA: ${{ github.event.workflow_run.pull_requests[0].head.sha || '' }}
# COMMIT_TAG is derived from workflow_run.head_sha and used by workflows that upload artifacts using the shared commit_tag.
# SDK_COMMIT_TAG is derived from the PR head SHA for sdk-testing PR runs to match sdk-testing.yml's cov-tag step.
# We use bash substring (${VAR:0:7}) instead of `git rev-parse --short=7` to avoid checking out fork code in this privileged workflow_run context.
run: |
COMMIT_TAG="${WORKFLOW_RUN_HEAD_SHA:0:7}"
SDK_COMMIT_TAG="$COMMIT_TAG"
if [[ "$TRIGGERING_WORKFLOW" == "sdk-testing" ]] && [[ -n "$WORKFLOW_RUN_PR_HEAD_SHA" ]]; then
SDK_COMMIT_TAG="${WORKFLOW_RUN_PR_HEAD_SHA:0:7}"
fi
echo "COMMIT_TAG=$COMMIT_TAG" >> "$GITHUB_OUTPUT"
echo "SDK_COMMIT_TAG=$SDK_COMMIT_TAG" >> "$GITHUB_OUTPUT"
- name: Show commit tag
env:
COMMIT_TAG: ${{ steps.compute-commit-tag.outputs.COMMIT_TAG }}
SDK_COMMIT_TAG: ${{ steps.compute-commit-tag.outputs.SDK_COMMIT_TAG }}
run: |
echo "COMMIT_TAG: $COMMIT_TAG"
echo "SDK_COMMIT_TAG: $SDK_COMMIT_TAG"
# Ideally we would use dorny/paths-filter@v3 to conditionally trigger an upload job based on file changes
# However there is a limitation in Github Actions where workflows triggered by a `workflow_run` event have no access to metadata on external fork PRs - https://github.com/orgs/community/discussions/25220
# Hence we are unable to find the base commit (the common ancestor commit between the PR branch and main branch) without using very clunky workarounds
# Hence we cannot provide the correct set of 'before' and 'after' commits for dorny/paths-filter@v3 to accurately assess PR file changes
# So instead we unconditionally use 'continue-on-error: true' and try to download every possible test coverage report that we want to upload to Codecov
upload-codecov-coordinator:
needs: [ get-commit-tag ]
runs-on: gha-lfdt-lineth-ss-ubuntu-24-amd64-small
name: upload-codecov-coordinator
permissions:
actions: read # download artifacts from another workflow run
contents: read # codecov commit correlation
steps:
- name: Download Jacoco test coverage report (from coordinator-testing.yml)
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
id: coordinator-report-download
with:
name: jacocoRootReport-${{ needs.get-commit-tag.outputs.commit-tag }}.xml
path: |
${{ github.workspace }}/ci-coordinator-coverage
# Required to download artifacts from another workflow run
github-token: ${{ secrets.GITHUB_TOKEN }}
# Gets run id of the precedeing workflow that triggered this workflow_run
run-id: ${{ github.event.workflow_run.id }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.coordinator-report-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-coordinator-coverage/**/jacocoRootReport.xml
flags: kotlin
os: linux
name: codecov-coordinator
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
upload-codecov-smart-contracts:
needs: [ get-commit-tag ]
runs-on: gha-lfdt-lineth-ss-ubuntu-24-amd64-small
name: upload-codecov-smart-contracts
permissions:
actions: read # download artifacts from another workflow run
contents: read # codecov commit correlation
steps:
- name: Download smart contract coverage report (from run-smc.tests.yml)
id: smc-report-download
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: smart-contract-coverage-${{ needs.get-commit-tag.outputs.commit-tag }}.json
path: |
${{ github.workspace }}/ci-smart-contract-coverage
# Required to download artifacts from another workflow run
github-token: ${{ secrets.GITHUB_TOKEN }}
# Gets run id of the precedeing workflow that triggered this workflow_run
run-id: ${{ github.event.workflow_run.id }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.smc-report-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-smart-contract-coverage/**/coverage-final.json
flags: hardhat
os: linux
name: codecov-contracts
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
upload-codecov-ts:
needs: [ get-commit-tag ]
runs-on: gha-lfdt-lineth-ss-ubuntu-24-amd64-small
name: upload-codecov-ts
permissions:
actions: read # download artifacts from another workflow run
contents: read # codecov commit correlation
steps:
- name: Download TS test coverage reports (from postman-testing.yml)
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
id: ts-coverage-download
with:
name: ts-coverage-${{ needs.get-commit-tag.outputs.commit-tag }}
path: |
${{ github.workspace }}/ci-ts-coverage
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.ts-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-ts-coverage/**/native-libs-lcov.info
flags: linea-native-libs
os: linux
name: codecov-linea-native-libs-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.ts-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-ts-coverage/**/postman-lcov.info
flags: postman
os: linux
name: codecov-postman
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.ts-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-ts-coverage/**/sdk-viem-lcov.info
flags: sdk-viem
os: linux
name: codecov-sdk-viem
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
upload-codecov-native-yield-ts:
needs: [ get-commit-tag ]
runs-on: gha-lfdt-lineth-ss-ubuntu-24-amd64-small
name: upload-codecov-native-yield-ts
permissions:
actions: read # download artifacts from another workflow run
contents: read # codecov commit correlation
steps:
- name: Download TS coverage (from native-yield-automation-service-testing.yml)
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
id: native-yield-coverage-download
with:
name: native-yield-ts-coverage-${{ needs.get-commit-tag.outputs.commit-tag }}
path: |
${{ github.workspace }}/ci-native-yield-coverage
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.native-yield-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-native-yield-coverage/**/shared-utils-lcov.info
flags: linea-shared-utils
os: linux
name: codecov-linea-shared-utils-native-yield-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.native-yield-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-native-yield-coverage/**/automation-service-lcov.info
flags: native-yield-automation-service
os: linux
name: codecov-native-yield-automation-service-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
upload-codecov-lido-ts:
needs: [ get-commit-tag ]
runs-on: gha-lfdt-lineth-ss-ubuntu-24-amd64-small
name: upload-codecov-lido-ts
permissions:
actions: read # download artifacts from another workflow run
contents: read # codecov commit correlation
steps:
- name: Download TS coverage (from lido-governance-monitor-testing.yml)
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
id: lido-coverage-download
with:
name: lido-ts-coverage-${{ needs.get-commit-tag.outputs.commit-tag }}
path: |
${{ github.workspace }}/ci-lido-coverage
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.lido-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-lido-coverage/**/shared-utils-lcov.info
flags: linea-shared-utils
os: linux
name: codecov-linea-shared-utils-lido-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.lido-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-lido-coverage/**/lido-governance-monitor-lcov.info
flags: lido-governance-monitor
os: linux
name: codecov-lido-governance-monitor-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
upload-codecov-sdk-ts:
needs: [ get-commit-tag ]
runs-on: gha-lfdt-lineth-ss-ubuntu-24-amd64-small
name: upload-codecov-sdk-ts
permissions:
actions: read # download artifacts from another workflow run
contents: read # codecov commit correlation
steps:
- name: Download TS coverage (from sdk-testing.yml)
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
id: sdk-coverage-download
with:
name: sdk-ts-coverage-${{ needs.get-commit-tag.outputs.sdk-commit-tag }}
path: |
${{ github.workspace }}/ci-sdk-coverage
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.sdk-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-sdk-coverage/**/sdk-core-lcov.info
flags: sdk-core
os: linux
name: codecov-sdk-core-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.sdk-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-sdk-coverage/**/sdk-viem-lcov.info
flags: sdk-viem
os: linux
name: codecov-sdk-viem-sdk-testing-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0
if: ${{ steps.sdk-coverage-download.outcome == 'success' }}
with:
fail_ci_if_error: true
files: ${{ github.workspace }}/ci-sdk-coverage/**/sdk-ethers-lcov.info
flags: sdk-ethers
os: linux
name: codecov-sdk-ethers-fork
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}