-
Notifications
You must be signed in to change notification settings - Fork 50
198 lines (177 loc) · 6.79 KB
/
Copy pathcoverage.yaml
File metadata and controls
198 lines (177 loc) · 6.79 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
# Runs coverage and uploads to Codecov.
# - On push to main: provides base reports so Codecov can compute diffs on PRs.
# - On pull_request: provides head reports for the PR branch.
name: Coverage
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches: [main, 'feature/**', 'release/**']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-paths:
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend }}
ui: ${{ steps.filter.outputs.ui }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Check which paths changed
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
token: ''
filters: |
backend:
- '.github/workflows/coverage.yaml'
- 'BUILD'
- 'MODULE.bazel'
- 'bzl/**'
- 'src/**'
- '!src/ui/**'
- 'run/**'
ui:
- '.github/workflows/coverage.yaml'
- 'src/ui/**'
coverage:
needs: [check-paths]
if: needs.check-paths.outputs.backend == 'true'
timeout-minutes: 45
runs-on: self-hosted
continue-on-error: true
environment:
name: internal-ci
env:
COMPOSE_PROJECT_NAME: cov-${{ github.run_id }}
DOCKER_BUILDKIT: "1"
container:
# python:3.10.18-bullseye pinned to digest for security (amd64)
image: python:3.10.18-bullseye@sha256:4e96d6c7c610e5b2a46ff8a36cc76a159d57a5b865d580eda29d51afdc1a1923
env:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: ""
options: --memory=8g --cpus=4 --memory-swap=8g --pids-limit=4096 -v /var/run/docker.sock:/var/run/docker.sock
services:
docker:
# docker:29.2.1-dind pinned to digest for security
image: docker:29.2.1-dind@sha256:2658fda9e8779b94ea1581f4d25214dac9ed144b407902842e5328cce8f861f5
env:
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
options: --privileged --memory=4g --cpus=2
ports:
- 2375:2375
steps:
- name: Install Docker CLI and dependencies
run: |
apt-get update
apt-get install -y ca-certificates curl gnupg git-lfs
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce-cli
echo "Docker version: $(docker --version)"
echo "Git LFS version: $(git-lfs --version)"
- name: Clean up stale LFS hooks
run: rm -f .git/hooks/pre-push .git/hooks/post-checkout .git/hooks/post-commit .git/hooks/post-merge || true
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
lfs: true
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@4fd964a13a440a8aeb0be47350db2fc640f19ca8
with:
bazelisk-cache: true
bazelisk-version: 1.27.0
# Go coverage via rules_go, Python coverage via manual coverage tool wiring in MODULE.bazel.
- name: Run Tests with Coverage
run: |
bazel coverage --config=ci \
--remote_cache=${{ secrets.BAZEL_REMOTE_CACHE_URL }} \
--test_env=DOCKER_HOST=tcp://docker:2375 \
--test_env=TESTCONTAINERS_HOST_OVERRIDE=docker \
--test_output=errors \
-- \
//...
- name: Upload coverage to Codecov
if: always() && !cancelled()
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: bazel-out/_coverage/_coverage_report.dat
flags: backend
fail_ci_if_error: false
- name: Docker cleanup
if: always()
run: |
docker ps -q | xargs -r docker stop --time=5 || true
docker ps -aq | xargs -r docker rm -f || true
docker volume ls -q | xargs -r docker volume rm -f || true
docker network ls --filter type=custom -q | xargs -r docker network rm || true
- name: Host cleanup
if: always()
env:
DOCKER_HOST: ""
run: |
docker ps -aq -f status=exited -f status=dead --filter "until=5m" 2>/dev/null | xargs -r docker rm -f || true
docker volume prune -f 2>/dev/null || true
docker network prune -f 2>/dev/null || true
docker image prune -f 2>/dev/null || true
ui-coverage:
needs: [check-paths]
if: needs.check-paths.outputs.ui == 'true'
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
lfs: true
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
package_json_file: src/ui/package.json
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: src/ui/.nvmrc
cache: pnpm
cache-dependency-path: src/ui/pnpm-lock.yaml
- name: Run Tests with Coverage
working-directory: src/ui
run: |
pnpm install --frozen-lockfile
pnpm test:coverage
- name: Upload UI coverage to Codecov
if: always() && !cancelled()
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: src/ui/coverage/lcov.info
flags: ui
fail_ci_if_error: false