GitHub Actions Local Checks
Overview
When working in a repository with GitHub Actions, run relevant pipeline checks locally before pushing. This catches failures early and is much faster than waiting for CI to run and report errors.
When to Use This Skill
- Before committing and pushing code changes
- After making significant changes to ensure tests still pass
- When adding new features or fixing bugs
- Before creating a pull request
Identifying Steps to Run Locally
Look at workflow files in .github/workflows/*.yml to identify runnable steps:
Run Locally (Fast Feedback)
- Tests:
npm test,npm run test:unit,jest --coverage - Linting:
npm run lint,eslint . - Type Checking:
npm run type-check,tsc --noEmit - Prettier/Formatting:
npx prettier --check . - Build validation:
npm run build(if fast)
Skip Locally (CI-Only)
- Deployments:
cdk deploy, deployment scripts - Docker builds/pushes: Slow and require credentials
- Integration tests: If they require external services
- Codecov uploads: CI handles this
Workflow Pattern
-
Identify the relevant workflow file
- For PRs: Usually
.github/workflows/run-tests.ymlor similar - For deployments: Usually
.github/workflows/deploy-*.yml
- For PRs: Usually
-
Find test/lint steps in the workflow
- Look for
run:commands understeps: - Note the
working-directory:if specified - Identify which commands to run
- Look for
-
Run commands locally
# Example: Run tests for a specific stack cd stacks/oncall-data-sync-stack npm run test -- --coverage # Example: Run linting npm run lint # Example: Type checking npm run type-check -
Fix any failures before pushing
Common Patterns
Matrix strategies
If workflow uses matrix (e.g., testing multiple stacks), run checks for each affected area:
matrix:
stack: [stack-a, stack-b, stack-c]
→ Run tests in each stack directory you modified
Working directories
Match the workflow's working-directory:
- name: Run tests
working-directory: ./stacks/my-stack
run: npm test
→ Run cd stacks/my-stack && npm test locally
Conditional steps
If workflow has if: conditions, check if they apply to your changes:
- name: Integration tests
if: github.event_name == 'push'
run: npm run test:integration
→ Skip if you're just testing locally, but run if condition matches
Example
Scenario: Modified code in stacks/oncall-data-sync-stack/
Workflow file shows:
- name: Run unit tests
working-directory: ./stacks/oncall-data-sync-stack
run: npm run test -- --coverage
Run locally:
cd stacks/oncall-data-sync-stack
npm run test -- --coverage
Result: Catches test failures before pushing, saves time waiting for CI.
Benefits
- Faster feedback loop: Seconds vs minutes waiting for CI
- Cheaper: No wasted CI compute on failures
- Better workflow: Fix issues immediately while context is fresh
- Fewer failed builds: Keep CI green