Repository navigation
204 lines (172 loc) · 6.15 KB
/
Copy pathci.yml
File metadata and controls
204 lines (172 loc) · 6.15 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
199
200
201
202
203
204
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
contents: read
concurrency:
group: gpu-descheduler-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
try-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- name: Build
run: go build ./...
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- name: Test
run: go test -race -count=1 ./...
fuzz:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- { pkg: ./pkg/schedulerclient, name: FuzzParseMetrics }
- { pkg: ./pkg/gpu-descheduler/webhook, name: FuzzParseDeviceSpec }
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- name: Fuzz ${{ matrix.target.name }}
env:
PKG: ${{ matrix.target.pkg }}
NAME: ${{ matrix.target.name }}
run: go test "$PKG" -run '^$' -fuzz "^${NAME}\$" -fuzztime 60s
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- name: Check go.mod and go.sum are tidy
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Verify module checksums
run: go mod verify
govulncheck:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Scan with the toolchain the release image is built with, so standard
# library advisories in the shipped binary are caught.
- name: Read builder Go version from Dockerfile
id: go
run: |
version=$(sed -n 's/^FROM golang:\([0-9.]*\)-.* AS builder$/\1/p' Dockerfile)
test -n "$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version: ${{ steps.go.outputs.version }}
- name: Run govulncheck
run: go run golang.org/x/vuln/cmd/govulncheck@v1.10.0 ./...
helm-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Helm
uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e # v5.1.0
with:
version: v4.3.2
- name: Lint chart
run: helm lint chart
- name: Render chart
run: helm template gpu-descheduler chart > /dev/null
- name: Install helm-unittest
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version v1.2.1 --verify=false
- name: Unit test chart
run: helm unittest chart
# The default image and the install command in the READMEs follow the
# chart appVersion, so a release cannot leave them on an older version.
- name: Check versions
run: |
version=$(sed -n 's/^appVersion: "\(.*\)"$/\1/p' chart/Chart.yaml)
test -n "$version"
helm template gpu-descheduler chart > rendered.yaml
grep -q "gpu-descheduler-webhook:v${version}\"" rendered.yaml
grep -q -- "--version ${version}-chart" README.md
grep -q -- "--version ${version}-chart" README_CN.md
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Compute metadata
id: meta
env:
SHA: ${{ github.sha }}
run: |
{
echo "version=dev"
echo "revision=${SHA::7}"
echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
} >> "$GITHUB_OUTPUT"
- name: Build image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: false
load: true
tags: gpu-descheduler-webhook:ci
build-args: |
TARGETOS=linux
TARGETARCH=amd64
VERSION=${{ steps.meta.outputs.version }}
REVISION=${{ steps.meta.outputs.revision }}
BUILD_DATE=${{ steps.meta.outputs.build_date }}
# Fail on any vulnerability that has a fix, whatever its severity:
# trivy rates Debian security advisories UNKNOWN, other scanners
# rate some of them HIGH.
- name: Scan image
run: >-
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock
ghcr.io/aquasecurity/trivy:0.74.0@sha256:62b1e65e8869bc4b4c6aa4fa2b21595256c7c2f6018a9d9ad61caf87187c1969
image --scanners vuln --ignore-unfixed --exit-code 1 --no-progress
gpu-descheduler-webhook:ci