Repository navigation
fix(ci): retain disk samples when npm install fails #10517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
37dead9
ci: gate heavy jobs on a disk floor and persist pressure samples
yiliang114 7da0eb7
ci: single-quote the failure() condition to satisfy yamllint quoted-s…
yiliang114 d8ff4f2
ci: keep TMPDIR routing block byte-identical across test legs
yiliang114 1186e50
fix(ci): validate disk floor overrides
yiliang114 c17ce29
fix(ci): reject oversized disk floor overrides
yiliang114 44344d4
test(ci): pin the disk-floor overflow guard boundaries
yiliang114 6eae982
Merge origin/main into fix/ci-disk-floor-gate-10035
yiliang114 0c7fe0a
refactor(ci): simplify disk floor validation and sampling
yiliang114 5c8456d
fix(ci): preserve the TMPDIR sampler sentinel
yiliang114 fa9bfb0
fix(ci): retain disk samples from dependency install
yiliang114 26654c5
refactor(ci): reuse the workflow parser in disk tests
yiliang114 9ac726f
Merge origin/main into fix/ci-preinstall-disk-sampling-10035
yiliang114 1a4fd1b
chore(ci): trigger checks after retargeting to main
yiliang114 8a0f5dd
test(ci): pin disk-pressure workflow contract
yiliang114 8a386ab
Merge branch 'main' into fix/ci-preinstall-disk-sampling-10035
yiliang114 cbf28ac
fix(ci): harden install disk sampling
yiliang114 3aac615
Merge branch 'main' into fix/ci-preinstall-disk-sampling-10035
yiliang114 c0da45d
ci: record ci.yml growth in the size baseline
yiliang114 9964047
Merge branch 'main' into fix/ci-preinstall-disk-sampling-10035
yiliang114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { spawnSync } from 'node:child_process'; | ||
| import { | ||
| chmodSync, | ||
| mkdtempSync, | ||
| readFileSync, | ||
| rmSync, | ||
| writeFileSync, | ||
| } from 'node:fs'; | ||
| import { tmpdir } from 'node:os'; | ||
| import { dirname, join } from 'node:path'; | ||
| import { describe, it } from 'node:test'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { parse } from 'yaml'; | ||
|
|
||
| const workflowPath = join( | ||
| dirname(fileURLToPath(import.meta.url)), | ||
| '..', | ||
| 'workflows', | ||
| 'ci.yml', | ||
| ); | ||
| const testSteps = parse(readFileSync(workflowPath, 'utf8')).jobs.test.steps; | ||
|
|
||
| function step(name) { | ||
| const value = testSteps.find((candidate) => candidate.name === name); | ||
| assert.ok(value, `missing ${name} step`); | ||
| return value; | ||
| } | ||
|
|
||
| describe('ci.yml disk-pressure evidence', () => { | ||
| it('starts sampling before npm ci and preserves those samples for upload', () => { | ||
| const install = step('Install dependencies').run; | ||
| const npmCi = install.indexOf('npm ci'); | ||
|
|
||
| assert.match( | ||
| install, | ||
| /DISK_SAMPLES="\$\{RUNNER_TEMP\}\/disk-pressure-samples\.log"/, | ||
| ); | ||
| assert.ok(npmCi > install.indexOf('DFSAMPLE ')); | ||
| assert.match(install, /\( while sleep 10; do sample_disk; done \) &/); | ||
| assert.ok(npmCi > install.indexOf('( while sleep 10')); | ||
| assert.match(install, /trap .*SAMPLER_PID.* EXIT/); | ||
|
|
||
| const tests = step('Run tests and generate reports').run; | ||
| assert.match( | ||
| tests, | ||
| /DISK_SAMPLES="\$\{RUNNER_TEMP\}\/disk-pressure-samples\.log"\nif \[ ! -s "\$DISK_SAMPLES" \]; then\n {2}echo "DISKCONTEXT .*" > "\$DISK_SAMPLES" 2>\/dev\/null \|\| true\nfi/, | ||
| ); | ||
| assert.ok(tests.indexOf('export TMPDIR=') > tests.indexOf('DISK_SAMPLES=')); | ||
|
|
||
| const sampleFormat = (script) => { | ||
| const match = script.match( | ||
| /sample="DFSAMPLE .*\/proc\/meminfo 2>\/dev\/null(?: \|\| true)?\)\]"/, | ||
| ); | ||
| assert.ok(match); | ||
| return match[0] | ||
| .replaceAll('${RUNNER_TEMP:-/tmp}', '${TMPDIR}') | ||
| .replace( | ||
| ' /proc/meminfo 2>/dev/null || true)]', | ||
| ' /proc/meminfo 2>/dev/null)]', | ||
| ); | ||
| }; | ||
| const headerLine = (script) => | ||
| script | ||
| .split('\n') | ||
| .find((line) => line.trimStart().startsWith('echo "DISKCONTEXT ')) | ||
| ?.trim(); | ||
| assert.equal(headerLine(install), headerLine(tests)); | ||
| assert.equal(sampleFormat(install), sampleFormat(tests)); | ||
|
|
||
| const upload = step('Upload disk-pressure samples'); | ||
| assert.equal(upload.if, '${{ failure() }}'); | ||
| assert.equal(upload.with['if-no-files-found'], 'ignore'); | ||
| assert.equal( | ||
| upload.with.path, | ||
| '${{ runner.temp }}/disk-pressure-samples.log', | ||
| ); | ||
| }); | ||
|
|
||
| it('keeps install failure status while writing the pre-install sample', () => { | ||
| const root = mkdtempSync(join(tmpdir(), 'ci-disk-pressure-')); | ||
| const npm = join(root, 'npm'); | ||
| writeFileSync(npm, '#!/usr/bin/env bash\nexit 42\n'); | ||
| chmodSync(npm, 0o755); | ||
|
|
||
| try { | ||
| const result = spawnSync( | ||
| 'bash', | ||
| ['-e', '-o', 'pipefail', '-c', step('Install dependencies').run], | ||
|
yiliang114 marked this conversation as resolved.
Resolved
|
||
| { | ||
| encoding: 'utf8', | ||
| timeout: 30_000, | ||
| env: { | ||
| ...process.env, | ||
| PATH: `${root}:${process.env.PATH}`, | ||
| RUNNER_TEMP: root, | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| assert.equal(result.error, undefined); | ||
| assert.equal( | ||
| result.status, | ||
| 42, | ||
| `signal: ${result.signal}\nerror: ${result.error}\nstdout: ${result.stdout}\nstderr: ${result.stderr}`, | ||
| ); | ||
| const samples = readFileSync( | ||
| join(root, 'disk-pressure-samples.log'), | ||
| 'utf8', | ||
| ); | ||
| assert.match(samples, /^DISKCONTEXT /m); | ||
| assert.match(samples, /^DFSAMPLE /m); | ||
| } finally { | ||
| rmSync(root, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.