-
Notifications
You must be signed in to change notification settings - Fork 168
167 lines (158 loc) · 4.57 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
name: CI
on:
pull_request:
merge_group:
push:
branches:
- main
- release-*
jobs:
test-unit:
runs-on: ubuntu-latest
container:
image: golang:1.22.2-bookworm
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: /go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
run: make test-unit
- name: Remove generated code from report
run: |
grep -v .pb.go coverage.txt | grep -v zz_generated | grep -v service.connect.go > coverage.tmp
mv coverage.tmp coverage.txt
- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
lint-go:
runs-on: ubuntu-latest
container:
image: golang:1.22.2-bookworm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install linter
env:
GOLANGCI_LINT_VERSION: 1.57.2
working-directory: /usr/local/bin
run: |
curl -sSfL https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz \
| tar xvz golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint --strip-components=1
- name: Configure Git
run: git config --global --add safe.directory '*'
- name: Run linter
env:
GO_LINT_ERROR_FORMAT: github-actions
run: make lint-go
lint-charts:
runs-on: ubuntu-latest
container:
image: golang:1.22.2-bookworm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install linter
run: |
cd /usr/local/bin
curl -sSfL https://get.helm.sh/helm-v3.10.0-linux-amd64.tar.gz \
| tar xvz linux-amd64/helm --strip-components=1
- name: Run linter
run: make lint-charts
lint-proto:
runs-on: ubuntu-latest
container:
image: golang:1.22.2-bookworm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install linter
uses: bufbuild/buf-setup-action@v1
with:
version: "1.20.0"
- name: Run linter
env:
BUF_LINT_ERROR_FORMAT: github-actions
run: make lint-proto
check-codegen:
runs-on: ubuntu-latest
container:
image: golang:1.22.2-bookworm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install tools
run: apt update && apt install unzip
- uses: pnpm/action-setup@v3
with:
version: 8
run_install: false
- name: Install nodejs
uses: actions/setup-node@v4
with:
node-version: "20.12.1"
cache: "pnpm"
cache-dependency-path: "**/pnpm-lock.yaml"
- name: Install nodejs dependencies
run: pnpm install --dev
working-directory: ./ui
- uses: actions/cache@v4
with:
path: /go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install buf
uses: bufbuild/buf-setup-action@v1.29.0-1
with:
version: 1.26.1
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "25.3"
- name: Git stuff
# As of go 1.20, this seems to be necessary for invoking git commands
# within the container
run: git config --global --add safe.directory /__w/kargo/kargo
- name: Run Codegen
run: make codegen
- name: Check nothing has changed
run: git diff --exit-code -- .
build-image:
needs: [test-unit, lint-go, lint-charts, lint-proto, check-codegen]
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
build-cli:
needs: [test-unit, lint-go, lint-charts, lint-proto, check-codegen]
runs-on: ubuntu-latest
container:
image: golang:1.22.2-bookworm
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: /go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build CLI
env:
GOFLAGS: -buildvcs=false
run: make build-cli