-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (55 loc) · 2.3 KB
/
collect-coverage.yml
File metadata and controls
58 lines (55 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Collect coverage
permissions:
pull-requests: read
contents: read
on:
workflow_call:
jobs:
collect-coverage:
# description: |
# Gather, merge then uploads test coverage files from all test jobs (this includes integration tests,
# like codegen-test). This reduces the number of failures due to codecov hitting github API rate limit.
name: collect test coverage
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
-
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: stable
check-latest: true
cache: true
-
name: Download coverage artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
run-id: "${{ github.run_id }}"
pattern: "*.coverage.*"
# artifacts resolve as folders
path: coverage/
-
name: Reprocess coverage paths
# on projects with a v2 suffix, the go import path reported by coverage doesn't match
# well the actual path. codecov knows about that for the root module, but is unable
# to find its way with versioned go sub-modules.
# We rewrite paths in coverage paths to match actual repo folders.
run: |
go list -m -f '{"name":{{ printf "%q" .Path }},"path":{{ printf "%q" .Dir }}}'|\
jq -r '[.name,.path] | @tsv' |\
while IFS=$'\t' read -r name path ; do
target="github.com/${GITHUB_REPOSITORY}/${path#${GITHUB_WORKSPACE}/}"
sed -i "s|${name}|${target}|" $(find coverage -type f -name \*.coverage.\*.out)
done
-
name: Upload coverage to codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
name: Aggregated coverage
# All *.coverage.*.out files uploaded should be detected by the codecov action.
# NOTE: we lose the flags on individual test reports (e.g. by os, by go version, unit vs integration tests)
fail_ci_if_error: false
verbose: false