/
Taskfile.yaml
89 lines (85 loc) · 2.81 KB
/
Taskfile.yaml
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
version: '3'
tasks:
# Package
package-generate:
desc: Generates package files.
cmds:
- for: ["aws", "google", "azure"]
cmd: pkl eval --format yaml pkl/{{ .ITEM }}.pkl --output-path package/{{ .ITEM }}.yaml
package-apply:
desc: Applies Compositions and Composite Resource Definition.
cmds:
- cmd: kubectl apply --filename package/definition.yaml && sleep 1
- for: ["aws.yaml", "azure.yaml", "google.yaml"]
cmd: kubectl apply --filename package/{{ .ITEM }}
package-publish:
desc: Builds and pushes the package.
deps:
- package-generate
cmds:
- up login --token $UP_TOKEN
- up xpkg build --package-root package --name sql.xpkg
- up xpkg push --package package/sql.xpkg xpkg.upbound.io/$UP_ACCOUNT/dot-sql:$VERSION
- rm package/sql.xpkg
- yq --inplace ".spec.package = \"xpkg.upbound.io/devops-toolkit/dot-sql:$VERSION\"" config.yaml
# Test
test:
desc: Combines `cluster-create`, `test-watch` (without the watcher), and `cluster-destroy` tasks.
cmds:
- task: cluster-create
- task: test-watch
- defer: { task: cluster-destroy }
test-watch:
desc: Runs tests assuming that the cluster is already created and everything is installed.
deps:
- task: package-generate
cmds:
- task: package-apply
- chainsaw test
watch: true
sources:
- pkl/*.pkl
- tests/**/*.yaml
generates:
- package/*.yaml
test-once:
desc: Runs tests once assuming that the cluster is already created and everything is installed.
deps:
- task: package-generate
cmds:
- task: package-apply
- chainsaw test
# Cluster
cluster-create:
desc: Creates a kind cluster, installs Crossplane, providers, and packages, waits until they are healthy, and runs tests.
vars:
TIMEOUT: 300s
PROVIDERS:
sh: ls -1 providers | grep -v config
deps:
- package-generate
- cluster-create-kind
- helm-repo
cmds:
- helm upgrade --install crossplane crossplane-stable/crossplane --namespace crossplane-system --create-namespace --wait
- for: { var: PROVIDERS }
cmd: kubectl apply --filename providers/{{ .ITEM }}
- task: package-apply
- sleep 60
- kubectl wait --for=condition=healthy provider.pkg.crossplane.io --all --timeout={{.TIMEOUT}}
- kubectl wait --for=condition=healthy function.pkg.crossplane.io --all --timeout={{.TIMEOUT}}
cluster-destroy:
desc: Destroys the cluster
cmds:
- kind delete cluster
cluster-create-kind:
desc: Creates a kind cluster
cmds:
- cmd: kind create cluster
ignore_error: true
internal: true
helm-repo:
cmds:
- helm repo add crossplane-stable https://charts.crossplane.io/stable
- helm repo update
internal: true