Skip to content

Commit e24932f

Browse files
GuanzhouSongclaude
andauthored
Make CI check what it claims to check (#98)
* Make CI check what it claims to check Four fixes, each for something currently unguarded. 1. YAML schema validation never validated anything. The step ran three commands that all pointed at paths which do not exist: npx yaml-ls-check .\articles The backslashes are Windows separators. On the Ubuntu runner bash treats `\a` as an escape, so the argument reaching the tool is `.articles`, and the output was `Validating 0 YAML files. Validation complete.` with exit 0 on every run. Correcting the paths alone would not have been enough. yaml-ls-check reads its schema mapping from `<root>/.vscode/settings.json`, where `<root>` is the directory passed on the command line, so `yaml-ls-check articles` looks for `articles/.vscode/settings.json`, finds nothing, and falls back to syntax-only checking. Relative roots also break the mapping's `./schema/...` references, which resolve to `/schema/...`. Passing the workspace as an absolute path is the form that works: the schemas load and violations are reported. Against the tree as it stands this validates 11 files, all passing. The separate `npm install yaml-ls-check` step is gone. It installed the entire project dependency tree as a side effect and wrote to package.json and package-lock.json in CI; `npx --yes` fetches just the tool. 2. Lint never ran anywhere. `next build` does not lint, and no workflow invoked `npm run lint`, so an ESLint or TypeScript upgrade could go green without its effect on the lint rules ever being exercised. 3. No job had a timeout. A stalled step therefore ran against GitHub's 6-hour default before failing. This is not hypothetical: a `Validate YAML files` step recently sat over six minutes on work that normally takes 24 seconds. The deployment workflow is the more serious case, since its `pages` concurrency group means one stuck run blocks every deployment queued behind it. 4. Nothing checked where the lockfile resolves from. A lockfile generated behind a corporate registry proxy records that proxy's backing-feed URLs instead of registry.npmjs.org. Those hosts are unreachable from public CI and by outside contributors, and the failure appears far from its cause. The new step asserts every `resolved` URL points at the public registry and prints the offenders when it fails. Also adds a concurrency group so a rebase or force-push supersedes in-flight pull request runs rather than leaving several racing on stale commits. Pushes to main are never cancelled, so every default-branch commit keeps a recorded result. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WWCBtvyCpxc2aqtyLDhDeE * Exclude vendored Jekyll gems from lint The new lint step failed on third-party JavaScript, not ours: vendor/bundle/ruby/3.3.0/gems/jekyll-4.4.1/lib/jekyll/commands/serve/ livereload_assets/livereload.js 1:221 error Missing semicolon semi ruby/setup-ruby runs with bundler-cache: true, which vendors gems into vendor/bundle before the lint step, so ESLint sees Jekyll's minified livereload.js. The directory is already in .gitignore, but ESLint flat config does not read .gitignore, so the ignore has to be repeated in eslint.config.mjs. This is invisible locally, where vendor/ does not exist. Also ignores .jekyll-cache and any _site output for the same reason. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WWCBtvyCpxc2aqtyLDhDeE --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8acfddc commit e24932f

3 files changed

Lines changed: 48 additions & 7 deletions

File tree

.github/workflows/continuous-deployment.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
permissions:
2121
contents: read
2222
runs-on: ubuntu-22.04
23+
# Without an explicit timeout a stalled step runs against GitHub's 6-hour
24+
# default before failing, which for `pages` concurrency means blocking
25+
# every deployment queued behind it.
26+
timeout-minutes: 30
2327
steps:
2428
- name: Checkout source
2529
uses: actions/checkout@v7
@@ -132,6 +136,7 @@ jobs:
132136
name: github-pages
133137
url: ${{ steps.deployment.outputs.page_url }}
134138
runs-on: ubuntu-latest
139+
timeout-minutes: 10
135140
needs:
136141
- build
137142
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages

.github/workflows/continuous-integration.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,39 @@ on:
99
pull_request:
1010
branches:
1111
- main
12+
# Supersede in-flight runs for a pull request when new commits arrive, so a
13+
# rebase or force-push does not leave several runs racing on stale commits.
14+
# Pushes to main are never cancelled: every commit on the default branch
15+
# should get a recorded result.
16+
concurrency:
17+
group: ci-${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1219
jobs:
1320
# YAML schema validation job
1421
yaml-schema-validation:
1522
name: Validate YAML files against schemas
1623
runs-on: ubuntu-latest
24+
timeout-minutes: 10
1725
steps:
1826
- name: Checkout repository
1927
uses: actions/checkout@v7
2028
- name: Set up Node.js
2129
uses: actions/setup-node@v7
2230
with:
2331
node-version: 24
24-
- name: Install dependencies
25-
run: |
26-
npm install yaml-ls-check
2732
- name: Validate YAML files
28-
run: |
29-
npx yaml-ls-check .\articles
30-
npx yaml-ls-check .\blogs
31-
npx yaml-ls-check .\reference
33+
# Pass the repository root as an absolute path. yaml-ls-check reads its
34+
# schema mapping from `<root>/.vscode/settings.json`, so the root it is
35+
# given has to be the directory holding `.vscode`. Passing a
36+
# subdirectory silently skips schema validation and checks only YAML
37+
# syntax; passing a relative path breaks the mapping's `./schema/`
38+
# references.
39+
run: npx --yes yaml-ls-check "$GITHUB_WORKSPACE"
3240
# Build validation job
3341
build-validation:
3442
name: Validate Next.js build
3543
runs-on: ubuntu-latest
44+
timeout-minutes: 20
3645
steps:
3746
- name: Checkout repository
3847
uses: actions/checkout@v7
@@ -47,8 +56,28 @@ jobs:
4756
with:
4857
ruby-version: 3.3
4958
bundler-cache: true
59+
- name: Check lockfile resolves against the public registry
60+
# A lockfile generated behind a registry proxy records that proxy's
61+
# backing-feed URLs, which public CI and outside contributors cannot
62+
# fetch. Catch it here rather than after it is merged.
63+
run: |
64+
node -e "
65+
const lock = require('./package-lock.json');
66+
const bad = Object.entries(lock.packages)
67+
.filter(([, v]) => v.resolved && !v.resolved.startsWith('https://registry.npmjs.org/'));
68+
if (bad.length) {
69+
console.error('package-lock.json has ' + bad.length + ' resolved URL(s) outside registry.npmjs.org:');
70+
bad.slice(0, 10).forEach(([name, v]) => console.error(' ' + name + ' -> ' + v.resolved));
71+
process.exit(1);
72+
}
73+
console.log('All resolved URLs point at registry.npmjs.org.');
74+
"
5075
- name: Install dependencies
5176
run: npm ci
77+
- name: Lint
78+
# `next build` does not lint, so without this an ESLint or TypeScript
79+
# upgrade can land without its effect on the lint rules ever running.
80+
run: npm run lint
5281
- name: Build Next.js site
5382
# Validate that the site builds successfully
5483
#

eslint.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ export default defineConfig([
1010
"coverage/**",
1111
"build/**",
1212
"node_modules/**",
13+
// Jekyll vendors its gems into vendor/bundle when bundler-cache is on,
14+
// which drops third-party JavaScript such as Jekyll's minified
15+
// livereload.js into the tree. These paths are in .gitignore, but flat
16+
// config does not read .gitignore, so they have to be listed here too.
17+
"vendor/**",
18+
".jekyll-cache/**",
19+
"**/_site/**",
1320
],
1421
},
1522
{

0 commit comments

Comments
 (0)