-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskfile.yml
57 lines (50 loc) · 1.68 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
version: "3"
dotenv: [".env"]
vars:
SOLUTIONS_ROOT: "solutions/"
tasks:
default: task -l
create-*-*:
desc: "create files for a new day eg.: create-2024-01"
vars:
YEAR: "{{index .MATCH 0}}"
DAY: "{{index .MATCH 1}}"
cmds:
- task: session_test
- mkdir -p {{.SOLUTIONS_ROOT}}{{.YEAR}}/{{.DAY}}
- cp skeleton/* {{.SOLUTIONS_ROOT}}{{.YEAR}}/{{.DAY}}
- cmd: git checkout -b day/{{.YEAR}}-{{.DAY}}
ignore_error: true
- |
curl "https://adventofcode.com/{{.YEAR}}/day/`echo {{.DAY}} | sed 's/^0*//'`/input" -H "cookie: session=${AOC_SESSION}" -o "{{.SOLUTIONS_ROOT}}{{.YEAR}}/{{.DAY}}/input.txt" 2>/dev/null
run-*-*-*:
desc: "run specified day and part eg.: run-2024-01-1"
vars:
YEAR: "{{index .MATCH 0}}"
DAY: "{{index .MATCH 1}}"
PART: "{{index .MATCH 2}}"
cmds:
- go run {{.SOLUTIONS_ROOT}}{{.YEAR}}/{{.DAY}}/main.go {{.PART}} {{.SOLUTIONS_ROOT}}{{.YEAR}}/{{.DAY}}/
test-*-*:
desc: "run tests for a specified day eg.: run-2024-01"
vars:
YEAR: "{{index .MATCH 0}}"
DAY: "{{index .MATCH 1}}"
cmds:
- cd {{.SOLUTIONS_ROOT}}{{.YEAR}}/{{.DAY}}; go test
session_test:
desc: "check aoc session cookie"
internal: true
silent: true
cmds:
- |
if [ -z "${AOC_SESSION}" ]; then
echo "AOC_SESSION env variable is unset!"
exit 1
fi
- |
STATUS=`curl -w "%{http_code}" "https://adventofcode.com/2022/day/1/input" -H "cookie: session=${AOC_SESSION}" -o /dev/null 2>/dev/null`
if [[ $STATUS -ne 200 ]]; then
echo "Input file download test failed! - Update session cookie."
exit 1
fi