CI/CD Workflows
Img2Num uses GitHub Actions for continuous integration and deployment. This page documents the workflows that run automatically on pull requests and pushes to main.
Workflows Overview
Lint Workflow
File: .github/workflows/ci.yml (lint job)
Triggers:
- Pull requests to
main - Pushes to
main
Purpose: Ensures all code meets our style and quality standards before merging.
Steps:
- Checkout code
- Setup Node.js 22 with npm caching
- Install dependencies (
npm ci) - Run ESLint (
npm run lint) - Run editorconfig-checker (
npm run lint:style)
What it checks:
- JavaScript/React code quality (ESLint)
- Code style consistency (indentation, line endings, etc.)
- EditorConfig compliance
Failure conditions: The workflow fails if any linting errors are detected.
Script Validation Workflow
File: .github/workflows/ci.yml (validate-scripts job)
Triggers:
- Pull requests to
main(when scripts are modified) - Pushes to
main(when scripts are modified)
Purpose: Validates that every npm script has corresponding documentation in package.json's scriptsInfo section.
Smart detection: Only runs when:
package.jsonordocs/package.jsonchanges includescriptsInfomodifications- Files under
scripts/ordocs/scripts/are modified
Steps:
- Detect if script-related files changed
- If yes, run
npm run validate-scripts - Comment on PR if validation fails (with error details)
Running CI Checks Locally
To verify your changes will pass CI before pushing:
# Run all lint checks
npm ci
npm run lint
npm run lint:style
# Validate scripts (if you modified scripts)
npm run validate-scripts
Troubleshooting CI Failures
Lint Job Fails
Symptoms: npm run lint or npm run lint:style fails in CI
Solutions:
- Run the failing command locally:
npm run lint # for ESLint errors
npm run lint:style # for style errors - Review the error messages
- Fix issues (use
npm run lint:fixfor auto-fixable ESLint issues) - Commit and push fixes
Script Validation Fails
Symptoms: validate-scripts job fails
Solutions:
- Ensure every script in
package.jsonhas an entry inscriptsInfo - Run
npm run validate-scriptslocally to see specific errors - Add missing
scriptsInfoentries or remove unused scripts - See Project Scripts for more details
Workflow Configuration
Node.js Version
All workflows use Node.js 22 to match the project's runtime environment.
Caching
npm dependencies are cached to speed up workflow runs:
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
Conditional Execution
The validate-scripts job only runs when necessary, saving CI resources:
- Checks git diff for relevant file changes
- Uses
if: steps.check_changes.outputs.scripts_changed == 'true'
Best Practices
- Run checks locally first: Don't rely on CI to catch issues
- Keep commits lint-clean: Fix linting issues before pushing
- Review CI logs: If CI fails, read the full error output
- Ask for help: If stuck, open a discussion or comment on your PR
Future Enhancements
Planned improvements to CI workflows:
- Unit test automation
- Build verification
- Deployment automation
- Code coverage reporting
If you want to improve or add new workflows, please open an issue first to discuss your ideas with the maintainers.