bigpowers 2.7.5 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,308 @@
1
+ ---
2
+ name: wire-ci
3
+ description: "CI pipeline setup with pre-built templates and local validation. Generates GitHub Actions workflows, validates YAML syntax and permissions, supports dry-run via act/gh. The CI equivalent of wire-observability."
4
+ model: sonnet
5
+ ---
6
+
7
+ # Wire CI
8
+
9
+ > **HARD GATE** — Do not ship a project without CI. Run this skill before first merge to main or when adding CI to an existing project.
10
+ >
11
+ > **HARD GATE** — CI that is untestable locally will break every cycle. Always run `--validate` after generating workflows and `--dry-run` before pushing.
12
+
13
+ Generate, validate, and test CI workflows. Detects your project type, produces platform-appropriate GitHub Actions configurations, and provides local verification to catch auth, permissions, and syntax issues before they reach CI.
14
+
15
+ ## What this sets up
16
+
17
+ 1. **CI workflow** — `.github/workflows/ci.yaml` with test, lint, typecheck, build steps
18
+ 2. **Release workflow** — `.github/workflows/release.yaml` with semantic-release (if applicable)
19
+ 3. **`--validate` mode** — checks YAML syntax, workflow permissions, required secrets, and common pitfalls
20
+ 4. **`--dry-run` mode** — runs workflows locally via `act` or `gh workflow run` to prove correctness before push
21
+ 5. **Failure pattern documentation** — common CI failure categories and their fixes
22
+
23
+ ## Process
24
+
25
+ ### 1. Detect project type
26
+
27
+ Read the project root for manifest files to determine which template to use:
28
+
29
+ | Manifest | Type | Template |
30
+ |----------|------|----------|
31
+ | `Cargo.toml` | Rust | Rust CI: test, clippy, fmt, build |
32
+ | `package.json` | Node | Node CI: test, lint, typecheck, build |
33
+ | `setup.py` / `pyproject.toml` | Python | Python CI: pytest, ruff/mypy/flake8, build |
34
+ | `go.mod` | Go | Go CI: test, vet, staticcheck, build |
35
+ | `CMakeLists.txt` | C/C++ | C/C++ CI: cmake build, ctest |
36
+ | Multiple detected | Polyglot | Combined workflows or error if ambiguous |
37
+
38
+ If no manifest is found, prompt the user to specify the type or pass `--type <rust|node|python|go|cpp>`.
39
+
40
+ ### 2. Generate CI workflow
41
+
42
+ Create `.github/workflows/ci.yaml` with standard steps derived from the project type and its manifest:
43
+
44
+ **Rust template (`Cargo.toml`):**
45
+ ```yaml
46
+ name: CI
47
+ on: [push, pull_request]
48
+ jobs:
49
+ test:
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+ - uses: actions-rust/toolchain@v1
54
+ with:
55
+ toolchain: stable
56
+ components: clippy, rustfmt
57
+ - run: cargo fmt --all -- --check
58
+ - run: cargo clippy -- -D warnings
59
+ - run: cargo test
60
+ - run: cargo build --release
61
+ ```
62
+
63
+ **Node template (`package.json`):**
64
+ ```yaml
65
+ name: CI
66
+ on: [push, pull_request]
67
+ jobs:
68
+ test:
69
+ runs-on: ubuntu-latest
70
+ steps:
71
+ - uses: actions/checkout@v4
72
+ - uses: actions/setup-node@v4
73
+ with:
74
+ node-version: 20
75
+ cache: npm
76
+ - run: npm ci
77
+ - run: npm test
78
+ - run: npm run lint 2>/dev/null || true
79
+ - run: npm run typecheck 2>/dev/null || true
80
+ - run: npm run build 2>/dev/null || true
81
+ ```
82
+
83
+ **Python template (`setup.py` / `pyproject.toml`):**
84
+ ```yaml
85
+ name: CI
86
+ on: [push, pull_request]
87
+ jobs:
88
+ test:
89
+ runs-on: ubuntu-latest
90
+ steps:
91
+ - uses: actions/checkout@v4
92
+ - uses: actions/setup-python@v5
93
+ with:
94
+ python-version: "3.12"
95
+ cache: pip
96
+ - run: pip install -e ".[dev]" || pip install -e .
97
+ - run: pip install pytest ruff mypy
98
+ - run: ruff check .
99
+ - run: mypy . 2>/dev/null || true
100
+ - run: pytest
101
+ ```
102
+
103
+ **Go template (`go.mod`):**
104
+ ```yaml
105
+ name: CI
106
+ on: [push, pull_request]
107
+ jobs:
108
+ test:
109
+ runs-on: ubuntu-latest
110
+ steps:
111
+ - uses: actions/checkout@v4
112
+ - uses: actions/setup-go@v5
113
+ with:
114
+ go-version: stable
115
+ cache: true
116
+ - run: go vet ./...
117
+ - run: go test ./...
118
+ - run: go build ./...
119
+ ```
120
+
121
+ **C/C++ template (`CMakeLists.txt`):**
122
+ ```yaml
123
+ name: CI
124
+ on: [push, pull_request]
125
+ jobs:
126
+ test:
127
+ runs-on: ubuntu-latest
128
+ steps:
129
+ - uses: actions/checkout@v4
130
+ - run: cmake -B build
131
+ - run: cmake --build build
132
+ - run: ctest --test-dir build
133
+ ```
134
+
135
+ ### 3. Generate release workflow (if semantic-release detected)
136
+
137
+ If the project has semantic-release configured (in `package.json`, `.releaserc`, or `release.config.js`), also generate `.github/workflows/release.yaml`:
138
+
139
+ ```yaml
140
+ name: Release
141
+ on:
142
+ push:
143
+ branches: [main]
144
+ jobs:
145
+ release:
146
+ runs-on: ubuntu-latest
147
+ permissions:
148
+ contents: write
149
+ issues: write
150
+ pull-requests: write
151
+ id-token: write
152
+ steps:
153
+ - uses: actions/checkout@v4
154
+ with:
155
+ fetch-depth: 0
156
+ - uses: actions/setup-node@v4
157
+ with:
158
+ node-version: 20
159
+ cache: npm
160
+ - run: npm ci
161
+ - run: npm run build 2>/dev/null || true
162
+ - run: npx semantic-release
163
+ env:
164
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
165
+ NPM_TOKEN: \${{ secrets.NPM_TOKEN }}
166
+ ```
167
+
168
+ > **NPM_TOKEN is required** for publishing to npm. Without it, semantic-release will fail at the publish step. See `--validate` to check this.
169
+
170
+ ### 4. Validate workflows (`--validate`)
171
+
172
+ Run `wire-ci --validate` to check all generated workflow files:
173
+
174
+ ```bash
175
+ # Validate YAML syntax
176
+ for f in .github/workflows/*.yaml; do
177
+ python3 -c "import yaml; yaml.safe_load(open('$f'))" || echo "FAIL: $f has YAML syntax errors"
178
+ done
179
+
180
+ # Check permissions block presence
181
+ for f in .github/workflows/*.yaml; do
182
+ if grep -q "permissions:" "$f"; then
183
+ echo "OK: $f has permissions block"
184
+ else
185
+ echo "WARNING: $f missing permissions block — add one for security"
186
+ fi
187
+ done
188
+
189
+ # Check for npm publish without NPM_TOKEN
190
+ for f in .github/workflows/*.yaml; do
191
+ if grep -q "npm publish\|npx semantic-release" "$f"; then
192
+ if ! grep -q "NPM_TOKEN" "$f"; then
193
+ echo "WARNING: $f has npm publish/semantic-release but no NPM_TOKEN secret"
194
+ fi
195
+ fi
196
+ done
197
+
198
+ # Check for hardcoded Node versions
199
+ for f in .github/workflows/*.yaml; do
200
+ if grep -q "node-version: [0-9]" "$f" && grep -qv "node-version-file\|\.nvmrc" "$f"; then
201
+ echo "NOTE: $f has hardcoded Node version — consider using .nvmrc instead"
202
+ fi
203
+ done
204
+
205
+ # Check for common secrets reference errors
206
+ for f in .github/workflows/*.yaml; do
207
+ # Secrets referencing something that doesn't exist in the workflow
208
+ grep -oP 'secrets\.\w+' "$f" | sort -u | while read -r secret; do
209
+ echo "REF: $f references $secret"
210
+ done
211
+ done
212
+ ```
213
+
214
+ **Exit codes:**
215
+ - `0` — all checks pass (no errors)
216
+ - `1` — YAML syntax errors found
217
+ - `2` — validation warnings only (missing permissions, secrets, etc.)
218
+
219
+ ### 5. Dry-run workflows (`--dry-run`)
220
+
221
+ Attempt to run the generated workflows locally to catch errors before push:
222
+
223
+ ```bash
224
+ # Option A: Use act (recommended)
225
+ if command -v act &>/dev/null; then
226
+ act push --dry-run
227
+ echo "OK: act dry-run completed"
228
+ elif command -v gh &>/dev/null; then
229
+ # Option B: Use gh workflow run (remote test, no local docker)
230
+ gh workflow run ci.yaml --ref "$(git branch --show-current)"
231
+ echo "OK: CI workflow dispatched. Check status: gh run list"
232
+ else
233
+ echo "NOTE: Install act (https://github.com/nektos/act) for full local dry-run"
234
+ echo " Install gh CLI for remote dry-run"
235
+ fi
236
+ ```
237
+
238
+ > **act** runs workflows in a local Docker environment — the most accurate pre-push validation.
239
+ > **gh workflow run** sends the workflow to GitHub but doesn't execute locally — useful for checking YAML parsing but not for testing the actual steps.
240
+
241
+ ### 6. Document common CI failure patterns
242
+
243
+ Add the following to the project's documentation or CLAUDE.md after setup:
244
+
245
+ | Failure | Cause | Fix |
246
+ |---------|-------|-----|
247
+ | `npm publish` fails | `NPM_TOKEN` not set as repo secret | Add `NPM_TOKEN` to GitHub repo secrets |
248
+ | `semantic-release` fails on push | Missing `permissions: contents: write` | Add `permissions: contents: write` to release job |
249
+ | `cargo publish` auth fail | `CARGO_REGISTRY_TOKEN` not set | Add token to `~/.cargo/config.toml` or env |
250
+ | `go vet` fails | Go version mismatch | Match `go.mod` `go` directive with setup-go version |
251
+ | `cargo clippy` errors | New lints in Rust nightly | `cargo clippy --fix` or allow specific lints |
252
+ | `act` not found | Docker not running or act not installed | `brew install act` / `docker ps` to verify Docker |
253
+ | Hardcoded Node version stale | `.nvmrc` exists but workflow uses hardcoded version | Use `node-version-file: .nvmrc` instead |
254
+
255
+ ## Examples
256
+
257
+ ### Create CI for a Rust project
258
+
259
+ ```bash
260
+ # Detect from Cargo.toml, generate workflows
261
+ wire-ci
262
+
263
+ # Validate generated workflows
264
+ wire-ci --validate
265
+
266
+ # Run locally with act
267
+ wire-ci --dry-run
268
+ ```
269
+
270
+ ### Create CI for a Node project with semantic-release
271
+
272
+ ```bash
273
+ wire-ci
274
+ wire-ci --validate
275
+ # Expect warning: "npm publish step found but no NPM_TOKEN in secrets"
276
+ # Fix: add NPM_TOKEN to repo secrets
277
+ ```
278
+
279
+ ### Validate existing workflows (no generation)
280
+
281
+ ```bash
282
+ wire-ci --validate --check-only
283
+ ```
284
+
285
+ ## Options
286
+
287
+ | Flag | Description |
288
+ |------|-------------|
289
+ | `--validate` | Check YAML syntax, permissions, secrets, common pitfalls |
290
+ | `--dry-run` | Run workflows locally via `act` or dispatch via `gh` |
291
+ | `--check-only` | Only validate, do not generate new files |
292
+ | `--type <type>` | Force project type (skip auto-detection) |
293
+ | `--force` | Overwrite existing workflow files |
294
+ | `--no-release` | Skip release workflow generation even if semantic-release detected |
295
+
296
+ ## Integration with build-epic
297
+
298
+ When `wire-ci` is used as part of `build-epic`:
299
+
300
+ 1. **During develop-tdd**: If the task modifies `.github/workflows/`, run `wire-ci --validate` as a CI dry-run sub-step
301
+ 2. **During release-branch**: After push, run `gh run list --limit 1 --branch main --json status,conclusion` to verify CI passes
302
+
303
+ ## Verify
304
+
305
+ → verify: `test -f wire-ci/SKILL.md && echo "OK: skill file exists" || echo "FAIL: no skill file"`
306
+ → verify: `grep -q "name: wire-ci" wire-ci/SKILL.md && echo "OK: frontmatter" || echo "FAIL: frontmatter"`
307
+ → verify: `grep -ci "template\|workflow\|validate\|dry.run" wire-ci/SKILL.md | awk '{if($1>=3) print "OK: semantics"; else print "FAIL: missing"}'`
308
+ → verify: `grep -q "wire-ci" SKILL-INDEX.md && echo "OK: in SKILL-INDEX" || echo "FAIL: not indexed"`