Skip to content

Commit a858c0c

Browse files
committed
Fix auto-discovery taskfiles
Signed-off-by: Patrick <patrick.weiss@iteratec.com>
1 parent a068a33 commit a858c0c

4 files changed

Lines changed: 197 additions & 161 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ jobs:
243243

244244
- name: Build Container Image
245245
working-directory: ./auto-discovery/kubernetes/
246-
run: task base:docker-build
246+
run: task docker-build
247247

248248
- name: Export Container Image
249249
working-directory: ./auto-discovery/kubernetes/
250-
run: task base:docker-export
250+
run: task docker-export
251251

252252
- name: Upload Image As Artifact
253253
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
@@ -372,15 +372,15 @@ jobs:
372372
373373
- name: Test
374374
working-directory: ./auto-discovery/cloud-aws/
375-
run: task base:test
375+
run: task test
376376

377377
- name: Build Container Image
378378
working-directory: ./auto-discovery/cloud-aws/
379-
run: task base:docker-build
379+
run: task docker-build
380380

381381
- name: Export Container Image
382382
working-directory: ./auto-discovery/cloud-aws/
383-
run: task base:docker-export
383+
run: task docker-export
384384

385385
- name: Upload Image As Artifact
386386
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0

auto-discovery/Taskfile.yaml

Lines changed: 0 additions & 131 deletions
This file was deleted.

auto-discovery/cloud-aws/Taskfile.yaml

Lines changed: 110 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,122 @@
44

55
version: "3.48.0"
66

7-
includes:
8-
base:
9-
taskfile: ../Taskfile.yaml
10-
vars:
11-
COMPONENT_DIR: '{{ .TASKFILE_DIR }}'
12-
COMPONENT_NAME: cloud-aws
13-
BINARY_NAME: service
14-
BUILD_CMD: cmd/service/main.go
7+
env:
8+
IMG_NS: securecodebox
9+
IMG_TAG:
10+
sh: 'echo "sha-$(git rev-parse --short HEAD)"'
11+
12+
vars:
13+
COMPONENT_NAME: cloud-aws
14+
BINARY_NAME: service
15+
BUILD_CMD: cmd/service/main.go
16+
LOCALBIN: '{{ .TASKFILE_DIR }}/bin'
17+
ENVTEST_K8S_VERSION:
18+
sh: cd {{ .TASKFILE_DIR }} && go list -m -f '{{"{{"}}.Version{{"}}"}}' k8s.io/api 2>/dev/null | sed -E 's/^v?[0-9]+\.([0-9]+).*/1.\1/'
19+
ENVTEST_VERSION:
20+
sh: cd {{ .TASKFILE_DIR }} && go list -m -f '{{"{{"}}.Version{{"}}"}}' sigs.k8s.io/controller-runtime 2>/dev/null | sed -E 's/^v?([0-9]+)\.([0-9]+).*/release-\1.\2/'
1521

1622
tasks:
23+
fmt:
24+
desc: "Run go fmt against code"
25+
dir: '{{ .TASKFILE_DIR }}'
26+
cmds:
27+
- go fmt ./...
28+
29+
vet:
30+
desc: "Run go vet against code"
31+
dir: '{{ .TASKFILE_DIR }}'
32+
cmds:
33+
- go vet ./...
34+
35+
envtest:
36+
desc: "Download setup-envtest locally if necessary"
37+
run: once
38+
dir: '{{ .TASKFILE_DIR }}'
39+
generates:
40+
- '{{ .LOCALBIN }}/setup-envtest'
41+
- '{{ .LOCALBIN }}/.setup-envtest.version'
42+
cmds:
43+
- mkdir -p {{ .LOCALBIN }}
44+
- rm -f {{ .LOCALBIN }}/setup-envtest
45+
- GOBIN={{ .LOCALBIN }} go install sigs.k8s.io/controller-runtime/tools/setup-envtest@{{ .ENVTEST_VERSION }}
46+
- echo "{{ .ENVTEST_VERSION }}" > {{ .LOCALBIN }}/.setup-envtest.version
47+
status:
48+
- test -f {{ .LOCALBIN }}/setup-envtest
49+
- grep -qxF "{{ .ENVTEST_VERSION }}" {{ .LOCALBIN }}/.setup-envtest.version 2>/dev/null
50+
51+
test:
52+
desc: "Run Go tests"
53+
deps: [fmt, vet, envtest]
54+
dir: '{{ .TASKFILE_DIR }}'
55+
cmds:
56+
- |
57+
KUBEBUILDER_ASSETS="$({{ .LOCALBIN }}/setup-envtest use {{ .ENVTEST_K8S_VERSION }} --bin-dir {{ .LOCALBIN }} -p path)" \
58+
go test ./... -coverprofile cover.out
59+
60+
ginkgo:
61+
desc: "Run Ginkgo tests with verbose output"
62+
deps: [fmt, vet, envtest]
63+
dir: '{{ .TASKFILE_DIR }}'
64+
cmds:
65+
- |
66+
KUBEBUILDER_ASSETS="$({{ .LOCALBIN }}/setup-envtest use {{ .ENVTEST_K8S_VERSION }} --bin-dir {{ .LOCALBIN }} -p path)" \
67+
ginkgo test ./... -coverprofile cover.out -v --progress
68+
1769
run:
1870
desc: "Run the cloud-aws service from your host"
19-
deps: [base:fmt, base:vet]
71+
deps: [fmt, vet]
2072
dir: '{{ .TASKFILE_DIR }}'
2173
cmds:
2274
- go run ./cmd/service/main.go --config auto-discovery-cloud-aws-config.yaml
2375

76+
build:
77+
desc: "Build the binary"
78+
deps: [fmt, vet]
79+
dir: '{{ .TASKFILE_DIR }}'
80+
cmds:
81+
- go build -o bin/{{ .BINARY_NAME }} {{ .BUILD_CMD }}
82+
83+
helm-unit-tests:
84+
desc: "Run helm unit tests"
85+
dir: '{{ .TASKFILE_DIR }}'
86+
preconditions:
87+
- msg: "Helm unittest plugin is not installed. Install it from https://github.com/helm-unittest/helm-unittest/"
88+
sh: "helm plugin list | grep -q 'unittest' || false"
89+
cmds:
90+
- helm unittest .
91+
92+
docker-build:
93+
desc: "Build Docker image"
94+
dir: '{{ .TASKFILE_DIR }}'
95+
preconditions:
96+
- msg: "Docker is not running, please start Docker first"
97+
sh: "docker info >/dev/null 2>&1 || false"
98+
cmds:
99+
- docker build -t ${IMG_NS}/auto-discovery-{{ .COMPONENT_NAME }}:${IMG_TAG} .
100+
status:
101+
- docker images | grep -q "${IMG_NS}/auto-discovery-{{ .COMPONENT_NAME }}:${IMG_TAG}"
102+
103+
docker-push:
104+
desc: "Push Docker image"
105+
dir: '{{ .TASKFILE_DIR }}'
106+
cmds:
107+
- docker push ${IMG_NS}/auto-discovery-{{ .COMPONENT_NAME }}:${IMG_TAG}
108+
109+
docker-export:
110+
desc: "Export Docker image to tar file"
111+
deps: [docker-build]
112+
dir: '{{ .TASKFILE_DIR }}'
113+
cmds:
114+
- docker save ${IMG_NS}/auto-discovery-{{ .COMPONENT_NAME }}:${IMG_TAG} > auto-discovery-{{ .COMPONENT_NAME }}.tar
115+
116+
kind-import:
117+
desc: "Import Docker image into kind cluster"
118+
deps: [docker-export]
119+
dir: '{{ .TASKFILE_DIR }}'
120+
cmds:
121+
- kind load image-archive ./auto-discovery-{{ .COMPONENT_NAME }}.tar
122+
24123
helm-deploy:
25124
desc: "Deploy cloud-aws to kind cluster with SQS configuration"
26125
dir: '{{ .TASKFILE_DIR }}'
@@ -30,10 +129,9 @@ tasks:
30129
- msg: "AWS_REGION environment variable is required"
31130
sh: '[ -n "$AWS_REGION" ]'
32131
cmds:
33-
- 'echo "Deploying cloud-aws with image tag ${IMG_TAG} into kind"'
34132
- |
35-
helm -n integration-tests upgrade --install cloud-aws ./ --wait \
36-
--set="image.repository=docker.io/${IMG_NS}/cloud-aws" \
133+
helm -n integration-tests upgrade --install auto-discovery-{{ .COMPONENT_NAME }} ./ --wait \
134+
--set="image.repository=docker.io/${IMG_NS}/auto-discovery-{{ .COMPONENT_NAME }}" \
37135
--set="image.tag=${IMG_TAG}" \
38136
--set="image.pullPolicy=IfNotPresent" \
39137
--set="config.aws.queueUrl=${SQS_QUEUE_URL}" \

0 commit comments

Comments
 (0)