-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTaskfile.yml
More file actions
166 lines (156 loc) · 6.05 KB
/
Taskfile.yml
File metadata and controls
166 lines (156 loc) · 6.05 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
version: "3"
silent: true
vars:
RUNWHEN_HOME: /home/runwhen
CODECOLLECTION_DIR: "{{.RUNWHEN_HOME}}/codecollection"
SKILLS_SRC: "{{.TASKFILE_DIR}}/skills"
DEFAULT_REPO: runwhen-contrib/rw-cli-codecollection
DEFAULT_BRANCH: main
tasks:
setup:
desc: Bootstrap a codecollection into this environment
summary: |
Clone a codecollection repo, install its deps, and optionally check out a PR.
Examples:
task setup # defaults (rw-cli-codecollection, main)
task setup REPO=runwhen-contrib/rw-cli-codecollection PR=42 # specific PR
task setup REPO=runwhen-contrib/azure-c7n-codecollection BRANCH=feat/foo
vars:
REPO: '{{.REPO | default .DEFAULT_REPO}}'
BRANCH: '{{.BRANCH | default .DEFAULT_BRANCH}}'
PR: '{{.PR | default ""}}'
REPO_URL: '{{if or (hasPrefix "http" .REPO) (hasPrefix "git@" .REPO)}}{{.REPO}}{{else}}https://github.com/{{.REPO}}.git{{end}}'
cmds:
- |
echo ""
echo "╔══════════════════════════════════════╗"
echo "║ CodeCollection DevTools Setup ║"
echo "╚══════════════════════════════════════╝"
echo ""
echo " Repo {{.REPO_URL}}"
echo " Branch {{.BRANCH}}"
echo " PR {{if .PR}}#{{.PR}}{{else}}none{{end}}"
echo ""
- task: clone
vars: { REPO_URL: "{{.REPO_URL}}", BRANCH: "{{.BRANCH}}" }
- task: checkout-pr
vars: { PR: "{{.PR}}" }
- task: install-deps
- task: install-skills
- task: verify
clone:
desc: Clone or update the codecollection repo
internal: true
vars:
REPO_URL: '{{.REPO_URL}}'
BRANCH: '{{.BRANCH}}'
cmds:
- |
if [ -d "{{.CODECOLLECTION_DIR}}/.git" ]; then
echo "→ Updating existing clone..."
git -C "{{.CODECOLLECTION_DIR}}" fetch --all --prune -q 2>&1 | tail -5 || true
git -C "{{.CODECOLLECTION_DIR}}" checkout "{{.BRANCH}}" -q
git -C "{{.CODECOLLECTION_DIR}}" pull --ff-only -q || true
else
rm -rf "{{.CODECOLLECTION_DIR}}"
echo "→ Cloning {{.REPO_URL}}..."
git clone --branch "{{.BRANCH}}" --progress "{{.REPO_URL}}" "{{.CODECOLLECTION_DIR}}" 2>&1 \
| tail -3
fi
- |
LINK="{{.TASKFILE_DIR}}/codecollection"
if [ "$(readlink -f "$LINK" 2>/dev/null)" = "$(readlink -f "{{.CODECOLLECTION_DIR}}")" ]; then
:
else
rm -f "$LINK"
ln -s "{{.CODECOLLECTION_DIR}}" "$LINK"
echo "→ Symlinked ./codecollection → {{.CODECOLLECTION_DIR}}"
fi
checkout-pr:
desc: Check out a PR branch
internal: true
vars:
PR: '{{.PR}}'
status:
- test -z "{{.PR}}"
cmds:
- |
echo "→ Checking out PR #{{.PR}}..."
cd "{{.CODECOLLECTION_DIR}}" && gh pr checkout "{{.PR}}" 2>&1 | grep -v '^Already on' || true
echo " Branch: $(git -C {{.CODECOLLECTION_DIR}} branch --show-current)"
install-deps:
desc: Install codecollection Python dependencies
internal: true
sources:
- "{{.CODECOLLECTION_DIR}}/requirements.txt"
cmds:
- |
if [ -f "{{.CODECOLLECTION_DIR}}/requirements.txt" ]; then
echo "→ Installing Python dependencies..."
_out=$(pip install --user --no-cache-dir -r "{{.CODECOLLECTION_DIR}}/requirements.txt" 2>&1) || {
echo "$_out"
exit 1
}
echo "$_out" | grep -c '^Successfully installed' >/dev/null 2>&1 \
&& echo " $(echo "$_out" | grep '^Successfully installed')" || true
fi
- mkdir -p "{{.RUNWHEN_HOME}}/auth"
install-skills:
desc: Install CodeBundle authoring skills as Cursor rules
cmds:
- |
if [ ! -d "{{.SKILLS_SRC}}" ]; then
echo "→ Skills directory not found, skipping."
exit 0
fi
RULES_DIR="{{.TASKFILE_DIR}}/.cursor/rules"
mkdir -p "$RULES_DIR"
count=0
for skill in "{{.SKILLS_SRC}}"/*.md; do
[ -f "$skill" ] || continue
base=$(basename "$skill" .md)
cp "$skill" "$RULES_DIR/${base}.mdc"
count=$((count + 1))
done
if [ ! -f "$RULES_DIR/.gitignore" ]; then
printf '# Injected by codecollection-devtools -- do not commit\n*.mdc\n' > "$RULES_DIR/.gitignore"
fi
echo "→ Installed ${count} Cursor rules to .cursor/rules/"
verify:
desc: Check that key tools are available
cmds:
- |
echo ""
echo "╔══════════════════════════════════════╗"
echo "║ Environment Ready ║"
echo "╚══════════════════════════════════════╝"
echo ""
check() {
local name="$1"
if command -v "$name" >/dev/null 2>&1; then
printf " ✓ %-10s %s\n" "$name" "$(command -v "$name")"
else
printf " ✗ %-10s %s\n" "$name" "MISSING"
fi
}
check ro
check robot
check kubectl
check gh
printf " ✓ %-10s %s\n" "python" "$(python --version 2>&1)"
echo ""
echo " Codecollection: ./codecollection → {{.CODECOLLECTION_DIR}}"
echo ""
echo " Get started:"
echo " cd codecollection/codebundles/<name> && ro"
echo ""
echo " Note: git commits inside ./codecollection go to the"
echo " codecollection repo, not this devtools repo."
echo ""
clean:
desc: Remove the cloned codecollection (start fresh)
prompt: This will delete {{.CODECOLLECTION_DIR}}. Continue?
cmds:
- rm -f "{{.TASKFILE_DIR}}/codecollection"
- rm -rf "{{.CODECOLLECTION_DIR}}"
- echo "Cleaned. Run 'task setup REPO=... ' to start again."