This file provides guidance to AI coding agents when working with code in this repository.
This is a GitHub Action that validates pull request titles against commitlint rules. It uses @commitlint/load to load configurations and @commitlint/lint to validate PR titles.
- src/main.ts: Entry point that retrieves PR title from GitHub context and calls the linter
- src/linter.ts: Core logic that loads commitlint config and validates titles
lintPullRequest(): Main validation function that loads config, parses rules, and returns validation resultsgetLintOptions(): Extracts parser options, plugins, and ignores from commitlint configselectParserOpts(): Safely extracts parser options from parser presets
The action reads PR title from github.context.payload.pull_request.title and validates it against a commitlint configuration file (default: ./commitlint.config.js).
# Build TypeScript to lib/
pnpm build
# Bundle with esbuild to dist/index.js
pnpm bundle
# Run unit tests
pnpm test
# Run e2e tests (requires dist/index.js to exist)
pnpm test:e2e
# Lint code
pnpm lint
# Format code
pnpm format
# Check formatting
pnpm format-check
# Full build, test, and bundle pipeline
pnpm all
# Build and bundle together
pnpm build:packThe project uses a two-step build:
- TypeScript compilation:
tsccompilessrc/**/*.tstolib/(CommonJS) - esbuild bundling: Bundles
lib/main.jsto singledist/index.jsfile
Important esbuild behavior (see esbuild.config.js):
- Replaces
import.meta.urlwithimport_meta_urlfor Node.js compatibility - Copies template files from
conventional-changelog-angular/templatestodist/templates/ - Copies
commitlint.schema.jsontodist/for config validation - Target: Node.js 20, CommonJS format
Tests use Vitest. There are two test suites:
- Unit tests (
test/linter.test.ts): TestslintPullRequest()directly using real commitlint with fixture config files intest/e2e/fixtures/configs/. - E2E tests (
test/e2e/e2e.test.ts): Spawnsnode dist/index.jsas a child process with controlled environment variables simulating GitHub Actions execution. Requirespnpm build:packfirst.
When adding tests:
- Test files match
**/*.test.ts - Use fixture configs in
test/e2e/fixtures/configs/for commitlint rules - Use fixture events in
test/e2e/fixtures/events/for GitHub webhook payloads
The action accepts one input parameter:
configuration-path: Path to commitlint config (default:./commitlint.config.js)
Example commitlint config format (commitlint.config.js):
module.exports = {
rules: {
"scope-case": [2, "always", "lower-case"]
}
}@commitlint/load: Loads commitlint configurations with plugin support@commitlint/lint: Validates commit messages against rules@commitlint/typespinned to20.4.3via pnpm override to prevent version drift withconventional-commits-parsertypes