-
Notifications
You must be signed in to change notification settings - Fork 867
143 lines (129 loc) · 3.71 KB
/
go.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
name: Go
on:
push:
branches:
- "master"
- "release-*"
pull_request:
branches:
- "master"
env:
# Golang version to use across CI steps
GOLANG_VERSION: '1.20'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{ github.event_path }}
lint-go:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: Lint Go code
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: ${{ env.GOLANG_VERSION }}
- name: Checkout code
uses: actions/checkout@v4
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.3
args: --timeout 6m
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: ${{ env.GOLANG_VERSION }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Restore go build cache
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
- name: Download all Go modules
run: |
go mod download
- name: Compile all packages
run: make controller plugin
- name: Test
run: make test-unit
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Unit Test Results
path: |
junit.xml
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: coverage.out
- name: Upload code coverage information to codecov.io
uses: codecov/[email protected]
with:
file: coverage.out
codegen:
name: Verify Codegen
runs-on: ubuntu-latest
env:
GOPATH: /home/runner/go
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang
uses: actions/[email protected]
with:
go-version: ${{ env.GOLANG_VERSION }}
# k8s codegen generates files into GOPATH location instead of the GitHub git checkout location
# This symlink is necessary to ensure that `git diff` detects changes
- name: Create symlink in GOPATH
run: |
mkdir -p ~/go/src/github.com/argoproj
ln -s $(pwd) ~/go/src/github.com/argoproj/argo-rollouts
- uses: actions/cache@v3
with:
path: /home/runner/.cache/go-build
key: GOCACHE-${{ hashFiles('**/go.mod') }}
- uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: GOMODCACHE-${{ hashFiles('**/go.mod') }}
- uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: go-bin-v1-${{ hashFiles('**/go.mod') }}
- name: Install protoc
run: |
make install-toolchain
- name: Add ~/go/bin to PATH
run: |
echo "/home/runner/go/bin" >> $GITHUB_PATH
- name: Add /usr/local/bin to PATH
run: |
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Run codegen
run: |
make go-mod-vendor
make codegen
- name: Ensure nothing changed
run: git diff --exit-code