-
Notifications
You must be signed in to change notification settings - Fork 17
90 lines (85 loc) · 2.42 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
name: CI
on:
push:
branches: [ main ]
pull_request:
types: [ opened, reopened, labeled, synchronize ]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
linter:
- golangci-lint
- shellcheck
steps:
- uses: actions/checkout@v4
# - name: Setup Nix
# uses: ./.github/actions/setup-nix
# - name: Run linter
# run: nix run .#lint-${{ matrix.linter }}
build:
runs-on: ubuntu-latest
strategy:
matrix:
package:
- nix-snapshotter
- image-hello
- image-redis
- image-redisWithShell
steps:
- uses: actions/checkout@v4
- name: Setup Nix
uses: ./.github/actions/setup-nix
- name: Build package
run: nix build .#${{ matrix.package }}
integration-test:
runs-on: nix-snapshotter-runner
strategy:
matrix:
test:
- snapshotter
- push-n-pull
- kubernetes
- k3s
- k3s-external
- k3s-rootless
- gvisor
needs: [lint, build]
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
steps:
- uses: actions/checkout@v4
- name: Setup Nix
uses: ./.github/actions/setup-nix
with:
enable-kvm: true
- name: Build snapshotter
run: nix build
- name: Run integration tests
run: nix run -L .#test-${{ matrix.test }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.test }}_build
path: build
if-no-files-found: ignore
retention-days: 1
coverage-report:
runs-on: ubuntu-latest
needs: [integration-test]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: build
merge-multiple: true
- uses: actions/setup-go@v4
with: { go-version: '1.20' }
- name: Collect test coverage
run: |
mkdir -p "$PWD/build/go-cover/unit"
go test -cover ./... -args -test.gocoverdir="$PWD/build/go-cover/unit"
go tool covdata textfmt -i=`find ./build/go-cover -mindepth 1 -type d | paste -sd ","` -o ./build/go-cover/profile
echo "# Coverage report" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
go tool cover -func ./build/go-cover/profile >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY