-
Notifications
You must be signed in to change notification settings - Fork 249
224 lines (202 loc) · 6.67 KB
/
ci.yaml
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: CI Workflow
on:
# Run this workflow every time a new commit pushed to upstream/fork repository.
# Run workflow on fork repository will help contributors find and resolve issues before sending a PR.
pull_request:
push:
# Exclude branches created by Dependabot to avoid triggering current workflow
# for PRs initiated by Dependabot.
branches-ignore:
- 'dependabot/**'
permissions:
contents: read # for actions/checkout to fetch code
env:
REGISTRY: docker.io
IMAGE_REPO: ${{ secrets.IMAGE_REPO || 'projecthami/hami' }}
IMAGE_ROOT_PATH: docker
BUILD_PLATFORM: linux/arm64,linux/amd64
REGISTER_USER: ${{ github.actor }}
REGISTER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
jobs:
lint:
name: lint
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: verify license
run: hack/verify-license.sh
- name: go tidy
run: make tidy
- name: lint
run: make lint
- name: import alias
run: hack/verify-import-aliases.sh
test:
name: Unit test
needs: lint # rely on lint successful completion
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout submodule
uses: Mushus/[email protected]
with:
basePath: # optional, default is .
submodulePath: libvgpu
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make tidy
- run: make test
- name: Upload coverage to Codecov
# Prevent running from the forked repository that doesn't need to upload coverage.
# In addition, running on the forked repository would fail as missing the necessary secret.
if: ${{ github.repository == 'Project-HAMi/HAMi' }}
uses: codecov/codecov-action@v5
with:
# Even though token upload token is not required for public repos,
# but adding a token might increase successful uploads as per:
# https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
token: ${{secrets.CODECOV_TOKEN}}
files: ./_output/coverage/coverage.out
flags: unittests
fail_ci_if_error: false
verbose: true
get_version:
name: get_version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.parse_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Parse the version
id: parse_version
run: |
value=$(make -f Makefile.defs print-version)
suffix="$(git rev-parse --short HEAD)"
tag="${value}-${suffix}"
echo "Generated tag: ${tag}"
echo "version=${tag}" >> $GITHUB_OUTPUT
build:
name: Compile
runs-on: ubuntu-22.04
environment: nvidia
needs: [ test, get_version ]
steps:
- uses: actions/checkout@master
- name: Free disk space
# https://github.com/actions/virtual-environments/issues/709
run: |
echo "=========original CI disk space"
df -h
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "=========after clean up, the left CI disk space"
df -h
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout submodule
uses: Mushus/[email protected]
with:
basePath: # optional, default is .
submodulePath: libvgpu
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:master
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}
- name: Build & Pushing hami image
uses: docker/[email protected]
with:
context: .
file: ${{ env.IMAGE_ROOT_PATH }}/Dockerfile
labels: ${{ needs.get_version.outputs.version }}
build-args: |
VERSION=${{ needs.get_version.outputs.version }}
GOLANG_IMAGE=golang:1.22.5-bullseye
NVIDIA_IMAGE=nvidia/cuda:12.2.0-devel-ubuntu20.04
DEST_DIR=/usr/local
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:${{ needs.get_version.outputs.version }}
push: false
load: true
github-token: ${{ env.REGISTER_PASSWORD }}
- name: List images
run: |
docker images
- name: Save Docker image to image.tar
run: |
docker save ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:${{ needs.get_version.outputs.version }} -o image.tar
- name: Upload image.tar as artifact
uses: actions/upload-artifact@v4
with:
name: hami-image
path: image.tar
retention-days: 5
if-no-files-found: error
# packages tgz from /charts of original branch, deploy to /charts of target branch
package_chart:
runs-on: ubuntu-22.04
needs: [ test, get_version ]
env:
HELM_VERSION: v3.8.1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.get_ref.outputs.ref }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- name: Lint helm chart
run: |
make lint_chart
- name: Package Chart
continue-on-error: false
env:
VERSION: ${{ needs.get_version.outputs.version }}
run: |
cd charts
make clean
make
if ! ls *.tgz &>/dev/null ; then
echo "failed to generate chart"
exit 1
fi
cd ..
mkdir -p tmp
mv charts/*.tgz tmp
- name: Upload Artifact
uses: actions/[email protected]
with:
name: chart_package_artifact
path: tmp/*
retention-days: 5
if-no-files-found: error
# execute a full e2e test when hami code merge
e2e_test:
uses: ./.github/workflows/call-e2e.yaml
needs: [ package_chart, get_version, build ]
with:
ref: ${{ needs.get_version.outputs.version }}
type: "pullrequest"