Reference
CI integration.
0 on success and a non-zero code when violations at or above the failOnSeverity threshold are found.GitHub Actions SARIF with Code Scanning
The recommended setup for GitHub. SARIF output is uploaded to GitHub Code Scanning, which surfaces violations as inline annotations on pull requests. Install ngcompass locally with ng add ngcompass before committing this workflow so CI uses the locked project dependency.
01name: ngcompass02
03on:04 push:05 pull_request:06 workflow_dispatch:07
08permissions:09 contents: read10 security-events: write11 actions: read12
13jobs:14 analyze:15 runs-on: ubuntu-latest16
17 steps:18 - uses: actions/checkout@v419
20 - uses: actions/setup-node@v421 with:22 node-version: '20'23
24 - name: Install dependencies25 run: npm ci26
27 - name: Run ngcompass28 run: npx ngcompass analyze --format sarif > results.sarif29 continue-on-error: true30
31 - name: Upload to Code Scanning32 uses: github/codeql-action/upload-sarif@v433 with:34 sarif_file: results.sarifGitHub Actions hard gate (no SARIF)
Simpler setup that fails the job directly when violations are found. Good for projects that don't use Code Scanning.
01name: ngcompass02
03on: [push, pull_request]04
05jobs:06 analyze:07 runs-on: ubuntu-latest08 steps:09 - uses: actions/checkout@v410
11 - uses: actions/setup-node@v412 with:13 node-version: '20'14
15 - name: Install dependencies16 run: npm ci17
18 # Exits non-zero if any error-severity violations are found.19 # Use --profile ci to activate stricter CI-specific rules.20 - name: Run ngcompass21 run: npx ngcompass analyze --profile ciCI profile
Define a ci profile in your config to use stricter rules in CI than you do locally:
01profiles: {02 ci: {03 failOnSeverity: 'warn',04 maxWarnings: 0,05 rules: {06 'spec-no-focused-test': 'error',07 },08 },09},Activate it with:
01npx ngcompass analyze --profile ciExit codes
0Analysis passed. No violations at or above failOnSeverity.
1Violations found, maxWarnings exceeded, or a configuration / runtime error occurred.
Caching in CI
ngcompass caches analysis results between runs. In CI, the cache lives in node_modules/.cache/ngcompass by default. Cache this directory between runs to speed up analysis on large codebases.
01- uses: actions/cache@v402 with:03 path: node_modules/.cache/ngcompass04 key: ngcompass-${{ hashFiles('src/**/*.ts') }}Skip the cache for a specific run with npx ngcompass analyze --force.