Skip to content

Commit 812666f

Browse files
authored
ci: change ko build base Image (#865)
* refactor: change ko build base Image Signed-off-by: Shubham Gupta <[email protected]> * ci: add ko build and test ci Signed-off-by: Shubham Gupta <[email protected]> * chore: update flags Signed-off-by: Shubham Gupta <[email protected]> * chore: add golang Signed-off-by: Shubham Gupta <[email protected]> * chore: add user Signed-off-by: Shubham Gupta <[email protected]> * chore: fix directory Signed-off-by: Shubham Gupta <[email protected]> * fix: remove tty Signed-off-by: Shubham Gupta <[email protected]> * fix: use kubectl latest-dev Signed-off-by: Shubham Gupta <[email protected]> * fix: add value flag Signed-off-by: Shubham Gupta <[email protected]> * chore: add makefile targegs Signed-off-by: Shubham Gupta <[email protected]> * chore: add makefile targegs Signed-off-by: Shubham Gupta <[email protected]> * chore: use sha Signed-off-by: Shubham Gupta <[email protected]> * chore: add golnag Signed-off-by: Shubham Gupta <[email protected]> * chore: add makefile targets Signed-off-by: Shubham Gupta <[email protected]> * chore: fix makefile Signed-off-by: Shubham Gupta <[email protected]> * chore: remove golang Signed-off-by: Shubham Gupta <[email protected]> * chore: remove env variable Signed-off-by: Shubham Gupta <[email protected]> * chore: remove comments Signed-off-by: Shubham Gupta <[email protected]> * chore: add golang again Signed-off-by: Shubham Gupta <[email protected]> * chore: add env again Signed-off-by: Shubham Gupta <[email protected]> --------- Signed-off-by: Shubham Gupta <[email protected]>
1 parent 7e4d810 commit 812666f

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

.github/workflows/tests.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,40 @@ jobs:
6767
set -e
6868
make e2e-tests
6969
70+
e2e-test-ko:
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
75+
- name: Setup Go
76+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
77+
with:
78+
go-version-file: go.mod
79+
cache-dependency-path: go.sum
80+
- name: Install ko
81+
uses: imjasonh/setup-ko@ace48d793556083a76f1e3e6068850c1f4a369aa #v0.6
82+
with:
83+
version: v0.15.1
84+
- name: Build Docker image locally with ko
85+
run: |
86+
set -e
87+
make build-ko
88+
env:
89+
KO_DOCKER_REPO: ko.local
90+
- name: Create test cluster
91+
run: |
92+
set -e
93+
make kind-cluster
94+
- name: Run tests
95+
run: |
96+
set -e
97+
make e2e-tests-ko
98+
7099
required:
71100
needs:
72101
- unit-tests
73102
- e2e-tests
103+
- e2e-test-ko
74104
runs-on: ubuntu-latest
75105
steps:
76106
- run: echo "Required jobs success!"

.ko.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
defaultBaseImage: cgr.dev/chainguard/kubectl:latest-dev

Makefile

+22-1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ $(CLI_BIN): fmt vet
219219

220220
build: $(CLI_BIN) ## Build
221221

222+
.PHONY: build-ko
223+
build-ko: ## Build Docker image with ko
224+
@echo "Build Docker image with ko..." >&2
225+
export KO_DOCKER_REPO=ko.local
226+
ko build --base-import-paths main.go
227+
222228
########
223229
# TEST #
224230
########
@@ -234,7 +240,22 @@ e2e-tests: $(CLI_BIN) ## Run e2e tests
234240
@echo Running e2e tests... >&2
235241
@echo "foo: bar" | ./$(CLI_BIN) test --test-dir ./testdata/e2e --config ./testdata/e2e/config.yaml --values -
236242

237-
########
243+
.PHONY: e2e-tests-ko
244+
e2e-tests-ko:
245+
@echo Running e2e tests in docker... >&2
246+
@docker run \
247+
-v ./testdata/e2e/:/chainsaw/ \
248+
-v ${HOME}/.kube/:/etc/kubeconfig/ \
249+
-e KUBECONFIG=/etc/kubeconfig/config \
250+
--network=host \
251+
--user $(id -u):$(id -g) \
252+
--name chainsaw \
253+
--rm ko.local/main.go:latest \
254+
test --test-dir /chainsaw \
255+
--config /chainsaw/config.yaml \
256+
--values /chainsaw/values.yaml
257+
258+
########
238259
# KIND #
239260
########
240261

testdata/e2e/config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: chainsaw.kyverno.io/v1alpha1
33
kind: Configuration
44
metadata:
5-
name: congiguration
5+
name: configuration
66
spec:
77
fullName: true
88
failFast: true

testdata/e2e/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo: bar

0 commit comments

Comments
 (0)