-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
172 lines (148 loc) · 5.03 KB
/
Taskfile.yml
File metadata and controls
172 lines (148 loc) · 5.03 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
---
# 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}}" }}'
base:
taskfile: ./goat/Task/Taskfile.yml
internal: true
optional: true
vars:
IMAGE_NAME: seiso/{{ cookiecutter.project_slug }}
PROJECT_SLUG: {{ cookiecutter.project_slug }}
PYTHON_VERSION: {{ cookiecutter.python_version }}
SUPPORTED_PLATFORMS: 'linux/amd64,linux/arm64'
VERSION:
# Does not use pipenv to avoid pipenv as a project bootstrapping requirement
sh: 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
preconditions:
- which pipenv || python -m pip install --upgrade pipenv
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-install-tools:
desc: Install required tools
internal: true
cmds:
- task: base:mac-brew-install
vars:
TOOLS: syft,grype
- task: base:runner-curl-install
vars:
INSTALL_URL: https://raw.githubusercontent.com/anchore/syft/main/install.sh
TOOL: syft
- task: base:runner-curl-install
vars:
INSTALL_URL: https://raw.githubusercontent.com/anchore/grype/main/install.sh
TOOL: grype
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
- task: init-install-tools
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.
cmds:
- task: py:build
vars:
# Unable to make these global due to https://taskfile.dev/usage/#variables see https://github.com/go-task/task/issues/1295
PLATFORM: '{{ "{{" }}if eq .PLATFORM "all"{{ "}}{{" }}.SUPPORTED_PLATFORMS{{ "}}{{" }}else if .PLATFORM{{ "}}{{" }}.PLATFORM{{ "}}{{" }}else{{ "}}{{" }}.LOCAL_PLATFORM{{ "}}{{" }}end{{ "}}" }}'
test:
desc: Run the project tests
cmds:
- task: py:test
update:
desc: Update the project dev and runtime dependencies, and other misc components
cmds:
- task: py:update
clean:
desc: Clean up build artifacts, cache files/directories, temp files, etc.
cmds:
- task: py:clean
release:
desc: Cut a project release
cmds:
- task: py:release
sbom:
desc: Generate project SBOMs
cmds:
- task: py:sbom
vulnscan:
desc: Vuln scan the SBOM
cmds:
- task: py:vulnscan
{%- if cookiecutter.dockerhub == 'yes' %}
publish:
desc: Publish the project artifacts; docker images, compiled binaries, etc.
cmds:
# We call into the py:publish instead of across to build to simplify centralized policy assessments (i.e. "is the project using a goat-provided task?")
- task: py:publish
vars:
PLATFORM: '{{ "{{" }}if eq .PLATFORM "all"{{ "}}{{" }}.SUPPORTED_PLATFORMS{{ "}}{{" }}else if .PLATFORM{{ "}}{{" }}.PLATFORM{{ "}}{{" }}else{{ "}}{{" }}.LOCAL_PLATFORM{{ "}}{{" }}end{{ "}}" }}'
{%- endif %}