Repository navigation
feat(python-cli-parity): fail scan diffs on blocking findings #1767
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
Open
John-David Dalton (jdalton)
wants to merge
1
commit into
v1.x
Choose a base branch
from
jdalton/surf-2234-strict-blocking
base: v1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−9
Open
Changes from all commits
Commits
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import { outputDiffScan } from './output-diff-scan.mts' | ||
|
|
||
| vi.mock('../../utils/logger.mts', () => ({ | ||
| logger: { error: vi.fn(), fail: vi.fn(), info: vi.fn(), log: vi.fn() }, | ||
| })) | ||
|
|
||
| const diff = { | ||
| after: { id: 'after' }, | ||
| artifacts: { | ||
| added: [], | ||
| removed: [], | ||
| replaced: [], | ||
| unchanged: [ | ||
| { | ||
| type: 'npm', | ||
| name: 'left-pad', | ||
| version: '1.0.0', | ||
| alerts: [{ action: 'error', type: 'test-alert', key: 'alert-1' }], | ||
| }, | ||
| ], | ||
| updated: [], | ||
| }, | ||
| before: { id: 'before' }, | ||
| directDependenciesChanged: false, | ||
| diff_report_url: '', | ||
| } | ||
|
|
||
| describe('outputDiffScan strict blocking', () => { | ||
| afterEach(() => { | ||
| process.exitCode = 0 | ||
| vi.clearAllMocks() | ||
| }) | ||
|
|
||
| it('fails for new blocking alerts in ordinary diff mode', async () => { | ||
| const changed = structuredClone(diff) | ||
| changed.artifacts.added.push({ | ||
| type: 'npm', | ||
| name: 'new-package', | ||
| version: '1.0.0', | ||
| alerts: [{ action: 'error', type: 'test-alert', key: 'alert-2' }], | ||
| }) | ||
| await outputDiffScan({ ok: true, data: changed } as never, { | ||
| depth: 0, | ||
| file: '', | ||
| outputKind: 'json', | ||
| strictBlocking: false, | ||
| }) | ||
| expect(process.exitCode).toBe(1) | ||
| }) | ||
|
|
||
| it('fails when an unchanged alert blocks under strict mode', async () => { | ||
| await outputDiffScan({ ok: true, data: diff } as never, { | ||
| depth: 0, | ||
| file: '', | ||
| outputKind: 'json', | ||
| strictBlocking: true, | ||
| }) | ||
| expect(process.exitCode).toBe(1) | ||
| }) | ||
|
|
||
| it('does not fail on unchanged blocking alerts by default', async () => { | ||
| await outputDiffScan({ ok: true, data: diff } as never, { | ||
| depth: 0, | ||
| file: '', | ||
| outputKind: 'json', | ||
| strictBlocking: false, | ||
| }) | ||
| expect(process.exitCode).toBe(0) | ||
| }) | ||
|
|
||
| it('does not fail when unchanged alerts are nonblocking', async () => { | ||
| const nonBlocking = structuredClone(diff) | ||
| nonBlocking.artifacts.unchanged[0]!.alerts![0]!.action = 'warn' | ||
| await outputDiffScan({ ok: true, data: nonBlocking } as never, { | ||
| depth: 0, | ||
| file: '', | ||
| outputKind: 'json', | ||
| strictBlocking: true, | ||
| }) | ||
| expect(process.exitCode).toBe(0) | ||
| }) | ||
| }) |
Oops, something went wrong.
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.