Repository navigation
fix(release): bind artifact build to exact tag checkout #326
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 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cf64209
test(release): require exact credential-free artifact checkout
seonghobae cbab679
fix(release): attest exact credential-free artifact checkout
seonghobae 68b0c59
test(release): expose prerelease fake-success path
seonghobae b4b13cc
fix(release): fail closed on prerelease tags
seonghobae 2e31d4c
chore(release): preserve workflow formatting
seonghobae 2e604d1
test(release): preserve scoped tag semantics
seonghobae 0623c22
fix(release): preserve prerelease scope after exact checkout hardening
seonghobae c255afb
test(release): require current checkout action baseline
seonghobae 42f05e6
fix(release): align artifact checkout action baseline
seonghobae 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { readFileSync } from 'node:fs'; | ||
| import { resolve } from 'node:path'; | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| /** Read one authoritative repository file as UTF-8 text. */ | ||
| function repositoryFile(path: string): string { | ||
| return readFileSync(resolve(process.cwd(), path), 'utf8'); | ||
| } | ||
|
|
||
| /** Extract one top-level workflow job without allowing another job to satisfy it. */ | ||
| function workflowJob(source: string, jobName: string, nextJobName: string): string { | ||
| const start = source.indexOf(` ${jobName}:`); | ||
| const end = source.indexOf(` ${nextJobName}:`, start + 1); | ||
| expect(start).toBeGreaterThan(-1); | ||
| expect(end).toBeGreaterThan(start); | ||
| return source.slice(start, end); | ||
| } | ||
|
|
||
| describe('release artifact checkout authority', () => { | ||
| it('binds the artifact build to the exact tag SHA without persisted credentials before setup', () => { | ||
| const workflow = repositoryFile('.github/workflows/release.yml'); | ||
| const buildJob = workflowJob( | ||
| workflow, | ||
| 'build-release-artifacts', | ||
| 'browser-release-evidence', | ||
| ); | ||
|
|
||
| const checkoutIndex = buildJob.indexOf('name: Check out the tagged source'); | ||
| const verifyIndex = buildJob.indexOf('name: Verify exact checkout'); | ||
| const pnpmIndex = buildJob.indexOf('name: Set up pnpm'); | ||
| const nodeIndex = buildJob.indexOf('name: Set up Node.js'); | ||
| const pythonIndex = buildJob.indexOf('name: Set up Python'); | ||
|
|
||
| expect(checkoutIndex).toBeGreaterThan(-1); | ||
| expect(buildJob).toContain('ref: ${{ github.sha }}'); | ||
| expect(buildJob).toContain('persist-credentials: false'); | ||
| expect(verifyIndex).toBeGreaterThan(checkoutIndex); | ||
| expect(verifyIndex).toBeLessThan(pnpmIndex); | ||
| expect(verifyIndex).toBeLessThan(nodeIndex); | ||
| expect(verifyIndex).toBeLessThan(pythonIndex); | ||
| expect(buildJob).toContain('INKSPAN_EXPECTED_HEAD_SHA: ${{ github.sha }}'); | ||
| expect(buildJob).toContain('actual_head="$(git rev-parse HEAD)"'); | ||
| expect(buildJob).toContain('test "$actual_head" = "$INKSPAN_EXPECTED_HEAD_SHA"'); | ||
| }); | ||
|
|
||
| it('fails closed on prerelease tags instead of allowing a registry-skipping release path', () => { | ||
| const workflow = repositoryFile('.github/workflows/release.yml'); | ||
| const buildJob = workflowJob( | ||
| workflow, | ||
| 'build-release-artifacts', | ||
| 'browser-release-evidence', | ||
| ); | ||
|
|
||
| expect(buildJob).toContain( | ||
| "if (!/^v(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$/.test(releaseTag))", | ||
| ); | ||
| expect(buildJob).toContain( | ||
| 'Release tag is not valid stable semantic version syntax', | ||
| ); | ||
| expect(buildJob).not.toContain('(?:-[0-9A-Za-z.-]+)?'); | ||
| expect(workflow).toContain("!contains(github.ref_name, '-')"); | ||
| }); | ||
| }); | ||
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.