-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
151 lines (141 loc) · 5.34 KB
/
Taskfile.yml
File metadata and controls
151 lines (141 loc) · 5.34 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
version: "3"
tasks:
default:
silent: true
cmds:
- task -l
test:
desc: |-
task APP=<app> CHANNEL=<channel> BASE=<true/false> test
cmds:
- task: download-goss
- >-
echo "VERSION: {{.VERSION}}"
- >-
cue vet --schema '#Spec' ./apps/{{.APP}}/metadata.json metadata.rules.cue
- >-
docker buildx build --progress=plain --load
-t {{.APP}}:{{.CHANNEL}}
--build-arg CHANNEL={{.CHANNEL}}
--build-arg VERSION={{.VERSION}}
{{if ne .PUBLIC_TOKEN ""}}--secret id=PUBLIC_PACKAGES_TOKEN,env=PUBLIC_PACKAGES_TOKEN{{end}}
-f ./apps/{{.APP}}/Dockerfile .
- >-
./.goss/dgoss run {{.APP}}:{{.CHANNEL}} {{if eq .BASE "true"}}tail -f /dev/null{{end}}
vars:
VERSION:
sh: bash ./.github/scripts/upstream.sh "{{.APP}}" "{{.CHANNEL}}"
PUBLIC_TOKEN: '{{.PUBLIC_TOKEN | default ""}}'
env:
CONTAINER_RUNTIME: docker
GOSS_PATH: ./.goss/goss
GOSS_OPTS: --retry-timeout 15s --sleep 2s --color --format documentation
GOSS_FILE: ./apps/{{.APP}}/ci/goss.yaml
test-x64:
desc: |-
task APP=<app> CHANNEL=<channel> BASE=<true/false> [SKIP_STARTUP=true] test
cmds:
- task: download-goss
- >-
echo "VERSION: {{.VERSION}}"
- >-
cue vet --schema '#Spec' ./apps/{{.APP}}/metadata.json metadata.rules.cue
- >-
docker buildx build --platform linux/amd64 --progress=plain --load
-t {{.APP}}:{{.CHANNEL}}
--build-arg CHANNEL={{.CHANNEL}}
--build-arg VERSION={{.VERSION}}
{{if ne .PUBLIC_TOKEN ""}}--secret id=PUBLIC_PACKAGES_TOKEN,env=PUBLIC_PACKAGES_TOKEN{{end}}
-f ./apps/{{.APP}}/Dockerfile .
- >-
./.goss/dgoss run
--platform linux/amd64
{{if eq .SKIP_STARTUP "true"}}-e SKIP_STARTUP=1{{end}}
{{.APP}}:{{.CHANNEL}}
{{if eq .BASE "true"}}tail -f /dev/null{{end}}
vars:
VERSION:
sh: bash ./.github/scripts/upstream.sh "{{.APP}}" "{{.CHANNEL}}"
PUBLIC_TOKEN: '{{.PUBLIC_TOKEN | default ""}}'
SKIP_STARTUP: '{{.SKIP_STARTUP | default "false"}}'
env:
CONTAINER_RUNTIME: docker
GOSS_PATH: ./.goss/goss
GOSS_OPTS: --retry-timeout 15s --sleep 2s --color --format documentation
GOSS_FILE: ./apps/{{.APP}}/ci/goss.yaml
test-push:
silent: true
desc: |-
Build, test, and push multi-platform image to REGISTRY
Usage: task APP=<app> CHANNEL=<channel> BASE=<true|false> REGISTRY=<registry> test-push
cmds:
- task: download-goss
- >-
echo "VERSION: {{.VERSION}}"
- >-
echo "Target platforms: {{.PLATFORMS}}"
#
# - |
# echo "Creating buildx builder {{.BUILDER_NAME}}"
# docker buildx create --name {{.BUILDER_NAME}} --driver docker-container --use
# docker buildx inspect --bootstrap
- >-
cue vet --schema '#Spec' ./apps/{{.APP}}/metadata.json metadata.rules.cue
# Build locally for test platform and test
- >-
docker buildx build --progress=plain --load
-t {{.APP}}:{{.CHANNEL}}-test
--build-arg CHANNEL={{.CHANNEL}}
--build-arg VERSION={{.VERSION}}
-f ./apps/{{.APP}}/Dockerfile .
# Run Goss tests
- |
if [ "{{.TESTS_ENABLED}}" = "true" ]; then
echo "Running Goss tests for {{.APP}}:{{.CHANNEL}}..."
./.goss/dgoss run {{.APP}}:{{.CHANNEL}}-test {{if eq .BASE "true"}}tail -f /dev/null{{end}}
else
echo "Skipping Goss tests for {{.APP}}:{{.CHANNEL}} (tests.enabled = false)"
fi
# Final production build + push for all platforms
- >-
docker buildx build --progress=plain --push
--platform={{.PLATFORMS}}
-t {{.REGISTRY}}/{{.APP}}:{{.CHANNEL}}
-t {{.REGISTRY}}/{{.APP}}:rolling
--build-arg CHANNEL={{.CHANNEL}}
--build-arg VERSION={{.VERSION}}
-f ./apps/{{.APP}}/Dockerfile .
# - |
# echo "Cleaning up buildx builder {{.BUILDER_NAME}}"
# docker buildx prune --builder {{.BUILDER_NAME}} --force
# docker buildx rm {{.BUILDER_NAME}}
vars:
BUILDER_NAME:
sh: echo "builder-{{.APP}}-{{.CHANNEL}}-$(date +%s)"
VERSION:
sh: bash ./.github/scripts/upstream.sh "{{.APP}}" "{{.CHANNEL}}"
PLATFORMS:
sh: jq -r '.channels[] | select(.name == "{{.CHANNEL}}") | .platforms | join(",")' ./apps/{{.APP}}/metadata.json
TESTS_ENABLED:
sh: jq -r '.channels[] | select(.name == "{{.CHANNEL}}") | .tests.enabled' ./apps/{{.APP}}/metadata.json
REGISTRY: "ghcr.io/ipromknight"
env:
CONTAINER_RUNTIME: docker
GOSS_PATH: ./.goss/goss
GOSS_OPTS: --retry-timeout 15s --sleep 2s --color --format documentation
GOSS_FILE: ./apps/{{.APP}}/ci/goss.yaml
download-goss:
silent: true
vars:
# renovate: datasource=github-releases depName=aelsabbahy/goss
GOSS_VERSION: v0.3.18
cmds:
- mkdir -p ./.goss
- curl -fsSL -o ./.goss/goss https://github.com/aelsabbahy/goss/releases/download/{{.GOSS_VERSION}}/goss-linux-amd64
- chmod +x ./.goss/goss
- curl -fsSL -o ./.goss/dgoss https://raw.githubusercontent.com/aelsabbahy/goss/{{.GOSS_VERSION}}/extras/dgoss/dgoss
- chmod +x ./.goss/dgoss
status:
- test -f ./.goss/goss
- test -f ./.goss/dgoss