-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (80 loc) · 2.22 KB
/
golang_unit_test.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
name: Go Unit Test
on:
push:
branches-ignore:
- main
- master
pull_request:
branches:
- main
- master
release:
jobs:
vet:
name: vet
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'
- name: Vet
run: |
go vet ./...
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'
- name: fmt
run: |
go fmt ./...
unit-test:
name: unit-test
needs: ["fmt", "vet"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'
# - name: Download envtest setup script
# run: curl -sSLo setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/master/hack/setup-envtest.sh
# - name: Make the script executable
# run: chmod +x setup-envtest.sh
# - name: Setup envtest
# run: ./setup-envtest.sh
# - name: Install Controller-gen
# run: GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected]
# - name: Install Kustomize
# run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
- name: run unit tests
run: make unit-test
- uses: actions/upload-artifact@v3
with:
name: unit_coverage_report
path: unit-test-cover.out
# coverage:
# name: Coverage report
# runs-on: ubuntu-latest
# needs: unit-test
# steps:
# - uses: actions/download-artifact@v3
# with:
# name: unit_coverage_report
# - uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# with:
# files: unit-test-cover.out
# flags: unittests
# fail_ci_if_error: true