Repository navigation
55 lines (51 loc) · 2.5 KB
/
Copy pathquality.yml
File metadata and controls
55 lines (51 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Quality
# Compares the changed files of a PR with their state where the branch left the base. Old code may
# stay as it is but must not get worse; new code keeps .claude/rules/code-conventions.md.
on:
pull_request:
permissions:
contents: read
concurrency:
group: quality-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
quality:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The PR's own commit, not the merge commit, and the history to find the fork point.
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
# Only typescript, at the lockfile's version. It installs outside the repo because a full npm ci also builds
# the bundles; this job needs neither.
- name: Install typescript
run: |
version="$(node -p "require('./package-lock.json').packages['node_modules/typescript'].version")"
cd "$RUNNER_TEMP"
npm install --no-audit --no-fund --no-save --prefix "$RUNNER_TEMP/typescript" "typescript@$version"
cd "$GITHUB_WORKSPACE"
mkdir -p node_modules
ln -s "$RUNNER_TEMP/typescript/node_modules/typescript" node_modules/typescript
# The base branch's copy of the check judges the PR, so a PR cannot switch the check off with its own edits.
# The first PR that adds the check has no such copy and runs its own.
- name: Check the changed files
env:
BASE_REF: ${{ github.base_ref }}
run: |
tool="tools/quality/check.mjs"
if git cat-file -e "origin/$BASE_REF:$tool" 2>/dev/null; then
mkdir -p "$RUNNER_TEMP/gate"
git archive "origin/$BASE_REF" tools/quality | tar -x -C "$RUNNER_TEMP/gate"
ln -s "$GITHUB_WORKSPACE/node_modules" "$RUNNER_TEMP/gate/node_modules"
tool="$RUNNER_TEMP/gate/$tool"
fi
changed="$(git diff --name-only "$(git merge-base "origin/$BASE_REF" HEAD)" HEAD -- tools/quality .claude/hooks .claude/settings.json .github/workflows/quality.yml .codex/hooks.json)"
if [ -n "$changed" ]; then
echo "::warning title=This PR changes the quality check::Review these on purpose, they run only after the merge: $(echo $changed)"
fi
node "$tool" --base "origin/$BASE_REF"