-
Notifications
You must be signed in to change notification settings - Fork 2.3k
166 lines (142 loc) · 5.89 KB
/
codecov.yml
File metadata and controls
166 lines (142 loc) · 5.89 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Code Coverage
on:
schedule:
- cron: '0 0 * * 6' # Saturday midnight UTC
push:
branches:
- "main"
- "release-[0-9]+.[0-9]"
tags: '**'
pull_request:
branches: '**'
concurrency:
group: format('{0}-{1}-{2}', ${{ github.ref }}, ${{ github.event_name }}, 'Code Coverage')
cancel-in-progress: true
permissions: read-all
jobs:
test:
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'Backport')
name: Code Coverage
runs-on: ${{ github.repository == 'vitessio/vitess' && 'oracle-vm-8cpu-32gb-x86-64' || 'ubuntu-24.04' }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- name: Check out code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: 'false'
- name: Determine run mode
id: mode
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "is_full_run=true" >> "$GITHUB_OUTPUT"
else
echo "is_full_run=false" >> "$GITHUB_OUTPUT"
fi
- name: Check for changes in files relevant to code coverage
if: steps.mode.outputs.is_full_run != 'true'
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: changes
with:
token: ''
filters: |
changed_files:
- .github/workflows/codecov.yml
- 'go/**'
- go.mod
- go.sum
- Makefile
- name: Set up Go
if: steps.mode.outputs.is_full_run == 'true' || steps.changes.outputs.changed_files == 'true'
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: ${{ (github.base_ref == 'main' || (github.base_ref == '' && github.ref_name == 'main')) && 'true' || 'false' }}
- name: Detect changed Go packages
if: steps.mode.outputs.is_full_run != 'true' && steps.changes.outputs.changed_files == 'true'
id: packages
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
CHANGED_GO_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" -- '*.go')
if [ -z "$CHANGED_GO_FILES" ]; then
echo "BASE_SHA=$BASE_SHA"
echo "HEAD_SHA=$HEAD_SHA"
echo "packages=$PACKAGES"
echo "packages=" >> "$GITHUB_OUTPUT"
exit 0
fi
PACKAGE_DIRS=$(echo "$CHANGED_GO_FILES" | xargs -n1 dirname | sort -u)
# Validate as Go packages and exclude endtoend tests. Only consider
# paths under go/; anything else (e.g. ".", "changelog", ".github")
# would expand to ./.../... and pull in the full endtoend suite.
PACKAGES=""
for dir in $PACKAGE_DIRS; do
case "$dir" in
go/*) ;;
*) continue ;;
esac
case "$dir" in
*/endtoend*|go/cmd/vttestserver*) continue ;;
esac
if go list "./$dir" >/dev/null 2>&1; then
PACKAGES="${PACKAGES:+$PACKAGES }$dir"
fi
done
echo "BASE_SHA=$BASE_SHA"
echo "HEAD_SHA=$HEAD_SHA"
echo "packages=$PACKAGES"
echo "packages=$PACKAGES" >> "$GITHUB_OUTPUT"
- name: Set up python
if: steps.mode.outputs.is_full_run == 'true' || (steps.changes.outputs.changed_files == 'true' && steps.packages.outputs.packages != '')
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
- name: Tune the OS
if: steps.mode.outputs.is_full_run == 'true' || (steps.changes.outputs.changed_files == 'true' && steps.packages.outputs.packages != '')
timeout-minutes: 5
uses: ./.github/actions/tune-os
- name: Setup MySQL
if: steps.mode.outputs.is_full_run == 'true' || (steps.changes.outputs.changed_files == 'true' && steps.packages.outputs.packages != '')
timeout-minutes: 8
uses: ./.github/actions/setup-mysql
with:
flavor: mysql-8.4
- name: Get dependencies
if: steps.mode.outputs.is_full_run == 'true' || (steps.changes.outputs.changed_files == 'true' && steps.packages.outputs.packages != '')
timeout-minutes: 5
run: |
export DEBIAN_FRONTEND="noninteractive"
sudo apt-get update
sudo apt-get install -y make unzip g++ curl git wget
go mod download
go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0
- name: Run make tools
if: steps.mode.outputs.is_full_run == 'true' || (steps.changes.outputs.changed_files == 'true' && steps.packages.outputs.packages != '')
timeout-minutes: 10
run: |
make BUILD_JAVA=0 BUILD_PROTOC=0 tools
- name: Run coverage tests
if: steps.mode.outputs.is_full_run == 'true' || (steps.changes.outputs.changed_files == 'true' && steps.packages.outputs.packages != '')
timeout-minutes: 60
run: |
set -exo pipefail
export VTDATAROOT="/tmp/"
export NOVTADMINBUILD=1
source build.env
if [ "${{ steps.mode.outputs.is_full_run }}" = "true" ]; then
make unit_test_cover
else
make COVERAGE_PACKAGES="${{ steps.packages.outputs.packages }}" unit_test_cover
fi
- name: Upload coverage reports
if: steps.mode.outputs.is_full_run == 'true' || (steps.changes.outputs.changed_files == 'true' && steps.packages.outputs.packages != '')
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
files: coverage.out
fail_ci_if_error: true
verbose: true
flags: ${{ steps.mode.outputs.is_full_run == 'true' && '' || 'partial' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}