|
| 1 | +name: Code Quality |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +# Detects whether a PR *adds* new dead code or duplication compared to main. |
| 8 | +# - fallow covers VueApp (dead code, unused exports, complexity, duplication) |
| 9 | +# - jscpd covers C# (web/Areas/**/*.cs) since fallow is JS/TS-only |
| 10 | +# Passes if counts are equal to or lower than main. |
| 11 | + |
| 12 | +jobs: |
| 13 | + fallow-regression: |
| 14 | + name: Fallow regression (VueApp) |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout PR head |
| 18 | + uses: actions/checkout@v6 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - uses: actions/setup-node@v6 |
| 23 | + with: |
| 24 | + node-version: 24 |
| 25 | + cache: npm |
| 26 | + cache-dependency-path: | |
| 27 | + package-lock.json |
| 28 | + VueApp/package-lock.json |
| 29 | +
|
| 30 | + - name: Install dependencies (root) |
| 31 | + run: npm ci |
| 32 | + |
| 33 | + - name: Install dependencies (VueApp) |
| 34 | + # fallow resolves the tsconfig chain (incl. @tsconfig/node24) and needs |
| 35 | + # VueApp's node_modules to produce accurate counts. Without this step, |
| 36 | + # CI reports inflated unresolved-imports / unused-types numbers. |
| 37 | + run: npm ci --prefix VueApp |
| 38 | + |
| 39 | + - name: Audit fallow on changed files |
| 40 | + # `fallow audit` is purpose-built for PR-diff regression gating: it |
| 41 | + # scopes to files changed since --base and returns a pass/warn/fail |
| 42 | + # verdict (exit 0 if no regression). |
| 43 | + run: npx fallow audit --root VueApp --base origin/${{ github.base_ref }} |
| 44 | + |
| 45 | + jscpd-regression-csharp: |
| 46 | + name: JSCPD regression (C#) |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - name: Checkout PR head |
| 50 | + uses: actions/checkout@v6 |
| 51 | + with: |
| 52 | + fetch-depth: 0 |
| 53 | + |
| 54 | + - uses: actions/setup-node@v6 |
| 55 | + with: |
| 56 | + node-version: 24 |
| 57 | + cache: npm |
| 58 | + cache-dependency-path: | |
| 59 | + package-lock.json |
| 60 | + VueApp/package-lock.json |
| 61 | +
|
| 62 | + - name: Install dependencies (root) |
| 63 | + run: npm ci |
| 64 | + |
| 65 | + - name: Baseline jscpd on main |
| 66 | + # Use a separate worktree at the base ref so the baseline scan sees |
| 67 | + # main's full tree — files added by the PR aren't present, files |
| 68 | + # changed by the PR carry main's content. Pathspec `git checkout` |
| 69 | + # would leave PR-only files in place and pollute the baseline. |
| 70 | + env: |
| 71 | + BASE_REF: ${{ github.base_ref }} |
| 72 | + run: | |
| 73 | + BASE_TREE="$(mktemp -d)" |
| 74 | + git worktree add --detach "$BASE_TREE" "origin/$BASE_REF" |
| 75 | + node scripts/audit-jscpd-regression.js --save .jscpd-baseline-cs.json "$BASE_TREE/web/Areas" --format csharp --pattern '**/*.cs' --min-lines 15 |
| 76 | + git worktree remove --force "$BASE_TREE" |
| 77 | +
|
| 78 | + - name: Check jscpd regression on PR |
| 79 | + run: node scripts/audit-jscpd-regression.js --check .jscpd-baseline-cs.json web/Areas --format csharp --pattern '**/*.cs' --min-lines 15 |
| 80 | + |
| 81 | + jscpd-regression-vue: |
| 82 | + name: JSCPD regression (Vue/TS) |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - name: Checkout PR head |
| 86 | + uses: actions/checkout@v6 |
| 87 | + with: |
| 88 | + fetch-depth: 0 |
| 89 | + |
| 90 | + - uses: actions/setup-node@v6 |
| 91 | + with: |
| 92 | + node-version: 24 |
| 93 | + cache: npm |
| 94 | + cache-dependency-path: | |
| 95 | + package-lock.json |
| 96 | + VueApp/package-lock.json |
| 97 | +
|
| 98 | + - name: Install dependencies (root) |
| 99 | + run: npm ci |
| 100 | + |
| 101 | + - name: Baseline jscpd on main |
| 102 | + # See the C# baseline step above for why we use a worktree here. |
| 103 | + env: |
| 104 | + BASE_REF: ${{ github.base_ref }} |
| 105 | + run: | |
| 106 | + BASE_TREE="$(mktemp -d)" |
| 107 | + git worktree add --detach "$BASE_TREE" "origin/$BASE_REF" |
| 108 | + node scripts/audit-jscpd-regression.js --save .jscpd-baseline-vue.json "$BASE_TREE/VueApp/src" |
| 109 | + git worktree remove --force "$BASE_TREE" |
| 110 | +
|
| 111 | + - name: Check jscpd regression on PR |
| 112 | + run: node scripts/audit-jscpd-regression.js --check .jscpd-baseline-vue.json VueApp/src |
0 commit comments