-
Notifications
You must be signed in to change notification settings - Fork 7
/
Taskfile.yml
216 lines (193 loc) · 6.62 KB
/
Taskfile.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
---
# https://taskfile.dev
version: '3'
set:
- nounset
- errexit
- pipefail
includes:
py:
taskfile: ./goat/Task/python/Taskfile.yml
internal: true
optional: true
vars:
IMAGE_NAME: '{{.IMAGE_NAME}}'
PROJECT_SLUG: '{{.PROJECT_SLUG}}'
PYTHON_VERSION: '{{.PYTHON_VERSION}}'
VERSION: '{{.VERSION}}'
terraform:
taskfile: ./goat/Task/terraform/Taskfile.yml
internal: true
optional: true
vars:
IMAGE_NAME: seiso/easy_infra
PROJECT_SLUG: easy_infra
PYTHON_VERSION: 3.11
SUPPORTED_PLATFORMS: 'linux/amd64,linux/arm64'
VERSION:
sh: pipenv run python -c 'from {{.PROJECT_SLUG}} import __version__; print(__version__)'
LOCAL_PLATFORM:
# Inspired by https://github.com/containerd/containerd/blob/e0912c068b131b33798ae45fd447a1624a6faf0a/platforms/database.go#L76
sh: |
os="linux"
arch="$(uname -m)"
case ${arch} in
# AMD64
x86_64) echo "${os}/amd64" ;;
amd64) echo "${os}/amd64" ;;
# ARM64
aarch64) echo "${os}/arm64" ;;
arm64) echo "${os}/arm64" ;;
esac
silent: true
tasks:
init-pipenv:
desc: Initializes the pipenv virtual environment if Pipfile.lock changes
internal: true
sources:
- Pipfile.lock
cmds:
- pipenv install --deploy --ignore-pipfile --dev
init-submodules:
desc: >
Initializes git submodules; paved road projects include the Seiso goat 🐐
for its shared configs, etc.
internal: true
status:
# Only update submodules if you are in a git repository; quote to avoid yaml intrepretering the ! as a node tag
# https://yaml.org/spec/1.2.2/#691-node-tags
- '! test -d .git'
cmds:
- git submodule update --init
init-pre-commit:
desc: Install the pre-commit hooks
internal: true
sources:
- .pre-commit-config.yaml
status:
# Only install the pre-commit hooks if you are in a git repository; quote to avoid yaml intrepretering the ! as a node tag
# https://yaml.org/spec/1.2.2/#691-node-tags
- '! test -d .git'
cmds:
# Don't run this in pipelines
- '{{if ne .GITHUB_ACTIONS "true"}}pipenv run pre-commit install{{else}}echo "Detected a github actions pipeline; skipping the pre-commit install"{{end}}'
init:
desc: Initialize the repo for local use; intended to be run after git clone
cmds:
- task: init-pipenv
- task: init-submodules
- task: init-pre-commit
lint:
desc: Run the linter(s); paved road projects use the Seiso goat 🐐
cmds:
- task: py:lint
vars:
INPUT_LOG_LEVEL: '{{.CLI_ARGS}}'
validate:
desc: Validate the pre-commit config and hooks files
cmds:
- task: py:validate
build:
desc: Build the project; docker images, compiled binaries, etc.
vars:
TOOL: '{{.TOOL | default "all"}}'
ENVIRONMENT: '{{.ENVIRONMENT | default "all"}}'
DEBUG: '{{.DEBUG | default "False"}}'
TRACE: '{{.TRACE | default "False"}}'
DRY_RUN: '{{.DRY_RUN | default "False"}}'
PLATFORM: '{{.PLATFORM | default .LOCAL_PLATFORM}}'
cmds:
- |
pipenv run python -c \
'from distutils.util import strtobool;
trace = bool(strtobool("{{.TRACE}}"));
debug = bool(strtobool("{{.DEBUG}}"));
dry_run = bool(strtobool("{{.DRY_RUN}}"));
from {{.PROJECT_SLUG}} import utils;
utils.build(tool="{{.TOOL}}", environment="{{.ENVIRONMENT}}", trace=trace, debug=debug, dry_run=dry_run)'
test:
desc: Run the project tests
vars:
TOOL: '{{.TOOL | default "all"}}'
ENVIRONMENT: '{{.ENVIRONMENT | default "all"}}'
USER: '{{.USER | default "all"}}'
DEBUG: '{{.DEBUG | default "False"}}'
TAG: '{{.CLI_ARGS | default ""}}'
PLATFORM: '{{.PLATFORM | default .LOCAL_PLATFORM}}'
cmds:
- find tests -mindepth 1 -type d -exec chmod o+w {} \;
- |
pipenv run python -c \
'from distutils.util import strtobool;
debug = bool(strtobool("{{.DEBUG}}"));
from {{.PROJECT_SLUG}} import utils;
utils.test(tool="{{.TOOL}}", environment="{{.ENVIRONMENT}}", user="{{.USER}}", debug=debug, tag="{{.TAG}}")'
update:
desc: Update the project dev and runtime dependencies, and other misc components
vars:
DEBUG: '{{.DEBUG | default "False"}}'
cmds:
- task: py:update
- |
pipenv run python -c \
'from distutils.util import strtobool;
debug = bool(strtobool("{{.DEBUG}}"));
from {{.PROJECT_SLUG}} import utils;
utils.update(debug=debug)'
release:
desc: Cut a project release
cmds:
- task: py:release
publish:
desc: Publish the project artifacts; docker images, compiled binaries, etc.
vars:
TOOL: '{{.TOOL | default "all"}}'
ENVIRONMENT: '{{.ENVIRONMENT | default "all"}}'
DEBUG: '{{.DEBUG | default "False"}}'
DRY_RUN: '{{.DRY_RUN | default "False"}}'
cmds:
# At the point of writing this we couldn't use py:publish but ostensibly that could be used in the future with some new adjustments
- |
pipenv run python -c \
'from distutils.util import strtobool;
debug = bool(strtobool("{{.DEBUG}}"));
dry_run = bool(strtobool("{{.DRY_RUN}}"));
from {{.PROJECT_SLUG}} import utils;
utils.publish(tool="{{.TOOL}}", environment="{{.ENVIRONMENT}}", debug=debug, dry_run=dry_run)'
sbom:
desc: Generate the SBOMs
vars:
TOOL: '{{.TOOL | default "all"}}'
ENVIRONMENT: '{{.ENVIRONMENT | default "all"}}'
DEBUG: '{{.DEBUG | default "False"}}'
cmds:
- |
pipenv run python -c \
'from distutils.util import strtobool;
debug = bool(strtobool("{{.DEBUG}}"));
from {{.PROJECT_SLUG}} import utils;
utils.sbom(tool="{{.TOOL}}", environment="{{.ENVIRONMENT}}", debug=debug)'
vulnscan:
desc: Vuln scan the SBOMs
vars:
TOOL: '{{.TOOL | default "all"}}'
ENVIRONMENT: '{{.ENVIRONMENT | default "all"}}'
DEBUG: '{{.DEBUG | default "False"}}'
cmds:
- |
pipenv run python -c \
'from distutils.util import strtobool;
debug = bool(strtobool("{{.DEBUG}}"));
from {{.PROJECT_SLUG}} import utils;
utils.vulnscan(tool="{{.TOOL}}", environment="{{.ENVIRONMENT}}", debug=debug)'
clean:
desc: Clean up build artifacts, cache files/directories, temp files, etc.
cmds:
- task: py:clean
- task: terraform:clean
- task: easy_infra_cleanup
easy_infra_cleanup:
desc: Cleanup specific to easy_infra
cmds:
- rm -f '{{.ROOT_DIR}}/build/functions.sh'
- rm -f '{{.ROOT_DIR}}/build/Dockerfile'