-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTaskfile.yml
157 lines (147 loc) · 4.43 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
version: "3"
vars:
# Paths
BUILD_DIR: "{{.TASKFILE_DIR}}/build"
DOCS_OUTPUT_DIR: "{{.BUILD_DIR}}/html"
NODE_DEPS_DIR: "{{.BUILD_DIR}}/node"
VENV_DIR: "{{.BUILD_DIR}}/venv"
# Other variables
CHECKSUM_TAR_BASE_ARGS: >-
--group=0
--mtime='UTC 1970-01-01'
--numeric-owner
--owner=0
--sort=name
tasks:
default:
deps: ["docs"]
clean:
cmds:
- "rm -rf '{{.BUILD_DIR}}'"
docs:
deps: ["venv"]
vars:
CHECKSUM_FILE: "{{.BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "{{.DOCS_OUTPUT_DIR}}"
cmds:
- |
. "{{.VENV_DIR}}/bin/activate"
sphinx-build -a -E -c docs -b html docs "{{.OUTPUT_DIR}}"
# Checksum the generated files (this command must be last)
- >-
tar cf - --directory "{{.OUTPUT_DIR}}" {{.CHECKSUM_TAR_BASE_ARGS}} .
| md5sum > "{{.CHECKSUM_FILE}}"
sources:
- "docs/**/*"
- "{{.BUILD_DIR}}/venv.md5"
status:
- "test -f '{{.CHECKSUM_FILE}}'"
- >-
diff
<(tar cf - --directory "{{.OUTPUT_DIR}}" {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum)
"{{.CHECKSUM_FILE}}"
download-projects:
deps: ["venv"]
cmds:
- |-
. "{{.VENV_DIR}}/bin/activate"
python3 scripts/download-projects.py --build-dir "{{.BUILD_DIR}}"
release-tar:
deps: ["docs"]
vars:
OUTPUT_DIR_NAME: "yscope-docs-release"
OUTPUT_DIR: "{{.BUILD_DIR}}/{{.OUTPUT_DIR_NAME}}"
SITE_PUBLIC_DIR: "{{.OUTPUT_DIR}}/public"
cmds:
- "rm -rf '{{.OUTPUT_DIR}}'"
- "mkdir -p '{{.OUTPUT_DIR}}'"
- >-
rsync
--archive
--relative
conf/projects.json
server/.env
server/src
server/package.json
server/package-lock.json
server/README.md
"{{.OUTPUT_DIR}}"
- "mkdir '{{.SITE_PUBLIC_DIR}}'"
- "rsync -a '{{.BUILD_DIR}}/html' {{.SITE_PUBLIC_DIR}}"
- |-
cd "{{.BUILD_DIR}}"
find -type d -regex ".*/build/docs/html" -exec \
rsync \
--archive \
--relative \
{} \
"{{.SITE_PUBLIC_DIR}}" \
\;
- >-
tar czf "{{.BUILD_DIR}}/{{.OUTPUT_DIR_NAME}}.tar.gz" --directory "{{.OUTPUT_DIR}}/.."
"{{.OUTPUT_DIR_NAME}}"
serve:
dir: "server"
deps:
- "docs"
- "server"
cmds:
- "PUBLIC_DIR='{{.BUILD_DIR}}' npm run dev"
server:
internal: true
dir: "server"
vars:
CHECKSUM_FILE: "{{.BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "node_modules"
cmds:
- "rm -rf '{{.OUTPUT_DIR}}'"
- "npm install"
# Checksum the generated files (this command must be last)
- >-
tar cf - --directory "{{.OUTPUT_DIR}}" {{.CHECKSUM_TAR_BASE_ARGS}} .
| md5sum > "{{.CHECKSUM_FILE}}"
sources:
- "{{.TASKFILE}}"
- "package.json"
status:
- "test -f '{{.CHECKSUM_FILE}}'"
- >-
diff
<(tar cf - --directory "{{.OUTPUT_DIR}}" {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum)
"{{.CHECKSUM_FILE}}"
venv:
internal: true
vars:
CHECKSUM_FILE: "{{.BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "{{.VENV_DIR}}"
cmds:
- "rm -rf '{{.OUTPUT_DIR}}'"
- "python3 -m venv '{{.OUTPUT_DIR}}'"
# Remove calls to `hash` from the venv activation script since Task uses `gosh` rather than
# `bash`.
# NOTE: Older versions of Python's venv would only call `hash` if they detected the running
# shell was one that had the command, but that's not the case in newer versions.
- |-
# NOTE:
# 1. We can't use `sed -i` since `-i` has different syntax on Linux and macOS
# 2. We can't use `--regexp` instead of `-E` since `--regexp` is not supported on macOS
src="{{.OUTPUT_DIR}}/bin/activate"
dst="{{.OUTPUT_DIR}}/bin/activate.tmp"
sed -E 's/^([[:space:]]*)hash[[:space:]]+.*/\1true/g' "${src}" > "${dst}"
mv "${dst}" "${src}"
- |-
. "{{.OUTPUT_DIR}}/bin/activate"
pip3 install --upgrade -r requirements.txt
# Checksum the generated files (this command must be last)
- >-
tar cf - --directory "{{.OUTPUT_DIR}}" {{.CHECKSUM_TAR_BASE_ARGS}} .
| md5sum > "{{.CHECKSUM_FILE}}"
sources:
- "{{.TASKFILE}}"
- "requirements.txt"
status:
- "test -f '{{.CHECKSUM_FILE}}'"
- >-
diff
<(tar cf - --directory "{{.OUTPUT_DIR}}" {{.CHECKSUM_TAR_BASE_ARGS}} . | md5sum)
"{{.CHECKSUM_FILE}}"