-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
176 lines (152 loc) · 5.73 KB
/
Taskfile.yml
File metadata and controls
176 lines (152 loc) · 5.73 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
167
168
169
170
171
172
173
174
175
176
version: "3"
vars:
LOCALBIN: '{{default ".bin" .LOCALBIN}}'
VALE: "{{.LOCALBIN}}/vale"
OS:
sh: uname -s | tr '[:upper:]' '[:lower:]'
ARCH:
sh: uname -m | sed 's/x86_64/64-bit/' | sed 's/arm64/ARM64/'
tasks:
# Vale tasks
vale:install:
desc: Download vale binary locally
cmds:
- mkdir -p {{.LOCALBIN}}
- |
if ! test -s {{.VALE}}; then
echo "Downloading vale for {{.OS}}-{{.ARCH}}..."
if [ "{{.OS}}" = "darwin" ]; then
curl -sfL https://github.com/errata-ai/vale/releases/download/v3.1.0/vale_3.1.0_macOS_{{.ARCH}}.tar.gz | tar -xz -C {{.LOCALBIN}} vale
else
curl -sfL https://github.com/errata-ai/vale/releases/download/v3.1.0/vale_3.1.0_Linux_{{.ARCH}}.tar.gz | tar -xz -C {{.LOCALBIN}} vale
fi
fi
status:
- test -s {{.VALE}}
vale:sync:
desc: Download vale packages
deps: [vale:install]
cmds:
- "{{.VALE}} sync"
vale:lint:
desc: Run vale on all documentation
deps: [vale:sync]
cmds:
- |
files=$(rg --files --ignore-file=.valeignore -g "*.md" -g "*.mdx" -g '![A-Z]*.md' canary-checker/docs)
if [ -n "$files" ]; then
{{.VALE}} $files
fi
- |
files=$(rg --files --ignore-file=.valeignore -g "*.md" -g "*.mdx" -g '![A-Z]*.md' mission-control/docs)
if [ -n "$files" ]; then
{{.VALE}} $files
fi
vale:changed:
desc: Run vale on markdown files changed in current branch
deps: [vale:sync]
cmds:
- |
changed_files=$(git diff --name-only main...HEAD | grep -E '\.(md|mdx)$' || true)
allowed_files=$(rg --files --ignore-file=.valeignore -g "*.md" -g "*.mdx" -g '![A-Z]*.md' || true)
files=""
for file in $changed_files; do
if [ -f "$file" ] && echo "$allowed_files" | grep -q "^$file$"; then
files="$files $file"
fi
done
if [ -n "$files" ]; then
echo "Running vale on changed files:$files"
{{.VALE}} $files
else
echo "No markdown/mdx files changed"
fi
# Markdownlint tasks
markdown:lint:
desc: Run markdownlint on all documentation
cmds:
- markdownlint mission-control/docs
- markdownlint canary-checker/docs
# Prettier tasks
fmt:
desc: Format all markdown files with prettier
cmds:
- npx prettier --write "**/*.md" --ignore-path .prettierignore
fmt:check:
desc: Check markdown formatting without making changes
cmds:
- npx prettier --check --log-level=debug "**/*.md" --ignore-path .prettierignore
# File reference validation
check:files:
desc: Check file references in source MDX/MD files
vars:
DOCS_DIRS: '{{default "mission-control/docs canary-checker/docs" .DOCS_DIRS}}'
ROOT_DIR: '{{default "." .ROOT_DIR}}'
cmds:
- |
echo "=== Validating file=<rootDir>/modules references in source docs ==="
echo ""
MISSING_FILES_LIST=$(mktemp)
VALID_FILES_LIST=$(mktemp)
trap "rm -f $MISSING_FILES_LIST $VALID_FILES_LIST" EXIT
TOTAL_REFS=0
VALID_REFS=0
MISSING_REFS=0
# Search for file=<rootDir> references in MDX/MD source files
for docs_dir in {{.DOCS_DIRS}}; do
if [ ! -d "$docs_dir" ]; then
echo "⚠️ Skipping $docs_dir (directory not found)"
continue
fi
echo "Checking $docs_dir/"
# Find all file=<rootDir>/modules references
rg 'file=<rootDir>/modules/[^ ]+' -g '*.{md,mdx}' "$docs_dir" --no-heading --with-filename 2>/dev/null | while IFS=: read -r sourcefile match; do
TOTAL_REFS=$((TOTAL_REFS + 1))
# Extract the file path from the match
filepath=$(echo "$match" | grep -o 'file=<rootDir>/[^ ]*' | sed 's/file=<rootDir>//' | sed 's/[{}].*$//')
# Check if file exists (relative to repository root)
if [ -f "{{.ROOT_DIR}}$filepath" ]; then
echo " ✓ $filepath" >> "$VALID_FILES_LIST"
echo " (in: $sourcefile)" >> "$VALID_FILES_LIST"
VALID_REFS=$((VALID_REFS + 1))
else
echo " ✗ $filepath" >> "$MISSING_FILES_LIST"
echo " (in: $sourcefile)" >> "$MISSING_FILES_LIST"
echo "$filepath|$sourcefile" >> "$MISSING_FILES_LIST"
MISSING_REFS=$((MISSING_REFS + 1))
fi
done
done
echo ""
# Show valid references if any
if [ -s "$VALID_FILES_LIST" ]; then
echo "Valid file references:"
cat "$VALID_FILES_LIST"
echo ""
fi
# Show summary
# Note: Because we're in a subshell loop, counters don't persist
# So we count from the temp files instead
TOTAL_COUNT=$(grep -c "✓\|✗" "$VALID_FILES_LIST" "$MISSING_FILES_LIST" 2>/dev/null || echo "0")
VALID_COUNT=$(grep -c "✓" "$VALID_FILES_LIST" 2>/dev/null || echo "0")
MISSING_COUNT=$(grep -c "✗" "$MISSING_FILES_LIST" 2>/dev/null || echo "0")
echo "Summary: Found $TOTAL_COUNT file reference(s)"
echo " ✓ Valid: $VALID_COUNT"
echo " ✗ Missing: $MISSING_COUNT"
echo ""
# Check for missing files
if [ "$MISSING_COUNT" -gt 0 ]; then
echo "ERROR: Missing file references:"
cat "$MISSING_FILES_LIST"
echo ""
echo "ERROR: Found $MISSING_COUNT missing file reference(s)"
exit 1
fi
echo "✓ All file references are valid"
# Meta tasks
lint:
desc: Run all linting (vale + markdownlint)
deps: [vale:lint, markdown:lint]
check:
desc: Run all checks (lint + formatting + file references)
deps: [lint, fmt:check, check:files]