-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
197 lines (171 loc) · 6.14 KB
/
Copy pathTaskfile.yml
File metadata and controls
197 lines (171 loc) · 6.14 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
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
version: '3'
vars:
IMAGE: toshy/ffconv
env:
UID:
sh: id -u
GID:
sh: id -g
DOCKER_COMPOSE_RUN: docker compose --progress quiet run --rm --build
HADOLINT_IMAGE: ghcr.io/hadolint/hadolint:v2.14.0
ACTIONLINT_IMAGE: rhysd/actionlint:1.7.12
ZIZMOR_IMAGE: ghcr.io/zizmorcore/zizmor:1.26.1
PINACT_IMAGE: ghcr.io/toshy/docker-pinact:4.1.0
tasks:
default:
cmds:
- task --list
# Docker
build:
desc: Build local images
vars:
TARGETS: [ 'dev', 'prod' ]
cmds:
- for:
var: TARGETS
cmd: docker buildx build --load --target {{.ITEM}} --tag {{.IMAGE}}:{{.ITEM}} .
down:
desc: Down service
cmds:
- docker compose down --remove-orphans
# Shell
shell:dev:
desc: Container shell
vars:
TARGET: 'dev'
cmds:
- $DOCKER_COMPOSE_RUN {{.TARGET}} {{.CLI_ARGS | default "/bin/bash"}}
shell:prod:
desc: Container shell prod
vars:
TARGET: 'prod'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
FONTS_DIRECTORY: '{{.o | default "fonts"}}'
cmds:
- docker buildx build --quiet --target {{.TARGET}} --tag {{.IMAGE}}:{{.TARGET}} .
- docker run -it -u $(id -u):$(id -g) -v ${PWD}/{{.INPUT_DIRECTORY}}:/app/input -v ${PWD}/{{.OUTPUT_DIRECTORY}}:/app/output -v ${PWD}/{{.FONTS_DIRECTORY}}:/app/fonts --entrypoint="/bin/bash" --rm {{.IMAGE}}:{{.TARGET}} {{.CLI_ARGS}}
# Test
dev:
desc: Test dev image (compose)
vars:
TARGET: 'dev'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
cmds:
- mkdir -p ${PWD}/{{.INPUT_DIRECTORY}} ${PWD}/{{.OUTPUT_DIRECTORY}}
- $DOCKER_COMPOSE_RUN -u $(id -u):$(id -g) {{.TARGET}} python -m ffconv {{.CLI_ARGS}}
prod:
desc: Test prod image (docker)
silent: true
vars:
TARGET: 'prod'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
FONTS_DIRECTORY: '{{.o | default "fonts"}}'
cmds:
- docker buildx build --quiet --load --target {{.TARGET}} --tag {{.IMAGE}}:{{.TARGET}} .
- mkdir -p ${PWD}/{{.INPUT_DIRECTORY}} ${PWD}/{{.OUTPUT_DIRECTORY}} ${PWD}/{{.FONTS_DIRECTORY}}
- docker run -it -u $(id -u):$(id -g) -v ${PWD}/{{.INPUT_DIRECTORY}}:/app/input -v ${PWD}/{{.OUTPUT_DIRECTORY}}:/app/output -v ${PWD}/{{.FONTS_DIRECTORY}}:/app/fonts --rm {{.IMAGE}}:{{.TARGET}} {{.CLI_ARGS}}
prod:gpu:
desc: Test prod image with GPU (docker)
silent: true
vars:
TARGET: 'prod'
INPUT_DIRECTORY: '{{.i | default "input"}}'
OUTPUT_DIRECTORY: '{{.o | default "output"}}'
FONTS_DIRECTORY: '{{.o | default "fonts"}}'
cmds:
- docker buildx build --quiet --load --target {{.TARGET}} --tag {{.IMAGE}}:{{.TARGET}} .
- mkdir -p ${PWD}/{{.INPUT_DIRECTORY}} ${PWD}/{{.OUTPUT_DIRECTORY}} ${PWD}/{{.FONTS_DIRECTORY}}
- docker run -it --gpus all -u $(id -u):$(id -g) -v ${PWD}/{{.INPUT_DIRECTORY}}:/app/input -v ${PWD}/{{.OUTPUT_DIRECTORY}}:/app/output -v ${PWD}/{{.FONTS_DIRECTORY}}:/app/fonts --rm {{.IMAGE}}:{{.TARGET}} {{.CLI_ARGS}}
# Development tools
ruff:
desc: Run ruff
cmds:
- $DOCKER_COMPOSE_RUN dev ruff check .
ruff:fix:
desc: Run ruff fix
cmds:
- $DOCKER_COMPOSE_RUN dev ruff check --fix .
black:
desc: Run black
cmds:
- $DOCKER_COMPOSE_RUN dev black . --check --diff --color
black:fix:
desc: Run black fix
cmds:
- $DOCKER_COMPOSE_RUN dev black .
mypy:
desc: Run mypy
cmds:
- $DOCKER_COMPOSE_RUN dev mypy .
# zensical
docs:
desc: Zensical build
cmds:
- docker run --rm -it -v $(pwd):/docs -w /docs docker.io/zensical/zensical:0.0 build --clean
docs:live:
desc: Zensical development server
vars:
PORT: '{{.p | default "8001"}}'
cmds:
- docker run --rm -it -p {{.PORT}}:8000 -v $(pwd):/docs -w /docs docker.io/zensical/zensical:0.0 serve --dev-addr 0.0.0.0:8000
# Linting
hadolint:
desc: Lint all Dockerfiles
cmds:
- docker run --rm -v "{{.ROOT_DIR}}:/repo" -w /repo {{.HADOLINT_IMAGE}} hadolint /repo/Dockerfile
actionlint:
desc: Lint GitHub Actions workflows in .github/workflows
silent: true
cmds:
- docker run --rm -v "{{.ROOT_DIR}}:/repo" -w /repo "{{.ACTIONLINT_IMAGE}}" -color
zizmor:
desc: Audit GitHub Actions workflows for security issues in .github/workflows
silent: true
cmds:
- docker run --rm -v "{{.ROOT_DIR}}:/repo" -w /repo "{{.ZIZMOR_IMAGE}}" --color=always --collect=workflows .
pinact:
desc: Validate GitHub Actions are pinned to commit SHAs in .github/workflows
summary: |
Check pinned GitHub Actions against commit SHAs in .github/workflows.
Usage:
- task pinact TOKEN=github_pat_...
If no "TOKEN" environment variable is passed, you might experience rate limiting.
See https://github.com/suzuki-shunsuke/pinact#github-access-token.
silent: true
vars:
TOKEN: '{{.t | default ""}}'
cmds:
- |
if [ ! -d "{{.ROOT_DIR}}/.github/workflows" ]; then
printf "\033[33m[pinact]\033[0m no .github/workflows directory found\n"
exit 0
fi
docker run --rm \
-v "{{.ROOT_DIR}}:/repo" \
-e PINACT_GITHUB_TOKEN="{{.TOKEN}}" \
"{{.PINACT_IMAGE}}" run --diff
pinact:fix:
desc: Pin GitHub Actions to commit SHAs in-place in .github/workflows
summary: |
Check pinned GitHub Actions against commit SHAs in .github/workflows and fixes them.
Usage:
- task pinact:fix TOKEN=github_pat_...
If no "TOKEN" environment variable is passed, you might experience rate limiting.
See https://github.com/suzuki-shunsuke/pinact#github-access-token.
silent: true
vars:
TOKEN: '{{.t | default ""}}'
cmds:
- |
if [ ! -d "{{.ROOT_DIR}}/.github/workflows" ]; then
printf "\033[33m[pinact]\033[0m no .github/workflows directory found\n"
exit 0
fi
docker run --rm \
-v "{{.ROOT_DIR}}:/repo" \
-u "${UID}:${GID}" \
-e PINACT_GITHUB_TOKEN="{{.TOKEN}}" \
"{{.PINACT_IMAGE}}" run --fix