forked from home-operations/containers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
93 lines (85 loc) · 3.16 KB
/
Copy pathTaskfile.yaml
File metadata and controls
93 lines (85 loc) · 3.16 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
---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
set: [pipefail]
shopt: [globstar]
vars:
BIN_DIR: '{{.ROOT_DIR}}/.bin'
tasks:
default:
cmd: task --list
silent: true
init:
desc: Initialize the project
cmds:
- mkdir -p {{.BIN_DIR}}/goss {{.BIN_DIR}}/dgoss
- |
if [[ ! -x {{.BIN_DIR}}/goss/goss ]]; then
GOSS_ARCH="{{ARCH}}"
[[ "${GOSS_ARCH}" == "amd64" ]] && GOSS_ARCH="x86_64"
gh release download --repo goss-org/goss --pattern "goss_*_linux_${GOSS_ARCH}.tar.gz" --output /tmp/goss.tar.gz
tar -xzf /tmp/goss.tar.gz -C {{.BIN_DIR}}/goss goss
rm -f /tmp/goss.tar.gz
fi
- gh release download --repo goss-org/goss --skip-existing --pattern "dgoss" --output {{.BIN_DIR}}/dgoss/dgoss
- chmod +x {{.BIN_DIR}}/goss/goss {{.BIN_DIR}}/dgoss/dgoss
preconditions:
- which gh
local-build-*:
desc: Build and Test an app via Docker Buildx
dir: '{{.WORK_DIR}}'
cmds:
- rsync -a --ignore-existing --progress {{.ROOT_DIR}}/include/ {{.WORK_DIR}}
- rsync -a --ignore-existing --progress {{.ROOT_DIR}}/apps/{{.APP}}/ {{.WORK_DIR}}
- docker buildx bake --no-cache --metadata-file docker-bake.json --load
- |
IMAGE=$(jq --raw-output '."image-local"."containerimage.config.digest"' docker-bake.json)
case "{{.TEST_TOOL}}" in
"cst")
container-structure-test test --image "${IMAGE}" --config tests.yaml
;;
"goss")
{{.BIN_DIR}}/dgoss/dgoss run "${IMAGE}"
;;
esac
- defer: rm -rf {{.WORK_DIR}}
env:
GOSS_FILE: tests.yaml
GOSS_OPTS: --retry-timeout 60s --sleep 1s
GOSS_PATH: '{{.BIN_DIR}}/goss/goss'
vars:
APP: '{{index .MATCH 0}}'
TEST_TOOL:
sh: yq --exit-status '.schemaVersion' {{.ROOT_DIR}}/apps/{{.APP}}/tests.yaml &>/dev/null && echo "cst" || echo "goss"
WORK_DIR:
sh: mktemp -d
preconditions:
- test -f {{.ROOT_DIR}}/apps/{{.APP}}/docker-bake.hcl
- test -f {{.ROOT_DIR}}/apps/{{.APP}}/tests.yaml
- test -f {{.ROOT_DIR}}/apps/{{.APP}}/Dockerfile
- which container-structure-test docker gh jq yq
remote-build-*:
desc: Build and Test an app via GitHub Actions
cmds:
- gh workflow run release.yaml -f app={{.APP}} -f release={{.RELEASE}}
vars:
APP: '{{index .MATCH 0}}'
RELEASE: '{{.RELEASE | default "false"}}'
preconditions:
- gh auth status
- test -f {{.ROOT_DIR}}/.github/workflows/release.yaml
- which gh
generate-label-config:
desc: Generate labels and labeler config
cmds:
- for: { var: apps }
cmd: |
yq --inplace '. += [{"name": "app/{{.ITEM}}", "color": "027fa0"}]' {{.ROOT_DIR}}/.github/labels.yaml
- for: { var: apps }
cmd: |
yq --inplace '. += {"app/{{.ITEM}}": [{"changed-files": [{"any-glob-to-any-file": ["apps/{{.ITEM}}/**"]}]}]}' {{.ROOT_DIR}}/.github/labeler.yaml
vars:
apps:
sh: ls --directory {{.ROOT_DIR}}/apps/*/ | xargs --max-args=1 basename
preconditions:
- sh: '[[ -z {{.CLI_FORCE}} ]]'