-
Notifications
You must be signed in to change notification settings - Fork 106
/
justfile
106 lines (80 loc) · 2.52 KB
/
justfile
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
export COMMIT := `git rev-parse --short HEAD`
export VERSION := "0.0.0-" + COMMIT
export E2E_TEST := "default"
skaffoldTags := "tags.json"
defaul:
@just --list
@_skaffold-ctx:
skaffold config set default-repo localhost:5000
# build and publish image to release regisry, create chart archive
build-release:
#!/usr/bin/env bash
set -euo pipefail
skaffold build -b kube-mgmt -t {{VERSION}}
helm package charts/opa-kube-mgmt --version {{VERSION}} --app-version {{VERSION}}
_latest:
#!/usr/bin/env bash
set -euo pipefail
if [ -n "$(echo ${SKAFFOLD_IMAGE_REPO}|grep '^openpolicyagent$')" ]; then
crane tag ${SKAFFOLD_IMAGE} latest
fi
_helm-unittest:
helm plugin ls | grep unittest || helm plugin install https://github.com/helm-unittest/helm-unittest.git
# golang linter
lint-go:
go vet ./...
staticcheck ./...
# helm linter
lint-helm filter="*": _helm-unittest
helm unittest -f '../../test/lint/{{filter}}.yaml' charts/opa-kube-mgmt
# run all unit tests
lint: lint-go lint-helm
# run helm unit tests
test-helm filter="*": _helm-unittest
helm unittest -f '../../test/unit/{{filter}}.yaml' charts/opa-kube-mgmt
# run golang unit tests
test-go:
go test ./...
# run unit tests
test: lint test-go test-helm
# (re) create local k8s cluster using k3d
k3d: && _skaffold-ctx
k3d cluster delete kube-mgmt || true
k3d cluster create --config ./test/e2e/k3d.yaml
rebuild: && build
rm -rf {{skaffoldTags}}
# build and publish docker to local registry
build: _skaffold-ctx
skaffold build --file-output={{skaffoldTags}} --platform=linux/amd64
# install into local k8s
up: _skaffold-ctx down
#!/usr/bin/env bash
set -euo pipefail
if [ ! -f "{{skaffoldTags}}" ]; then
echo 'Run `just build` to build docker image'
exit 1
fi
kubectl delete cm -l kube-mgmt/e2e=true || true
skaffold deploy --build-artifacts={{skaffoldTags}}
# remove from local k8s
down:
skaffold delete || true
# run only e2e test script
test-e2e-sh:
#!/usr/bin/env bash
set -euo pipefail
kubectl delete cm -l kube-mgmt/e2e=true || true
kubectl delete svc -l kube-mgmt/e2e=true || true
./test/e2e/{{E2E_TEST}}/test.sh
# run single e2e test
test-e2e: up test-e2e-sh
# run all e2e tests
test-e2e-all: build
#!/usr/bin/env bash
set -euo pipefail
for E in $(find test/e2e/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort); do
echo "===================================================="
echo "= Running e2e: \`${E}\` "
echo "===================================================="
just E2E_TEST=${E} test-e2e
done