CI Integration
GitHub Actions
Section titled “GitHub Actions”name: Repotypeon: [push, pull_request]
jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - run: npm install - run: npx repotype validate . --jsonname: Repotypeon: pull_request: push: branches: [main]
jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4 with: version: 10
- uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Validate repository run: npx repotype validate . --json
- name: Generate compliance report run: | npx repotype report . --json --output .repotype/compliance.json npx repotype report . --format html --output .repotype/compliance.html npx repotype report . --output .repotype/compliance.md
- name: Upload reports uses: actions/upload-artifact@v4 with: name: repotype-reports path: .repotype/name: Repotype Auto-Fixon: pull_request: types: [opened, synchronize]
jobs: fix: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: ref: ${{ github.head_ref }}
- uses: actions/setup-node@v4 with: node-version: 20
- run: npm install
- name: Run repotype fix run: npx repotype fix .
- name: Commit fixes uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "fix: auto-fix repotype violations"GitLab CI
Section titled “GitLab CI”repotype: image: node:20 stage: test script: - npm install - npx repotype validate . --json artifacts: when: always paths: - .repotype/ reports: codequality: .repotype/compliance.jsonCircleCI
Section titled “CircleCI”version: 2.1
jobs: repotype: docker: - image: cimg/node:20.0 steps: - checkout - run: npm install - run: npx repotype validate . --json - store_artifacts: path: .repotype/
workflows: validate: jobs: - repotypeExit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | All validations passed |
1 | One or more errors found |
2 | Configuration error |
PR Comments
Section titled “PR Comments”For automated PR comments with validation results, use the JSON output:
- name: Validate and comment run: | npx repotype validate . --json > validation.json # Use gh cli or another tool to post results as PR commentCaching
Section titled “Caching”Speed up CI by caching node_modules:
- uses: actions/cache@v4 with: path: node_modules key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}Branch Protection
Section titled “Branch Protection”Require Repotype validation to pass before merging:
- Go to Settings → Branches → Branch protection rules
- Add rule for
main - Enable “Require status checks to pass”
- Select the repotype job
Now PRs must pass validation before merge.