Repository navigation
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
118 lines (105 loc) · 4 KB
/
Copy pathTaskfile.yaml
File metadata and controls
118 lines (105 loc) · 4 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
# 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 "anonymous@example.org"
- 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:
- task: check:hook:case
vars: {TEST_CASE: '{{.TEST_CASE}}'}
- cd {{.TEST_CASE}}_dir && poetry update
- cd {{.TEST_CASE}}_dir && task check
check:hook:case:
desc: smoke test the Stop hook a generated project ships
summary: |
Nothing else here ever executes the shipped agent files, and this one is
a blocking Stop hook: if it spoke when it should not, or ignored the
loop guard, every session in every generated project would stop being
able to end. Both cases are asserted against a freshly generated, clean
working tree.
This cannot tell you the hook fires on the right evidence. That is still
a hand run in a rendered case - see CLAUDE.md.
internal: true
cmds:
- >
cd {{.TEST_CASE}}_dir &&
out=$(printf '%s' '{"hook_event_name":"Stop","session_id":"smoke-{{.TEST_CASE}}-quiet","stop_hook_active":false}'
| python3 .claude/hooks/template-feedback.py) &&
{ [ -z "$out" ] || { echo "hook spoke on a clean tree: $out"; exit 1; }; }
- >
cd {{.TEST_CASE}}_dir &&
out=$(printf '%s' '{"hook_event_name":"Stop","session_id":"smoke-{{.TEST_CASE}}-loop","stop_hook_active":true}'
| python3 .claude/hooks/template-feedback.py) &&
{ [ -z "$out" ] || { echo "hook ignored stop_hook_active: $out"; exit 1; }; }
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