-
Notifications
You must be signed in to change notification settings - Fork 0
ci(npm): smoke supported Node release lines #3988
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
7 commits
Select commit
Hold shift + click to select a range
23fc663
ci(npm): smoke supported Node release lines
kojiwakayama 8699043
Merge origin/main into fix/issue-731-npm-smoke-node-matrix
kwakayama 1ba8652
ci(npm): record what the release-line matrix does not prove
kwakayama 8f0a94e
Merge remote-tracking branch 'origin/main' into loop-3988-work
kwakayama 2519e1f
Merge origin/main into fix/issue-731-npm-smoke-node-matrix
kwakayama e3e204c
Merge commit 'ea3672c7fb4891c1879ecce378c5d7757ef68733' into fix/issu…
kojiwakayama 371636f
ci(npm): clarify smoke release-line coverage
kojiwakayama 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import { assert, assertEquals } from "#veryfront/testing/assert.ts"; | ||
| import { describe, it } from "#veryfront/testing/bdd.ts"; | ||
| import { parse } from "#std/yaml/parse"; | ||
| import { | ||
| CURRENT_NPM_SMOKE_NODE_RELEASE_LINE, | ||
| MINIMUM_NODE_RELEASE_LINE, | ||
| MINIMUM_NODE_VERSION, | ||
| NPM_SMOKE_NODE_VERSIONS, | ||
| } from "./runtime-support.ts"; | ||
|
|
||
| const WORKFLOW_PATH = new URL( | ||
| "../../.github/workflows/cicd.yml", | ||
| import.meta.url, | ||
| ); | ||
|
|
||
| function record(value: unknown, label: string): Record<string, unknown> { | ||
| if (typeof value !== "object" || value === null || Array.isArray(value)) { | ||
| throw new TypeError(`${label} must be a record`); | ||
| } | ||
| return value as Record<string, unknown>; | ||
| } | ||
|
|
||
| function steps( | ||
| job: Record<string, unknown>, | ||
| label: string, | ||
| ): Array<Record<string, unknown>> { | ||
| if (!Array.isArray(job.steps)) { | ||
| throw new TypeError(`${label} steps must be an array`); | ||
| } | ||
| return job.steps.map((step, index) => record(step, `${label} step ${index}`)); | ||
| } | ||
|
|
||
| describe("npm smoke Node support contract", () => { | ||
| it("runs the packed npm smoke on the oldest supported and current release lines", async () => { | ||
| const workflow = record( | ||
| parse(await Deno.readTextFile(WORKFLOW_PATH)), | ||
| "CI workflow", | ||
| ); | ||
| const jobs = record(workflow.jobs, "CI workflow jobs"); | ||
| const versionsJob = record( | ||
| jobs["npm-smoke-node-versions"], | ||
| "npm smoke Node versions job", | ||
| ); | ||
| const versionsStep = steps(versionsJob, "npm smoke Node versions job").find( | ||
| (step) => step.id === "versions", | ||
| ); | ||
| assert( | ||
| versionsStep, | ||
| "The version contract job must publish its Node matrix", | ||
| ); | ||
| assertEquals( | ||
| record(versionsJob.outputs, "npm smoke Node versions outputs") | ||
| .node_versions, | ||
| "${{ steps.versions.outputs.node_versions }}", | ||
| ); | ||
| assertEquals( | ||
| typeof versionsStep.run === "string" && | ||
| versionsStep.run.includes("NPM_SMOKE_NODE_VERSIONS"), | ||
| true, | ||
| "The workflow must derive the matrix from the runtime support module", | ||
| ); | ||
|
|
||
| const smokeJob = record( | ||
| jobs["tests-npm-install-smoke"], | ||
| "npm install smoke job", | ||
| ); | ||
| assertEquals(smokeJob.needs, "npm-smoke-node-versions"); | ||
| assertEquals( | ||
| record( | ||
| record(smokeJob.strategy, "npm smoke strategy").matrix, | ||
| "npm smoke matrix", | ||
| )[ | ||
| "node-version" | ||
| ], | ||
| "${{ fromJSON(needs.npm-smoke-node-versions.outputs.node_versions) }}", | ||
| ); | ||
| assertEquals( | ||
| smokeJob.name, | ||
| "tests (npm install smoke: Node ${{ matrix.node-version }})", | ||
| ); | ||
|
|
||
| const smokeSteps = steps(smokeJob, "npm install smoke job"); | ||
| const setupNode = smokeSteps.find((step) => | ||
| step.uses === | ||
| "actions/setup-node@820762786026740c76f36085b0efc47a31fe5020" | ||
| ); | ||
| assert(setupNode, "The npm smoke job must install its matrix Node release"); | ||
| assertEquals( | ||
| record(setupNode.with, "npm smoke setup-node inputs")["node-version"], | ||
| "${{ matrix.node-version }}", | ||
| ); | ||
| assert( | ||
| smokeSteps.some((step) => | ||
| step.name === "Clean-room install/import smoke" && | ||
| step.run === "bash scripts/test/npm-install-smoke.sh" | ||
| ), | ||
| "Every matrix leg must run the existing packed clean-room smoke", | ||
| ); | ||
|
|
||
| for (const jobName of ["prerelease", "release"]) { | ||
| const releaseJob = record(jobs[jobName], `${jobName} job`); | ||
| assert( | ||
| Array.isArray(releaseJob.needs) && | ||
| releaseJob.needs.includes("tests-npm-install-smoke"), | ||
| `${jobName} must wait for every npm install smoke matrix leg`, | ||
| ); | ||
| } | ||
|
|
||
| assertEquals( | ||
| NPM_SMOKE_NODE_VERSIONS, | ||
| [MINIMUM_NODE_RELEASE_LINE, CURRENT_NPM_SMOKE_NODE_RELEASE_LINE], | ||
| ); | ||
| assertEquals(MINIMUM_NODE_RELEASE_LINE, "22"); | ||
| assertEquals(MINIMUM_NODE_VERSION, "22.3.0"); | ||
| assertEquals(CURRENT_NPM_SMOKE_NODE_RELEASE_LINE, "24"); | ||
| }); | ||
| }); |
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.