Repository navigation
79 lines (67 loc) · 2.46 KB
/
Copy pathgo-coverage.yml
File metadata and controls
79 lines (67 loc) · 2.46 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Go coverage
permissions:
contents: read
on:
pull_request:
branches:
- "main"
push:
branches:
- "main"
# run at least once every 2 months to prevent the coverage artifact from expiring
schedule:
- cron: '14 3 5 */2 *'
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
go-coverage:
name: Go coverage
runs-on: ubuntu-24.04
permissions:
pull-requests: write
id-token: write
steps:
- name: Harden runner
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: ${{ github.workspace }}/src/github.com/tektoncd/operator
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: "${{ github.workspace }}/src/github.com/tektoncd/operator/go.mod"
- name: Generate coverage
working-directory: ${{ github.workspace }}/src/github.com/tektoncd/operator
run: |
go test -cover -coverprofile=coverage.txt ./... || true
echo "Generated coverage profile"
- name: Archive coverage results
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: code-coverage
path: ${{ github.workspace }}/src/github.com/tektoncd/operator/coverage.txt
- name: Upload coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
continue-on-error: true # job still "succeeds" even if this step fails
with:
files: ${{ github.workspace }}/src/github.com/tektoncd/operator/coverage.txt
flags: unit-tests
use_oidc: true
fail_ci_if_error: true
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: fgrosse/go-coverage-report@c4bf7e78d1379325814b4dd42d80e526082e788b # v1.5.0
continue-on-error: true # This may fail if artifact on main branch does not exist (first run or expired)
with:
token: ${{ secrets.CHATOPS_TOKEN }}
coverage-artifact-name: "code-coverage"
coverage-file-name: "coverage.txt"