Repository navigation
fix(scripts): scope the flaky-test ratchet to check:changed's --base merge base #33782
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,14 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { execFileSync } from 'node:child_process' | ||
| import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' | ||
| import { tmpdir } from 'node:os' | ||
| import { join } from 'node:path' | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import { changedFileScope, countFindings } from './check-flaky-test-pattern-ratchet.mjs' | ||
| import { | ||
| changedFileScope, | ||
| countFindings, | ||
| listChangedFiles | ||
| } from './check-flaky-test-pattern-ratchet.mjs' | ||
|
|
||
| describe('countFindings', () => { | ||
| it('counts each rule per file, folding TSX twins and Windows separators', () => { | ||
|
|
@@ -32,3 +40,39 @@ describe('changedFileScope', () => { | |
| expect(changedFileScope(null)).toBeUndefined() | ||
| }) | ||
| }) | ||
|
|
||
| describe('listChangedFiles', () => { | ||
| let fixture | ||
| afterEach(() => { | ||
| vi.unstubAllEnvs() | ||
| rmSync(fixture, { recursive: true, force: true }) | ||
| }) | ||
|
|
||
| it('scopes to the base check:changed forwards instead of a stale origin/main', () => { | ||
| fixture = mkdtempSync(join(tmpdir(), 'flaky-ratchet-base-')) | ||
| const git = (...args) => | ||
| execFileSync('git', ['-c', 'user.name=t', '-c', 'user.email=t@example.com', ...args], { | ||
| cwd: fixture, | ||
| encoding: 'utf8' | ||
|
Comment on lines
+54
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clear inherited Git repository variables for the fixture. If a Git hook starts this test with Based on learnings, Git subprocesses targeting temporary repositories must clear inherited repository-location variables. Source: Learnings |
||
| }).trim() | ||
| const commit = (file) => { | ||
| writeFileSync(join(fixture, file), file) | ||
| git('add', file) | ||
| git('-c', 'commit.gpgsign=false', 'commit', '-qm', file) | ||
| return git('rev-parse', 'HEAD') | ||
| } | ||
| git('init', '-q') | ||
| git('update-ref', 'refs/remotes/origin/main', commit('fork-base.txt')) | ||
| const upstream = commit('upstream-drift.txt') | ||
| commit('contribution.txt') | ||
| vi.stubEnv('ORCA_FLAKY_TEST_RATCHET_ALL', '') | ||
| vi.stubEnv('ORCA_CODE_QUALITY_BASE', '') | ||
|
|
||
| expect([...listChangedFiles(fixture)].sort()).toEqual([ | ||
| 'contribution.txt', | ||
| 'upstream-drift.txt' | ||
| ]) | ||
| vi.stubEnv('ORCA_CODE_QUALITY_BASE', upstream) | ||
| expect([...listChangedFiles(fixture)]).toEqual(['contribution.txt']) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: stablyai/orca
Length of output: 2131
Support both base variables without changing
check:changedprecedence.The standalone command sets
ORCA_CHANGED_MERGE_BASE, but the ratchet reads onlyORCA_CODE_QUALITY_BASEand otherwise usesorigin/main. Add the documented variable afterORCA_CODE_QUALITY_BASE, so an inherited value cannot overridecheck:changed's resolved base.Suggested fix
Keep the fallback test clear of both base variables.
Committable suggestion