Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify taskfiles
Signed-off-by: Patrick <patrick.weiss@iteratec.com>
  • Loading branch information
p4trickweiss authored and J12934 committed Apr 9, 2026
commit bdfe72c8c8427a1b37d536617fc789d41dee5055
62 changes: 36 additions & 26 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,47 @@ vars:

tasks:
create-kind-cluster:
run: once
cmds:
- 'echo "Starting kind cluster for testing environment"'
- kind create cluster --name testing-env
status:
- kind get clusters | grep testing-env || exit 1
- kind get clusters | grep -q testing-env

build-operator-image:
run: once
cmds:
- 'echo "Building operator image with tag ${IMG_TAG}"'
- docker build -t ${IMG_NS}/operator:${IMG_TAG} {{ .TASKFILE_DIR }}/operator
status:
- docker images | grep "${IMG_NS}/operator" | grep "${IMG_TAG}"
- docker images | grep -q "${IMG_NS}/operator:${IMG_TAG}"

build-lurker-image:
run: once
cmds:
- 'echo "Building lurker image with tag ${IMG_TAG}"'
- docker build -t ${IMG_NS}/lurker:${IMG_TAG} {{ .TASKFILE_DIR }}/lurker
status:
- docker images | grep "${IMG_NS}/lurker" | grep "${IMG_TAG}"
- docker images | grep -q "${IMG_NS}/lurker:${IMG_TAG}"

load-operator-image:
run: once
deps: [build-operator-image]
cmds:
- kind load docker-image ${IMG_NS}/operator:${IMG_TAG} --name testing-env
status:
- kind get images --name testing-env | grep "${IMG_NS}/operator:${IMG_TAG}" || exit 1
- kind get images --name testing-env | grep -q "${IMG_NS}/operator:${IMG_TAG}"

load-lurker-image:
run: once
deps: [build-lurker-image]
cmds:
- kind load docker-image ${IMG_NS}/lurker:${IMG_TAG} --name testing-env
status:
- kind get images --name testing-env | grep "${IMG_NS}/lurker:${IMG_TAG}" || exit 1
- kind get images --name testing-env | grep -q "${IMG_NS}/lurker:${IMG_TAG}"

deploy-operator:
run: once
deps: [load-operator-image, load-lurker-image]
cmds:
- 'echo "Deploying secureCodeBox operator to the testing environment"'
Expand All @@ -72,21 +78,23 @@ tasks:
--set="lurker.image.tag=${IMG_TAG}" \
--set="lurker.image.pullPolicy=IfNotPresent"
status:
- kubectl get deployment -n securecodebox-system securecodebox-controller-manager | grep "1/1" || false
- kubectl get deployment -n securecodebox-system securecodebox-controller-manager | grep -q "1/1"

build-parser-sdk-image:
run: once
cmds:
- 'echo "Building parser-sdk images with tag ${IMG_TAG}"'
- docker build -t securecodebox/parser-sdk-nodejs:${IMG_TAG} {{ .TASKFILE_DIR }}/parser-sdk/nodejs
status:
- docker images | grep "securecodebox/parser-sdk-nodejs" | grep "${IMG_TAG}"
- docker images | grep -q "securecodebox/parser-sdk-nodejs:${IMG_TAG}"

build-hook-sdk-image:
run: once
cmds:
- 'echo "Building hook-sdk images with tag ${IMG_TAG}"'
- docker build -t securecodebox/hook-sdk-nodejs:${IMG_TAG} {{ .TASKFILE_DIR }}/hook-sdk/nodejs
status:
- docker images | grep "securecodebox/hook-sdk-nodejs" | grep "${IMG_TAG}"
- docker images | grep -q "securecodebox/hook-sdk-nodejs:${IMG_TAG}"

prepare-testing-env:
desc: "Prepare the testing environment by running all required tasks"
Expand Down Expand Up @@ -117,13 +125,12 @@ tasks:
preconditions:
- msg: "Helm unittest plugin is not installed. Install it from https://github.com/helm-unittest/helm-unittest/"
sh: "helm plugin list | grep -q 'unittest' || false"
vars:
CHARTS:
sh: find {{ .TASKFILE_DIR }} -name "Chart.yaml" -exec dirname {} \;
cmds:
- |
find . -name "Chart.yaml" | while read -r chart_file; do
chart_dir=$(dirname "$chart_file")
echo "Running tests for helm chart: $chart_dir"
helm unittest $chart_dir
done
- for: { var: CHARTS }
cmd: helm unittest "{{ .ITEM }}"

npm-ci-all:
desc: "Install all NPM dependencies across the project"
Expand All @@ -143,19 +150,21 @@ tasks:

hook-docs:
desc: "Generate documentation for all hooks"
vars:
CHARTS:
sh: find {{ .HOOKS_DIR }} -maxdepth 2 -name "Chart.yaml"
cmds:
- |
for chart in {{ .HOOKS_DIR }}/*/Chart.yaml; do
{{ .BIN_DIR }}/generate-helm-docs.sh --hook "$chart" "{{ .HELM_DOCS_DIR }}"
done
- for: { var: CHARTS }
cmd: '{{ .BIN_DIR }}/generate-helm-docs.sh --hook "{{ .ITEM }}" "{{ .HELM_DOCS_DIR }}"'

scanner-docs:
desc: "Generate documentation for all scanners"
vars:
CHARTS:
sh: find {{ .SCANNERS_DIR }} -maxdepth 2 -name "Chart.yaml"
cmds:
- |
for chart in {{ .SCANNERS_DIR }}/*/Chart.yaml; do
{{ .BIN_DIR }}/generate-helm-docs.sh --scanner "$chart" "{{ .HELM_DOCS_DIR }}"
done
- for: { var: CHARTS }
cmd: '{{ .BIN_DIR }}/generate-helm-docs.sh --scanner "{{ .ITEM }}" "{{ .HELM_DOCS_DIR }}"'

operator-docs:
desc: "Generate documentation for the operator"
Expand All @@ -170,11 +179,12 @@ tasks:

demo-target-docs:
desc: "Generate documentation for demo targets"
vars:
CHARTS:
sh: find {{ .DEMO_TARGETS_DIR }} -maxdepth 2 -name "Chart.yaml"
cmds:
- |
for chart in {{ .DEMO_TARGETS_DIR }}/*/Chart.yaml; do
{{ .BIN_DIR }}/generate-helm-docs.sh --demo-target "$chart" "{{ .HELM_DOCS_DIR }}"
done
- for: { var: CHARTS }
cmd: '{{ .BIN_DIR }}/generate-helm-docs.sh --demo-target "{{ .ITEM }}" "{{ .HELM_DOCS_DIR }}"'

docs:
desc: "Generate all documentation"
Expand Down
30 changes: 11 additions & 19 deletions auto-discovery/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ vars:
COMPONENT_NAME: '{{ .COMPONENT_NAME | default "auto-discovery" }}'
# ENVTEST_K8S_VERSION derived from go.mod
ENVTEST_K8S_VERSION:
sh: |
cd {{ .TASKFILE_DIR }}/{{ .COMPONENT_NAME }} && \
v=$(go list -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' k8s.io/api 2>/dev/null); \
printf '%s\n' "$v" | sed -E 's/^v?[0-9]+\.([0-9]+).*/1.\1/'
sh: cd {{ .TASKFILE_DIR }}/{{ .COMPONENT_NAME }} && go list -m -f '{{"{{"}}.Version{{"}}"}}' k8s.io/api 2>/dev/null | sed -E 's/^v?[0-9]+\.([0-9]+).*/1.\1/'
ENVTEST_VERSION:
sh: |
cd {{ .TASKFILE_DIR }}/{{ .COMPONENT_NAME }} && \
v=$(go list -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' sigs.k8s.io/controller-runtime 2>/dev/null); \
printf '%s\n' "$v" | sed -E 's/^v?([0-9]+)\.([0-9]+).*/release-\1.\2/'
sh: cd {{ .TASKFILE_DIR }}/{{ .COMPONENT_NAME }} && go list -m -f '{{"{{"}}.Version{{"}}"}}' sigs.k8s.io/controller-runtime 2>/dev/null | sed -E 's/^v?([0-9]+)\.([0-9]+).*/release-\1.\2/'
LOCALBIN: '{{ .TASKFILE_DIR }}/{{ .COMPONENT_NAME }}/bin'

tasks:
Expand All @@ -40,21 +34,19 @@ tasks:

envtest:
desc: "Download setup-envtest locally if necessary"
run: once
dir: '{{ .TASKFILE_DIR }}/{{ .COMPONENT_NAME }}'
generates:
- '{{ .LOCALBIN }}/setup-envtest'
- '{{ .LOCALBIN }}/.setup-envtest.version'
cmds:
- mkdir -p {{ .LOCALBIN }}
- |
ENVTEST={{ .LOCALBIN }}/setup-envtest
ENVTEST_VERSION={{ .ENVTEST_VERSION }}
echo "Downloading setup-envtest@$ENVTEST_VERSION"
rm -f "$ENVTEST" "$ENVTEST-$ENVTEST_VERSION"
GOBIN={{ .LOCALBIN }} go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$ENVTEST_VERSION
mv "{{ .LOCALBIN }}/setup-envtest" "$ENVTEST-$ENVTEST_VERSION"
ln -sf "setup-envtest-$ENVTEST_VERSION" "$ENVTEST"
- rm -f {{ .LOCALBIN }}/setup-envtest
- GOBIN={{ .LOCALBIN }} go install sigs.k8s.io/controller-runtime/tools/setup-envtest@{{ .ENVTEST_VERSION }}
- echo "{{ .ENVTEST_VERSION }}" > {{ .LOCALBIN }}/.setup-envtest.version
status:
- test -f {{ .LOCALBIN }}/setup-envtest-{{ .ENVTEST_VERSION }}
- test -L {{ .LOCALBIN }}/setup-envtest
- test "$(readlink {{ .LOCALBIN }}/setup-envtest)" = "setup-envtest-{{ .ENVTEST_VERSION }}"
- test -f {{ .LOCALBIN }}/setup-envtest
- grep -qxF "{{ .ENVTEST_VERSION }}" {{ .LOCALBIN }}/.setup-envtest.version 2>/dev/null

test:
desc: "Run Go tests"
Expand Down
30 changes: 11 additions & 19 deletions auto-discovery/kubernetes/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,27 @@ env:
vars:
CONTROLLER_TOOLS_VERSION: v0.18.0
ENVTEST_K8S_VERSION:
sh: |
cd {{ .TASKFILE_DIR }} && \
v=$(go list -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' k8s.io/api 2>/dev/null); \
printf '%s\n' "$v" | sed -E 's/^v?[0-9]+\.([0-9]+).*/1.\1/'
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/'
ENVTEST_VERSION:
sh: |
cd {{ .TASKFILE_DIR }} && \
v=$(go list -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' sigs.k8s.io/controller-runtime 2>/dev/null); \
printf '%s\n' "$v" | sed -E 's/^v?([0-9]+)\.([0-9]+).*/release-\1.\2/'
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/'
LOCALBIN: '{{ .TASKFILE_DIR }}/bin'

tasks:
controller-gen:
desc: "Download controller-gen locally if necessary"
run: once
dir: '{{ .TASKFILE_DIR }}'
generates:
- '{{ .LOCALBIN }}/controller-gen'
- '{{ .LOCALBIN }}/.controller-gen.version'
cmds:
- mkdir -p {{ .LOCALBIN }}
- |
CONTROLLER_GEN={{ .LOCALBIN }}/controller-gen
CONTROLLER_TOOLS_VERSION={{ .CONTROLLER_TOOLS_VERSION }}
echo "Downloading controller-gen@$CONTROLLER_TOOLS_VERSION"
rm -f "$CONTROLLER_GEN" "$CONTROLLER_GEN-$CONTROLLER_TOOLS_VERSION"
GOBIN={{ .LOCALBIN }} go install sigs.k8s.io/controller-tools/cmd/controller-gen@$CONTROLLER_TOOLS_VERSION
mv "{{ .LOCALBIN }}/controller-gen" "$CONTROLLER_GEN-$CONTROLLER_TOOLS_VERSION"
ln -sf "controller-gen-$CONTROLLER_TOOLS_VERSION" "$CONTROLLER_GEN"
- rm -f {{ .LOCALBIN }}/controller-gen
- GOBIN={{ .LOCALBIN }} go install sigs.k8s.io/controller-tools/cmd/controller-gen@{{ .CONTROLLER_TOOLS_VERSION }}
- echo "{{ .CONTROLLER_TOOLS_VERSION }}" > {{ .LOCALBIN }}/.controller-gen.version
status:
- test -f {{ .LOCALBIN }}/controller-gen-{{ .CONTROLLER_TOOLS_VERSION }}
- test -L {{ .LOCALBIN }}/controller-gen
- test "$(readlink {{ .LOCALBIN }}/controller-gen)" = "controller-gen-{{ .CONTROLLER_TOOLS_VERSION }}"
- test -f {{ .LOCALBIN }}/controller-gen
- grep -qxF "{{ .CONTROLLER_TOOLS_VERSION }}" {{ .LOCALBIN }}/.controller-gen.version 2>/dev/null

manifests:
desc: "Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects"
Expand Down
13 changes: 5 additions & 8 deletions demo-targets/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ tasks:
preconditions:
- msg: "Helm unittest plugin is not installed. Install it from https://github.com/helm-unittest/helm-unittest/"
sh: "helm plugin list | grep -q 'unittest' || false"
vars:
CHARTS:
sh: find {{ .TASKFILE_DIR }} -maxdepth 2 -name "Chart.yaml" -exec dirname {} \;
cmds:
- |
for directory in {{ .TASKFILE_DIR }}/*/; do
if [ -d "$directory" ]; then
dir_name=$(basename "$directory")
echo "Running helm unittest for $dir_name"
helm unittest "$directory"
fi
done
- for: { var: CHARTS }
cmd: helm unittest "{{ .ITEM }}"

deploy:app:
internal: true
Expand Down
15 changes: 4 additions & 11 deletions documentation/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@

version: "3.48.0"

vars:
DIAGRAMS:
sh: 'find {{ .TASKFILE_DIR }} -type f -name "*.puml"'

tasks:
puml:
desc: "Generate PlantUML images from .puml files"
sources:
- '{{ .TASKFILE_DIR }}/**/*.puml'
cmds:
- |
for diagram in {{ .TASKFILE_DIR }}/**/*.puml; do
if [ -f "$diagram" ]; then
echo "Generating PNG for $diagram"
plantuml -tpng "$diagram"
fi
done
- for: sources
cmd: plantuml -tpng {{ .ITEM }}

clean:
desc: "Remove node_modules directory"
Expand Down
32 changes: 18 additions & 14 deletions hooks/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ env:
tasks:
build:
desc: Build the Docker image for the {{ .hookName }} hook
requires:
vars: [hookName]
status:
- docker images | grep -q "docker.io/securecodebox/hook-{{ .hookName }}:${IMG_TAG}" || false
preconditions:
Expand Down Expand Up @@ -65,28 +67,30 @@ tasks:
# test:setup tasks
test:setup:hook-sdk:
internal: true
run: once
dir: '{{ .TASKFILE_DIR }}/../hook-sdk/nodejs'
status:
- "[ -d {{ .TASKFILE_DIR }}/../hook-sdk/nodejs/node_modules ] || false"
- test -d node_modules
cmds:
- cd {{ .TASKFILE_DIR }}/../hook-sdk/nodejs/ && bun install
- bun install
test:setup:test-helpers:
internal: true
run: once
dir: '{{ .TASKFILE_DIR }}/../tests/integration'
status:
- "[ -d {{ .TASKFILE_DIR }}/../tests/integration/node_modules ] || false"
- test -d node_modules
cmds:
- cd {{ .TASKFILE_DIR }}/../tests/integration && bun install
- bun install
test:setup:hook-deps:
internal: true
run: once
dir: '{{ .TASKFILE_DIR }}/{{ .hookName }}/hook'
status:
- "[ -d {{ .TASKFILE_DIR }}/{{ .hookName }}/hook/node_modules ] || false"
- '{{ if eq "true" .hookUsesNpmDependencies }}test -d node_modules{{ else }}true{{ end }}'
cmds:
- |
{{ if eq "true" .hookUsesNpmDependencies }}
cd {{ .TASKFILE_DIR }}/{{ .hookName }}/hook/ && bun install
{{ else }}
echo "Hook has no custom dependencies. Skipping."
{{ end }}
- '{{ if eq "true" .hookUsesNpmDependencies }}bun install{{ else }}echo "Hook has no custom dependencies. Skipping."{{ end }}'
test:setup:
run: once
cmds:
- task: test:setup:hook-sdk
- task: test:setup:test-helpers
Expand Down Expand Up @@ -141,6 +145,6 @@ tasks:
test:
desc: Run all tests for the {{ .hookName }} hook
cmds:
- task test:unit
- task test:helm
- task test:integration
- task: test:unit
- task: test:helm
- task: test:integration
2 changes: 2 additions & 0 deletions operator/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ vars:
tasks:
controller-gen:
desc: "Download controller-gen locally if necessary"
run: once
dir: '{{ .TASKFILE_DIR }}'
generates:
- '{{ .LOCALBIN }}/controller-gen'
Expand All @@ -37,6 +38,7 @@ tasks:

envtest:
desc: "Download setup-envtest locally if necessary"
run: once
dir: '{{ .TASKFILE_DIR }}'
generates:
- '{{ .LOCALBIN }}/setup-envtest'
Expand Down
Loading