-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTaskfile.yaml
92 lines (81 loc) · 2.76 KB
/
Taskfile.yaml
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
# https://taskfile.dev
---
version: '3'
vars:
TEMPLATE_REVISION:
sh: git rev-parse HEAD
tasks:
default:
summary: |
Just a list of documented tasks.
silent: true
cmds:
- task --list
clean:
desc: clean up working directory
cmds:
- rm -rf *_dir
create:
desc: create a project with the current version and ask for answers
deps:
- clean
cmds:
- copier copy --vcs-ref {{.TEMPLATE_REVISION}} . new_dir
check:generate:case:
desc: generate a project with the current version from a TEST_CASE
preconditions:
- sh: "[[ -v TEST_CASE ]]"
msg: >
Environment needs 'TEST_CASE' variable.
See tests directory - all yaml files without suffix are test cases.
- sh: "[ -f tests/${TEST_CASE}.yml ]"
msg: Test case file ${TEST_CASE}.yml does not exist.
cmds:
- rm -rf {{.TEST_CASE}}_dir
- mkdir {{.TEST_CASE}}_dir
- cp tests/{{.TEST_CASE}}.yml {{.TEST_CASE}}_dir/.copier-answers.yml
- copier copy --vcs-ref {{.TEMPLATE_REVISION}} --defaults . {{.TEST_CASE}}_dir
- git config --global init.defaultBranch develop
- cd {{.TEST_CASE}}_dir && git init .
- cd {{.TEST_CASE}}_dir && git add .
- cd {{.TEST_CASE}}_dir && git config init.defaultBranch main
- cd {{.TEST_CASE}}_dir && git config user.name "Anonymous Person"
- cd {{.TEST_CASE}}_dir && git config user.email "[email protected]"
- cd {{.TEST_CASE}}_dir && git commit -m "init from template"
check:generate:cases:
desc: generate all test cases with the current template version
deps:
- clean
vars:
TEST_CASES:
sh: find tests -type f -name '*.yml' | sed 's/^tests\///g' | sed 's/\.yml$//g'
cmds:
- for: { var: TEST_CASES }
cmd: TEST_CASE={{.ITEM}} task check:generate:case
check:validate:case:
desc: validate a project test case
preconditions:
- sh: "[[ -v TEST_CASE ]]"
msg: >
Environment needs 'TEST_CASE' variable.
See tests directory - all yaml files without suffix are test cases.
- sh: "[ -d ${TEST_CASE}_dir ]"
msg: >
Test case directory ${TEST_CASE}.yml does not exist.
Please use check:generate* tasks to create directories.
cmds:
- cd {{.TEST_CASE}}_dir && poetry update
- cd {{.TEST_CASE}}_dir && task check
check:validate:cases:
desc: validate all test cases
vars:
TEST_CASES:
sh: find tests -type f -name '*.yml' | sed 's/^tests\///g' | sed 's/\.yml$//g'
cmds:
- for: { var: TEST_CASES }
cmd: TEST_CASE={{.ITEM}} task check:validate:case
check:
desc: First generate, the validate all test cases
cmds:
- task: check:generate:cases
- task: check:validate:cases