-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
143 lines (125 loc) · 3.69 KB
/
Taskfile.yml
File metadata and controls
143 lines (125 loc) · 3.69 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
version: '3'
vars:
git_root:
sh: git rev-parse --show-toplevel
rust_version: "1.90.0"
cache_dir: ".cache"
# local repository image tag path (1.90.0-1)
image_patch: "-1"
tasks:
default:
desc: Default task.
cmds:
- echo "Please enter a task or use '-l' or '--list-all' to list all available tasks"
silent: true
# ================================================#
# ---------------------INTERNAL-------------------#
# ================================================#
_docker/run:
desc: Internal wrapper to run task in containers.
internal: true
silent: true
requires:
vars: [ IMAGE, CMD, MOUNT_DIR ]
dir: "{{.git_root}}"
cmd: |
set -euo pipefail
if ! docker image inspect "{{.IMAGE}}" >/dev/null 2>&1; then
echo "pulling: {{.IMAGE}}"
docker pull -q "{{.IMAGE}}" >/dev/null 2>&1 || {
echo "Failed to pull image: {{.IMAGE}}"
exit 1
}
fi
docker run --rm --init --pull=never \
--security-opt no-new-privileges \
--user $(id -u):$(id -g) \
--cap-drop=ALL \
\
--volume "{{.git_root}}/{{.MOUNT_DIR}}:/workspace:rw" \
{{if .VOLUMES}}{{range $vol := .VOLUMES}}--volume {{$vol}} {{end}}{{end}} \
{{if .ENVS}}{{range $env := .ENVS}}--env "{{$env}}" {{end}}{{end}} \
\
--workdir /workspace \
{{.IMAGE}} \
{{.CMD}}
_cargo/tool:
desc: Internal wrapper for running cargo tools.
internal: true
silent: true
requires:
vars: [ CMD ]
cmds:
- cmd: mkdir -p "{{.git_root}}/{{.cache_dir}}"
- task: _docker/run
vars:
IMAGE: "ghcr.io/soltihq/rust-ci:{{.rust_version}}{{.image_patch}}"
CMD: "{{.CMD}}"
MOUNT_DIR: "."
VOLUMES:
- "{{.git_root}}/{{.cache_dir}}:/tmp/{{.cache_dir}}"
ENVS:
- "CARGO_TARGET_DIR=/tmp/{{.cache_dir}}/target"
- "CARGO_HOME=/tmp/{{.cache_dir}}/cargo"
- "RUSTUP_TOOLCHAIN={{.rust_version}}"
- "RUSTUP_NO_UPDATE_CHECK=1"
- "CARGO_INCREMENTAL=0"
- "RUSTFLAGS=-D warnings"
# ================================================#
# ----------------------PUBLIC--------------------#
# ================================================#
cargo/fmt:
desc: Run 'cargo fmt'.
silent: true
cmds:
- task: _cargo/tool
vars:
CMD: "fmt --check --verbose"
cargo/check:
desc: Run 'cargo check'.
silent: true
cmds:
- task: _cargo/tool
vars:
CMD: "check"
cargo/clippy:
desc: Run 'cargo clippy'.
silent: true
cmds:
- task: _cargo/tool
vars:
CMD: "clippy --all --all-features -- -D warnings"
cargo/test:
desc: Run 'cargo test'.
silent: true
cmds:
- task: _cargo/tool
vars:
CMD: "test --all --all-features"
cargo/docs:
desc: Run 'rustdoc'.
silent: true
cmds:
- task: _cargo/tool
vars:
CMD: >-
+nightly rustdoc --lib -Zrustdoc-map --features "logging controller"
-Zunstable-options -Zrustdoc-scrape-examples
--config 'build.rustdocflags=["--cfg","docsrs","-Z","unstable-options","--cap-lints","warn"]'
cargo/audit:
desc: Run 'audit'.
silent: true
cmds:
- task: _cargo/tool
vars:
CMD: "audit"
# ================================================#
# ----------------------MANUAL--------------------#
# ================================================#
cargo/audit/fix:
desc: Run 'audit' with auto fix
silent: true
cmds:
- task: _cargo/tool
vars:
CMD: "audit fix"