-
Notifications
You must be signed in to change notification settings - Fork 5
344 lines (321 loc) · 12 KB
/
ci.yml
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
name: CI
on:
push:
branches:
- '**'
release:
types:
- created
repository_dispatch:
types: [trigger-test]
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
image_version:
description: 'Specify docker image version to test'
required: false
jobs:
build:
name: test (${{ matrix.os }}/${{ matrix.arch }}/${{ matrix.runs_on }})
runs-on: ${{ matrix.runs_on }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: amd64
os_alias: linux
arch_alias: amd64
runs_on: ubuntu-20.04
goos: linux
- os: macos
arch: amd64
os_alias: osx
arch_alias: amd64
goos: darwin
runs_on: macos-12
- os: linux
arch: arm32
os_alias: linux
arch_alias: armhf
goos: linux
goarch: arm
goarm: "7"
runs_on: ubuntu-20.04
cc: arm-linux-gnueabihf-gcc
cgo_enabled: 1
- os: linux
arch: arm64
os_alias: linux
arch_alias: arm64
goos: linux
goarch: arm64
runs_on: ubuntu-20.04
cc: aarch64-linux-gnu-gcc
cgo_enabled: 1
env:
TRAVIS_OS_NAME: ${{ matrix.os_alias }}
TRAVIS_ARCH: ${{ matrix.arch }}
REGISTRY: ghcr.io/
KIND_IMG_VERSION: v1.21.1
CC: ${{ matrix.cc }}
CGO_ENABLED: ${{ matrix.cgo_enabled }}
GOOS: ${{matrix.goos}}
GOARCH: ${{matrix.goarch}}
GOARM: ${{matrix.goarm}}
DOCKER_IMG_VERSION_DEFAULT: 0.8
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.17.1
cache: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-${{ matrix.arch }}-ccache-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-${{ matrix.arch }}-ccache-build-
- name: Event Information
run: |
echo "Event '${{ github.event.action }}' from '${{ github.event.client_payload.repository }}'"
- name: Set env
run: |
echo "$HOME/.local/bin:${{ github.workspace }}/bin" >> $GITHUB_PATH
echo "export PATH=$HOME/.local/bin:${{ github.workspace }}/bin:$PATH" >> $HOME/.bashrc
RELEASE_VERSION=`git describe --tags --abbrev=0 | sed "s/^v//"`
if [ `git rev-list -n 1 v"$RELEASE_VERSION"` == `git rev-list -n 1 HEAD` ] ; then
BUILD_VERSION=${RELEASE_VERSION}
else
BUILD_VERSION=${RELEASE_VERSION}-next
fi
PACKAGE_FILENAME=docker-runu_${BUILD_VERSION}_${{ matrix.arch_alias }}.deb
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
echo "BUILD_DATE="`date "+%Y%m%d"` >> $GITHUB_ENV
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
echo "DEB_ARCH=${{ matrix.arch_alias }}" >> $GITHUB_ENV
# image version
if [ -n "${{ github.event.inputs.image_version }}" ] ; then
echo "DOCKER_IMG_VERSION=${{ github.event.inputs.image_version }}" >> $GITHUB_ENV
elif [ -n "${{ github.event.client_payload.img_version }}" ] ; then
# TODO: not implemented yet
echo "DOCKER_IMG_VERSION=${{ github.event.client_payload.img_version }}" >> $GITHUB_ENV
else
echo "DOCKER_IMG_VERSION=${{ env.DOCKER_IMG_VERSION_DEFAULT }}" >> $GITHUB_ENV
fi
echo "GO_FLAGS=-ldflags \"-X main.version="${BUILD_VERSION}"\"" >> $GITHUB_ENV
- name: package installation (linux)
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: |
sudo apt update -y
sudo apt install -y bridge-utils
- name: package installation (linux-cross)
if: runner.os == 'linux' && ( matrix.arch == 'arm32' || matrix.arch == 'arm64')
run: |
sudo apt-get update -y
sudo apt-get install -y crossbuild-essential-${{ matrix.arch_alias }}
- name: package installation (mac)
if: runner.os == 'macos'
run: |
mkdir -p ~/.local/bin
# use pre-installed golang instead of brew
ln -s `which go` /usr/local/Homebrew/Library/Homebrew/shims/mac/super/go
brew install ukontainer/lkl/darwin-snapshotter ukontainer/lkl/containerd ukontainer/lkl/nerdctl --ignore-dependencies
brew install coreutils
ln -sf /usr/local/bin/gsha256sum ~/.local/bin/sha256sum
- name: Build
run: |
go install ${{ env.GO_FLAGS }} -v .
- name: Build shim
if: runner.os == 'macos'
run: |
go install ${{ env.GO_FLAGS }} -v ./cmd/containerd-shim-runu-v1
- name: Go Test
if: matrix.arch == 'amd64'
run: |
sudo go test -v .
runu -v
- name: goreportcard
if: runner.os == 'linux' && matrix.arch == 'amd64' && matrix.runs_on == 'ubuntu-18.04'
run: |
cd /tmp
go get -u github.com/gojp/goreportcard/cmd/goreportcard-cli
GO111MODULE=off go get -u github.com/alecthomas/gometalinter
go get -u github.com/gordonklaus/ineffassign
go get -u github.com/fzipp/gocyclo/cmd/gocyclo
go get -u github.com/client9/misspell/cmd/misspell
go get -u golang.org/x/lint/golint
cd ${{ github.workspace }}
# Do checks
GO111MODULE=on goreportcard-cli -t 100.0 -v
# TODO: run qemu for arm32/arm64 tests
- name: Test (standalone)
if: matrix.arch != 'arm32' && matrix.arch != 'arm64'
run: bash -e ${{ github.workspace }}/test/standalone-test.sh
- name: Test (containerd/ctr)
run: bash -e ${{ github.workspace }}/test/containerd-ctr-test.sh
- name: Test (containerd/nerdctl)
run: bash -e ${{ github.workspace }}/test/containerd-nerdctl-test.sh
# TODO: run qemu for arm32/arm64 tests
- name: Test (dockerd)
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: bash -e ${{ github.workspace }}/test/docker-oci-test.sh
- name: Test (docker more)
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: bash -e ${{ github.workspace }}/test/docker-more-test.sh
- name: Test (docker volume)
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: bash -e ${{ github.workspace }}/test/docker-volume-test.sh
- name: KinD image preparation
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: |
. ${{ github.workspace }}/test/common.sh
# prepare RUNU_AUX_DIR
create_runu_aux_dir
cp $RUNU_AUX_DIR/libc.so k8s/
cp $RUNU_AUX_DIR/lkick k8s/
# Build kind node docker image
cp `which runu` k8s/
cd k8s
docker build -t ukontainer/node-runu:$KIND_IMG_VERSION .
cd ..
- uses: engineerd/setup-kind@v0.5.0
name: kind setup with default CNI
if: runner.os == 'linux' && matrix.arch == 'amd64'
with:
version: "v0.11.1"
config: "k8s/kind-cluster.yaml"
image: "ukontainer/node-runu:${{ env.KIND_IMG_VERSION }}"
- name: Test (k8s)
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: |
bash -e ${{ github.workspace }}/test/k8s-test.sh 127.0.0.1
- run: kind delete cluster
if: runner.os == 'linux' && matrix.arch == 'amd64'
- uses: engineerd/setup-kind@v0.5.0
name: kind setup with calico
if: runner.os == 'linux' && matrix.arch == 'amd64'
with:
version: "v0.11.1"
config: "k8s/kind-cluster-calico.yaml"
image: "ukontainer/node-runu:${{ env.KIND_IMG_VERSION }}"
wait: "0s"
- name: Test (k8s/calico)
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: |
set -x
NET=`kubectl cluster-info dump | grep -- --cluster-cidr | cut -d'=' -f2 | sed s/\"\,//`
# install calico
curl -s https://docs.projectcalico.org/v3.20/manifests/calico.yaml | sed "s,192.168.0.0/16,$NET," | kubectl apply -f -
sleep 30
DST=`kubectl get node -o wide | grep control-plane | awk '{print $6}'`
bash -e ${{ github.workspace }}/test/k8s-test.sh $DST
- name: Build Debian package
if: runner.os == 'linux'
run: |
bash -ex pkg/pre-deploy-deb.sh
- name: Verify Debian package
if: runner.os == 'linux'
run: |
dpkg --info *.deb
dpkg --contents *.deb
- name: Test Debian package
if: runner.os == 'linux' && matrix.arch == 'amd64'
run: |
bash -ex pkg/pre-deploy-test-deb.sh
- name: upload artifact
if: runner.os == 'linux'
uses: actions/upload-artifact@v4
with:
path: ${{ env.PACKAGE_FILENAME }}
name: ${{ env.PACKAGE_FILENAME }}
# TODO: prepare homebrew bottle
- name: Github Releases
if: runner.os == 'linux' && gitHub.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.RELEASE_VERSION }}
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ env.PACKAGE_FILENAME }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.5
- name: Release to packagecloud.io
if: runner.os == 'linux' && gitHub.event_name == 'release'
run: |
# Instsall packagecloud CLI
gem install package_cloud
# push all versions and delete it in advance
for distro_version in ${{ env.DISTRO_LIST }} ; do
package_cloud yank ukontainer/runu/$distro_version ${{ env.PACKAGE_FILENAME }} || true
package_cloud push ukontainer/runu/$distro_version ${{ env.PACKAGE_FILENAME }}
done
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
DISTRO_LIST: "ubuntu/focal ubuntu/jammy ubuntu/noble"
- name: Test Released Debian package
if: runner.os == 'linux' && matrix.arch == 'amd64' && gitHub.event_name == 'release'
run: |
sudo apt-get remove docker-runu
#set -x
# wait for complete indexing at pkgcloud
sleep 60
curl -s https://packagecloud.io/install/repositories/ukontainer/runu/script.deb.sh | sudo bash
sudo apt-get install docker-runu
docker run --rm -i --runtime=runu-dev alpine uname -a
- name: Log in to docker.io
if: runner.os == 'linux'
uses: docker/login-action@v3.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the ghcr.io
if: runner.os == 'linux'
uses: docker/login-action@v3.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: gitHub.event_name == 'release' && runner.os == 'linux' && matrix.arch == 'amd64'
uses: docker/build-push-action@v2
with:
context: k8s
platforms: linux/amd64
push: true
tags: |
docker.io/ukontainer/node-runu:${{ env.KIND_IMG_VERSION }}
ghcr.io/ukontainer/node-runu:${{ env.KIND_IMG_VERSION }}
- name: Log
if: always()
run: |
cat /tmp/dockerd.log || true
cat /tmp/containerd.log || true
cat /tmp/darwin-snapshotter.log || true
- run: kind export logs logs
if: runner.os == 'linux' && matrix.arch == 'amd64' && always()
- uses: actions/upload-artifact@v4
if: runner.os == 'linux' && matrix.arch == 'amd64' && always()
with:
name: KinD-log
path: logs
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled && always ()}}