Skip to content

Commit de9580c

Browse files
committed
chore: add agent skills
1 parent 59ea97e commit de9580c

5 files changed

Lines changed: 2729 additions & 0 deletions

File tree

Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
# Skill: YASGUI Build-Test Workflow
2+
3+
## Description
4+
Automates the critical build-before-test workflow for YASGUI. This skill ensures tests are run with valid build output and selects the appropriate test command based on the environment and code changes.
5+
6+
## When to Use
7+
- User wants to run tests
8+
- User mentions test failures related to missing build output
9+
- User asks to "test my changes" or "run tests"
10+
- Before any test execution command
11+
- When CI/CD workflow questions arise
12+
13+
## Problem Statement
14+
YASGUI has a **mandatory build-before-test requirement**. Running tests without building first will fail with:
15+
```
16+
Run "npm run build" before running a test
17+
```
18+
19+
Additionally:
20+
- **Puppeteer tests** require Chrome and AppArmor configuration on Linux
21+
- **Unit tests** can run without Chrome
22+
- Build must complete successfully (~5 seconds)
23+
- Build output goes to `build/` directory (gitignored)
24+
25+
## Required Inputs
26+
- Current workspace state
27+
- Whether code changes affect UI/E2E scenarios
28+
- Operating system (for AppArmor warnings)
29+
30+
## Instructions
31+
32+
### Step 1: Check Build Status
33+
1. Check if `build/` directory exists and has content
34+
2. Check timestamps: if source files are newer than build output, rebuild is needed
35+
3. Look for these key build artifacts:
36+
- `build/yasgui.min.js`
37+
- `build/yasqe.min.js`
38+
- `build/yasr.min.js`
39+
- `build/utils.min.js`
40+
41+
### Step 2: Determine if Build is Needed
42+
Build is required if:
43+
- `build/` directory is missing
44+
- `build/` directory is empty
45+
- Source files have been modified since last build
46+
- User explicitly requests a full test run
47+
- This is a fresh clone of the repository
48+
49+
### Step 3: Run Build (if needed)
50+
Execute the build command:
51+
```bash
52+
npm run build
53+
```
54+
55+
**Expected output:**
56+
- "✓ Build complete!" message
57+
- Completes in ~5-10 seconds
58+
- Creates/updates files in `build/` directory
59+
60+
**If build fails:**
61+
- Check for TypeScript errors (some are expected from dependencies)
62+
- Check for esbuild errors (these are critical)
63+
- Verify all packages have dependencies installed
64+
65+
### Step 4: Select Appropriate Test Command
66+
67+
#### Option A: Unit Tests Only (Recommended for most cases)
68+
```bash
69+
npm run unit-test
70+
```
71+
- **Use when:** Testing logic, utilities, backend code
72+
- **Pros:** Fast, works without Chrome, no AppArmor issues
73+
- **Tests:** Files in `test/unit/*-test.ts`
74+
75+
#### Option B: Puppeteer E2E Tests Only
76+
```bash
77+
npm run puppeteer-test
78+
```
79+
- **Use when:** Testing UI, browser interactions, visual features
80+
- **Requires:** Chrome installed, AppArmor configured (Linux)
81+
- **Tests:** `test/run.ts` (main E2E test suite)
82+
- **Timeout:** 30 seconds per test
83+
84+
#### Option C: Full Test Suite
85+
```bash
86+
npm test
87+
```
88+
- **Use when:** Pre-commit, final validation, CI emulation
89+
- **Runs:** Both puppeteer and unit tests
90+
- **Time:** Longer execution (~30-60 seconds)
91+
92+
### Step 5: Handle Test Execution
93+
94+
**Before running tests:**
95+
1. Ensure build directory exists and is populated
96+
2. Provide context on what's being tested
97+
3. Warn about Chrome requirements if running puppeteer tests
98+
99+
**During test execution:**
100+
- Monitor for timeout errors (increase if needed with `--timeout` flag)
101+
- Watch for AppArmor errors on Linux
102+
103+
**After test execution:**
104+
- Report pass/fail status
105+
- If failures occur, analyze error messages
106+
- Suggest fixes based on error patterns
107+
108+
### Step 6: Handle Common Issues
109+
110+
#### Issue: Puppeteer Chrome Not Found
111+
**Solution:**
112+
```bash
113+
# Run unit tests only
114+
npm run unit-test
115+
116+
# OR install Chrome and disable AppArmor (Linux only)
117+
echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
118+
```
119+
120+
#### Issue: Build Fails with TypeScript Errors
121+
**Solution:**
122+
- Check if errors are in dependencies (expected, can be ignored)
123+
- Check if errors are in source code (must fix)
124+
- Run `npm run util:validateTs` for type-checking only
125+
126+
#### Issue: "No files matching packages/*/test/**/*.{ts,tsx}"
127+
**Solution:**
128+
- This is **expected** and **not an error**
129+
- Tests are in root `test/` directory, not per-package
130+
- ESLint message is informational only
131+
132+
## Decision Tree
133+
134+
```
135+
START
136+
137+
Does build/ exist with content?
138+
├─ NO → Run `npm run build`
139+
└─ YES → Check timestamps
140+
141+
Are source files newer than build?
142+
├─ YES → Run `npm run build`
143+
└─ NO → Skip build
144+
145+
What type of changes were made?
146+
├─ UI/Frontend → Recommend `npm run puppeteer-test`
147+
│ (warn about Chrome requirement)
148+
├─ Logic/Utils → Recommend `npm run unit-test`
149+
└─ Unknown → Recommend `npm run unit-test` (safer default)
150+
151+
Execute selected test command
152+
153+
Tests pass?
154+
├─ YES → Report success
155+
└─ NO → Analyze errors and suggest fixes
156+
```
157+
158+
## Examples
159+
160+
### Example 1: Fresh Clone
161+
```bash
162+
# User just cloned repo
163+
# Skill detects: build/ doesn't exist
164+
165+
# Action: Build first
166+
npm run build
167+
168+
# Then: Run appropriate tests
169+
npm run unit-test
170+
```
171+
172+
### Example 2: After Code Changes
173+
```bash
174+
# User modified packages/yasgui/src/Tab.ts
175+
# Skill detects: source newer than build
176+
177+
# Action: Rebuild
178+
npm run build
179+
180+
# Then: Run unit tests (logic change)
181+
npm run unit-test
182+
```
183+
184+
### Example 3: UI Feature Testing
185+
```bash
186+
# User added new theme toggle button
187+
# Skill detects: UI change requires E2E tests
188+
189+
# Action: Build first
190+
npm run build
191+
192+
# Then: Run puppeteer tests
193+
# Warning: Requires Chrome
194+
npm run puppeteer-test
195+
```
196+
197+
### Example 4: Pre-commit Validation
198+
```bash
199+
# User ready to commit
200+
# Skill suggests: Full validation
201+
202+
# Action: Build
203+
npm run build
204+
205+
# Then: Run all tests
206+
npm test
207+
```
208+
209+
## Output Format
210+
211+
When executing this skill, provide:
212+
213+
1. **Status Check:**
214+
```
215+
✓ Build directory exists
216+
⚠ Source files modified since last build
217+
```
218+
219+
2. **Action Plan:**
220+
```
221+
Building project...
222+
Running unit tests (logic changes detected)...
223+
```
224+
225+
3. **Results Summary:**
226+
```
227+
✓ Build completed in 5.2s
228+
✓ 15 unit tests passed
229+
```
230+
231+
4. **If Issues Found:**
232+
```
233+
⚠ 2 tests failed in query-management-test.ts
234+
Analyzing errors...
235+
```
236+
237+
## Integration with Other Workflows
238+
239+
- **Pre-commit:** Run `npm run build && npm test`
240+
- **CI/CD:** This skill explains GitHub Actions workflow requirements
241+
- **Development Loop:** Quick iteration with `npm run build && npm run unit-test`
242+
243+
## Validation Checklist
244+
245+
Before marking workflow complete:
246+
- [ ] Build output exists in `build/` directory
247+
- [ ] At least one test command executed successfully
248+
- [ ] User informed of test results
249+
- [ ] Any failures have actionable suggestions
250+
- [ ] Chrome requirement warned if puppeteer tests selected
251+
252+
## Related Files
253+
- `.github/copilot-instructions.md` - Build & test requirements
254+
- `package.json` - Test scripts
255+
- `test/run.ts` - E2E test entry point
256+
- `test/unit/` - Unit test directory
257+
- `esbuild.config.js` - Build configuration
258+
259+
## Notes
260+
- **Trust the build:** It's fast (~5s), rebuild when in doubt
261+
- **Unit tests first:** Default to unit-test for safety
262+
- **Puppeteer optional:** Skip E2E if Chrome unavailable
263+
- **CI mirrors this:** GitHub Actions follows same workflow

0 commit comments

Comments
 (0)