-
Notifications
You must be signed in to change notification settings - Fork 56
183 lines (163 loc) · 5.06 KB
/
go-ci.yml
File metadata and controls
183 lines (163 loc) · 5.06 KB
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
name: Go CI
on:
push:
branches: [ "main" ]
paths:
- "acp/**"
- ".github/workflows/go-ci.yml"
pull_request:
branches: [ "main" ]
paths:
- "acp/**"
- ".github/workflows/go-ci.yml"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
cache-dependency-path: acp/go.sum
- name: Cache acp tools
uses: actions/cache@v4
with:
path: acp/bin
key: ${{ runner.os }}-acp-bin-${{ hashFiles('acp/Makefile') }}
- name: Install golangci-lint
working-directory: acp
run: make golangci-lint
- name: Check formatting
working-directory: acp
run: |
make fmt
if [[ -n $(git diff) ]]; then
echo "::error::Code is not properly formatted. Run 'make fmt' locally."
git diff
exit 1
fi
- name: Run linter
working-directory: acp
run: make lint
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
cache-dependency-path: acp/go.sum
- name: Cache acp tools
uses: actions/cache@v4
with:
path: acp/bin
key: ${{ runner.os }}-acp-bin-${{ hashFiles('acp/Makefile') }}
- name: Run tests
working-directory: acp
run: make test
- name: Upload test coverage
uses: actions/upload-artifact@v4
with:
name: test-coverage
path: acp/cover.out
retention-days: 7
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
cache-dependency-path: acp/go.sum
- name: Cache acp tools
uses: actions/cache@v4
with:
path: acp/bin
key: ${{ runner.os }}-acp-bin-${{ hashFiles('acp/Makefile') }}
- name: Build
working-directory: acp
run: make build
# E2E tests are temporarily disabled due to configuration issues
#
# Issues encountered:
# 1. The e2e test suite has a hardcoded image name "example.com/acp:v0.0.1" in e2e_suite_test.go
# 2. The test expects controller-manager pods to be created in the acp-system namespace
# 3. Attempts to fix:
# - Setting KIND_CLUSTER environment variable to match the KinD cluster name
# - Modifying the Makefile to check for the correct cluster name
# - Trying to use the same image name that's hardcoded in the tests
# 4. The controller-manager pods never get created successfully during CI
#
# TODO:
# - Fix the e2e test configuration to work properly in CI
# - Consider making the test image name configurable instead of hardcoded
# - Debug why the controller-manager pods aren't being created/started correctly
#
# e2e-test:
# name: E2E Tests
# runs-on: ubuntu-latest
# needs: [build]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Set up Go
# uses: actions/setup-go@v5
# with:
# go-version: '1.24'
# cache: true
# cache-dependency-path: acp/go.sum
#
# - name: Setup KinD
# uses: helm/kind-action@v1.9.0
# with:
# cluster_name: acp-example-cluster
# config: acp-example/kind/kind-config.yaml
#
# - name: Set timestamp
# id: timestamp
# run: echo "TIMESTAMP=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV
#
# - name: Fix test-e2e check for cluster
# working-directory: acp
# run: |
# # Temporarily modify the Makefile to check for acp-example-cluster instead of 'kind'
# sed -i 's/@kind get clusters | grep -q '"'"'kind'"'"'/@kind get clusters | grep -q '"'"'acp-example-cluster'"'"'/' Makefile
#
# - name: Build and load controller image
# working-directory: acp
# env:
# IMG: controller:${{ env.TIMESTAMP }}
# run: make docker-build && kind load docker-image controller:${{ env.TIMESTAMP }} --name acp-example-cluster
#
# - name: Run e2e tests
# working-directory: acp
# env:
# KIND_CLUSTER: acp-example-cluster
# IMG: controller:${{ env.TIMESTAMP }}
# run: make test-e2e
docker:
name: Docker Build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, test, build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
working-directory: acp
run: make docker-build