Cursor rule
.cursor/rules/github-actions-testing.mdcExpert guidance for testing and validating GitHub Actions workflows before deployment - catches cache errors, path issues, monorepo dependencies, and service container problems that local testing misses
Cursor rules
Quality
93/100
Scores the file, not the repository.Length
1,426 words
43 headings · 14 code blocksRepository
121
— · pushed 39 days agoLast changed
3 days ago
First indexed 3 days ago.123456## Description78Interactive expert for testing and validating GitHub Actions workflows before deployment. Prevents common CI failures by catching cache configuration errors, path issues, monorepo dependency problems, and service container configuration mistakes.910## Capabilities1112This skill provides:13141. **Pre-Push Validation**: Complete workflow validation before pushing to GitHub152. **Cache Configuration**: Ensure cache-dependency-path is correctly specified163. **Monorepo Build Order**: Validate workspace dependency build sequences174. **Service Container Setup**: Guide proper service container configuration185. **Path Validation**: Verify all paths exist and are accessible196. **Local Testing**: Run workflows locally with act (Docker-based simulation)207. **Static Analysis**: Lint workflows with actionlint and yamllint2122## When to Use This Skill2324Invoke this skill when:25- Creating or modifying GitHub Actions workflows26- Debugging workflow failures in CI27- Setting up new repositories with CI/CD28- Migrating to monorepo architecture29- Adding service containers to workflows30- Experiencing cache-related failures31- Getting "module not found" errors in CI but not locally3233## Usage3435### Quick Validation3637"Validate my GitHub Actions workflows before I push"3839I'll:401. Run actionlint on all workflow files412. Check for missing cache-dependency-path configurations423. Validate all working-directory paths exist434. Verify monorepo build order is correct445. Check service container configurations456. Provide a pre-push checklist4647### Debugging Workflow Failures4849"My GitHub Actions workflow is failing with [error message]"5051I'll:521. Analyze the error message532. Identify the root cause543. Explain why local testing didn't catch it554. Provide the correct configuration565. Show how to test the fix locally5758### Setup New Repository5960"Set up GitHub Actions testing for my new project"6162I'll:631. Install required tools (act, actionlint, yamllint)642. Create validation scripts653. Set up pre-push hooks664. Configure recommended workflows675. Provide testing procedures6869## Critical Rules I Enforce7071### 1. Cache Configuration7273**ALWAYS specify cache-dependency-path explicitly:**7475```yaml76# ❌ WRONG77- uses: actions/setup-node@v478 with:79 cache: 'npm'8081# ✅ CORRECT82- uses: actions/setup-node@v483 with:84 cache: 'npm'85 cache-dependency-path: package-lock.json86```8788**Why**: GitHub Actions cache resolution fails silently in local testing but errors in CI with "Some specified paths were not resolved, unable to cache dependencies."8990### 2. Monorepo Build Order9192**ALWAYS build workspace dependencies before type checking:**9394```yaml95# ❌ WRONG96- run: npm ci97- run: npx tsc --noEmit9899# ✅ CORRECT100- run: npm ci101- run: npm run build --workspace=@prpm/types102- run: npm run build --workspace=@prpm/registry-client103- run: npx tsc --noEmit104```105106**Why**: TypeScript needs compiled output from workspace dependencies. Local development has pre-built artifacts, but CI starts clean.107108### 3. npm ci in Monorepos109110**ALWAYS run npm ci from root, not workspace directories:**111112```yaml113# ❌ WRONG114- working-directory: packages/infra115 run: npm ci116117# ✅ CORRECT118- run: npm ci119- working-directory: packages/infra120 run: pulumi preview121```122123**Why**: npm workspaces are managed from root. Workspace directories don't have their own package-lock.json.124125### 4. Service Containers126127**Service containers can't override CMD via options:**128129```yaml130# ❌ WRONG131services:132 minio:133 image: minio/minio:latest134 options: server /data # Ignored!135136# ✅ CORRECT137services:138 minio:139 image: minio/minio:latest140141steps:142 - run: |143 docker exec $(docker ps -q --filter ancestor=minio/minio:latest) \144 sh -c "minio server /data &"145```146147**Why**: GitHub Actions service containers ignore custom commands. They must be started manually in steps.148149## Validation Tools150151### Required Tools152153```bash154# macOS155brew install act actionlint yamllint156157# Linux158curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash159bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)160pip install yamllint161```162163### Validation Script164165I'll create `.github/scripts/validate-workflows.sh`:166167```bash168#!/bin/bash169set -e170171echo "🔍 Validating GitHub Actions workflows..."172173# 1. Static analysis174actionlint .github/workflows/*.yml175yamllint .github/workflows/*.yml176177# 2. Cache configuration check178for file in .github/workflows/*.yml; do179 if grep -q "cache: 'npm'" "$file"; then180 if ! grep -A 2 "cache: 'npm'" "$file" | grep -q "cache-dependency-path"; then181 echo "❌ $file: Missing explicit cache-dependency-path"182 exit 1183 fi184 fi185done186187# 3. Path validation188grep -r "working-directory:" .github/workflows/*.yml | while read -r line; do189 dir=$(echo "$line" | sed 's/.*working-directory: //' | tr -d '"')190 if [ ! -d "$dir" ]; then191 echo "❌ Directory does not exist: $dir"192 exit 1193 fi194done195196# 4. Check for explicit cache paths197grep -r "cache-dependency-path:" .github/workflows/*.yml | while read -r line; do198 path=$(echo "$line" | sed 's/.*cache-dependency-path: //' | tr -d '"')199 if [ ! -f "$path" ]; then200 echo "❌ Cache dependency path does not exist: $path"201 exit 1202 fi203done204205echo "✅ All workflow validations passed"206```207208### Pre-Push Checklist209210Before pushing workflow changes:2112121. **Lint**: `actionlint .github/workflows/*.yml`2132. **Validate**: `.github/scripts/validate-workflows.sh`2143. **Dry Run**: `act pull_request -W .github/workflows/[workflow].yml -n`2154. **Check Cache Paths**: Verify all cache-dependency-path values exist2165. **Check Build Order**: Ensure workspace dependencies built before type checks2176. **Service Containers**: Confirm manual startup if custom commands needed218219## Common Failure Patterns220221### "Cannot find module '@prpm/types'"222223**Root Cause**: Workspace dependency not built before type checking224225**Why Local Works**: Previous builds exist in node_modules/226227**Fix**:228```yaml229- name: Build @prpm/types230 run: npm run build --workspace=@prpm/types231- name: Type check232 run: npx tsc --noEmit233```234235### "Cache resolution error"236237**Root Cause**: Missing or incorrect cache-dependency-path238239**Why act Doesn't Catch**: act skips caching entirely240241**Fix**:242```yaml243- uses: actions/setup-node@v4244 with:245 cache: 'npm'246 cache-dependency-path: package-lock.json # Explicit!247```248249### "npm ci requires package-lock.json"250251**Root Cause**: Running npm ci from workspace directory252253**Why Local Works**: May have workspace-specific package-lock.json254255**Fix**:256```yaml257# Run from root258- run: npm ci259# Then use working-directory for commands260- working-directory: packages/infra261 run: pulumi preview262```263264### "Service container not starting"265266**Root Cause**: Custom command in options is ignored267268**Why Local Works**: docker-compose uses different container runtime269270**Fix**:271```yaml272steps:273 - run: docker exec [container] sh -c "command &"274```275276## Why act Alone Isn't Enough277278Local testing with `act` doesn't catch:2792801. **Cache Validation**: act skips GitHub's cache system entirely2812. **Service Commands**: Different container runtime, different behavior2823. **Build Artifacts**: Local has pre-built workspace dependencies2834. **Clean Environment**: CI starts completely fresh every time2845. **GitHub-Specific Features**: Some actions only work on GitHub's runners285286**Solution**: Use the complete validation suite (actionlint + custom validators + act dry run)287288## Interactive Debugging289290When you encounter a workflow failure:2912921. **Share the error**: Paste the exact GitHub Actions error message2932. **I'll analyze**: Identify the root cause and why local testing didn't catch it2943. **I'll fix**: Provide corrected workflow configuration2954. **I'll validate**: Show how to test the fix locally2965. **I'll explain**: Clarify why the issue occurred and how to prevent it297298## Example Interactions299300**User**: "My workflow is failing with 'Some specified paths were not resolved, unable to cache dependencies'"301302**Me**: This is a cache resolution error. You're using `cache: 'npm'` without specifying `cache-dependency-path`. GitHub Actions is trying to find package-lock.json but can't locate it.303304Here's the fix:305```yaml306- uses: actions/setup-node@v4307 with:308 node-version: '20'309 cache: 'npm'310 cache-dependency-path: package-lock.json # Add this311```312313This wasn't caught by `act` because it skips caching entirely. To prevent this in the future, run:314```bash315.github/scripts/validate-workflows.sh316```317318This script checks for missing cache-dependency-path configurations.319320---321322**User**: "TypeScript can't find '@prpm/types' in CI but works locally"323324**Me**: This is a monorepo build order issue. Your local environment has previously built `@prpm/types`, but CI starts clean.325326Add this before your type check:327```yaml328- name: Build @prpm/types329 run: npm run build --workspace=@prpm/types330```331332Why local worked: You've previously run `npm run build` which compiled @prpm/types to dist/. That compiled output exists in your node_modules. CI doesn't have this.333334To test this scenario locally, delete your dist/ folders and try again:335```bash336rm -rf packages/*/dist337npx tsc --noEmit # Should fail338npm run build --workspace=@prpm/types339npx tsc --noEmit # Should pass340```341342## Continuous Improvement343344After each workflow failure in CI:3453461. **Analyze**: Why didn't local testing catch this?3472. **Document**: Add to the common failure patterns3483. **Validate**: Update validation scripts to catch it next time3494. **Test**: Ensure the validator actually catches the issue350351## Best Practices3523531. **Always validate before pushing**: Run the complete validation suite3542. **Keep tools updated**: `brew upgrade act actionlint yamllint`3553. **Test in clean environment occasionally**: Use Docker to simulate fresh CI3564. **Document failures**: Add new patterns to validation scripts3575. **Use explicit configurations**: Never rely on defaults for cache, paths, or commands358359## Summary360361This skill helps you:362- ✅ Catch 90%+ of workflow failures before pushing363- ✅ Understand why local testing didn't catch issues364- ✅ Fix common GitHub Actions problems quickly365- ✅ Build confidence in your CI/CD pipeline366- ✅ Reduce iteration time (no more push-fail-fix-push cycles)367368Invoke me whenever you're working with GitHub Actions to ensure your workflows are solid before they hit CI.369
Also in pr-pm/prpm
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| pr-pm/prpm.cursor/rules/beanstalk-deploy.mdc · 121 | Cursor rules | teststyletypes | 62/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/core-principles.mdc · 121 | Cursor rules | testlint-formatstylearch+6 | 69/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/creating-agents-md.mdc · 121 | Cursor rules | testlint-formatstylearch+7 | 92/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/creating-cursor-rules.mdc · 121 | Cursor rules | testlint-formatstylearch+5 | 76/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/creating-kiro-agents.mdc · 121 | Cursor rules | setupbuildteststyle+5 | 76/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/creating-skills.mdc · 121 | Cursor rules | stylearchtesting-strategydo-not+1 | 61/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/format-conversion.mdc · 121 | Cursor rules | testlint-formatstyledo-not+1 | 63/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/karen-repo-reviewer.mdc · 121 | Cursor rules | archgit | 58/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/prpm-json-best-practices.mdc · 121 | Cursor rules | setuplint-formatstylearch+5 | 73/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/self-improve-cursor.mdc · 121 | Cursor rules | setuptestarchdependencies+3 | 69/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/testing-patterns.mdc · 121 | Cursor rules | testlint-formatstyletesting-strategy | 77/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/typescript-type-safety.mdc · 121 | Cursor rules | buildstylearchtypes+2 | 89/100 | 3 days ago | |
| pr-pm/prpm.cursor/rules/typescript-type-specialist.mdc · 121 | Cursor rules | styletypesdo-notagent-behaviour | 65/100 | 3 days ago | |
| pr-pm/prpmAGENTS.md · 121 | AGENTS.md | setupbuildtestlint-format+12 | 84/100 | 3 days ago | |
| pr-pm/prpmCLAUDE.md · 121 | CLAUDE.md | teststylegitapi+2 | 69/100 | 3 days ago |
Diff against .cursor/rules/beanstalk-deploy.mdc Diff against .cursor/rules/core-principles.mdc Diff against .cursor/rules/creating-agents-md.mdc Diff against .cursor/rules/creating-cursor-rules.mdc Diff against .cursor/rules/creating-kiro-agents.mdc Diff against .cursor/rules/creating-skills.mdc Diff against .cursor/rules/format-conversion.mdc Diff against .cursor/rules/karen-repo-reviewer.mdc Diff against .cursor/rules/prpm-json-best-practices.mdc Diff against .cursor/rules/self-improve-cursor.mdc Diff against .cursor/rules/testing-patterns.mdc Diff against .cursor/rules/typescript-type-safety.mdc Diff against .cursor/rules/typescript-type-specialist.mdc Diff against AGENTS.md Diff against CLAUDE.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago |
