-
Notifications
You must be signed in to change notification settings - Fork 259
ci(cli): validate npm tarball across platforms #3185
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
2 commits
Select commit
Hold shift + click to select a range
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,146 @@ | ||
| name: CLI package validation | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - '.github/workflows/cli-package-validation.yml' | ||
| - '.gitattributes' | ||
| - '.npmrc' | ||
| - 'LICENSE' | ||
| - 'NOTICE' | ||
| - 'package.json' | ||
| - 'package-lock.json' | ||
| - 'patches/**' | ||
| - 'packages/cli/**' | ||
| - 'packages/code-mode/**' | ||
| - 'packages/core/**' | ||
| - 'packages/eval/**' | ||
| - 'packages/mcp/**' | ||
| - 'packages/runtime/**' | ||
| - 'packages/runtime-host/**' | ||
| - 'packages/storage/**' | ||
| - 'scripts/apply-dependency-patches.mjs' | ||
| - 'scripts/clean-paths.mjs' | ||
| - 'scripts/generate-third-party-notices.mjs' | ||
| - 'scripts/install-electron-with-retry.mjs' | ||
| - 'scripts/npm-spawn.mjs' | ||
| - 'scripts/release-cli-*.mjs' | ||
| - 'scripts/smoke-release-cli-package.mjs' | ||
| - 'tsconfig*.json' | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - '.github/workflows/cli-package-validation.yml' | ||
| - '.gitattributes' | ||
| - '.npmrc' | ||
| - 'LICENSE' | ||
| - 'NOTICE' | ||
| - 'package.json' | ||
| - 'package-lock.json' | ||
| - 'patches/**' | ||
| - 'packages/cli/**' | ||
| - 'packages/code-mode/**' | ||
| - 'packages/core/**' | ||
| - 'packages/eval/**' | ||
| - 'packages/mcp/**' | ||
| - 'packages/runtime/**' | ||
| - 'packages/runtime-host/**' | ||
| - 'packages/storage/**' | ||
| - 'scripts/apply-dependency-patches.mjs' | ||
| - 'scripts/clean-paths.mjs' | ||
| - 'scripts/generate-third-party-notices.mjs' | ||
| - 'scripts/install-electron-with-retry.mjs' | ||
| - 'scripts/npm-spawn.mjs' | ||
| - 'scripts/release-cli-*.mjs' | ||
| - 'scripts/smoke-release-cli-package.mjs' | ||
| - 'tsconfig*.json' | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: cli-package-validation-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build immutable tarball | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||
| with: | ||
| node-version: '22.19.0' | ||
| cache: npm | ||
| - name: Select the release npm toolchain | ||
| run: npm install --global --no-audit --no-fund npm@11.12.1 | ||
| - name: Build the release tarball once | ||
| run: npm run release:cli:pack | ||
| - name: Upload the immutable release candidate | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: cli-release-candidate | ||
| path: | | ||
| packages/cli/release/*.tgz | ||
| packages/cli/release/*.tgz.sha256 | ||
| packages/cli/release/*.tgz.files.json | ||
| if-no-files-found: error | ||
| retention-days: 7 | ||
|
|
||
| smoke: | ||
| name: Validate installed CLI ${{ matrix.name }} | ||
| needs: build | ||
| runs-on: ${{ matrix.runner }} | ||
| timeout-minutes: 15 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - name: Linux x64 / Node 22.19 | ||
| runner: ubuntu-24.04 | ||
| node: '22.19.0' | ||
| platform: linux | ||
| arch: x64 | ||
| - name: Linux x64 / Node 24 | ||
| runner: ubuntu-24.04 | ||
| node: '24' | ||
| platform: linux | ||
| arch: x64 | ||
| - name: macOS arm64 / Node 24 | ||
| runner: macos-15 | ||
| node: '24' | ||
| platform: darwin | ||
| arch: arm64 | ||
| - name: Windows x64 / Node 24 | ||
| runner: windows-2025 | ||
| node: '24' | ||
| platform: win32 | ||
| arch: x64 | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||
| with: | ||
| node-version: ${{ matrix.node }} | ||
| - name: Select the release npm toolchain | ||
| run: npm install --global --no-audit --no-fund npm@11.12.1 | ||
| - name: Assert the runner architecture | ||
| env: | ||
| EXPECTED_PLATFORM: ${{ matrix.platform }} | ||
| EXPECTED_ARCH: ${{ matrix.arch }} | ||
| run: | | ||
| node -e "if (process.platform !== process.env.EXPECTED_PLATFORM || process.arch !== process.env.EXPECTED_ARCH) throw new Error('Expected ' + process.env.EXPECTED_PLATFORM + '/' + process.env.EXPECTED_ARCH + ', found ' + process.platform + '/' + process.arch)" | ||
| - name: Download the release candidate | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: cli-release-candidate | ||
| path: packages/cli/release | ||
| - name: Validate the installed tarball | ||
| run: node scripts/smoke-release-cli-package.mjs | ||
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,22 @@ | ||
| // The first installable proof tarball was 15,005,877 compressed bytes, | ||
| // 77,684,229 unpacked bytes, and 7,511 entries. These ceilings preserve | ||
| // deliberate headroom while making an accidental dependency/content spike a | ||
| // reviewed release change instead of silently shipping it. | ||
| export const CLI_RELEASE_ARTIFACT_LIMITS = Object.freeze({ | ||
| compressedBytes: 18 * 1024 * 1024, | ||
| unpackedBytes: 90 * 1024 * 1024, | ||
| entryCount: 9_000, | ||
| }); | ||
|
|
||
| export function validateCliReleaseArtifactMetrics(metrics) { | ||
| for (const key of ['compressedBytes', 'unpackedBytes', 'entryCount']) { | ||
| const value = metrics[key]; | ||
| if (!Number.isSafeInteger(value) || value < 0) { | ||
| throw new Error(`CLI release artifact ${key} must be a non-negative safe integer`); | ||
| } | ||
| const limit = CLI_RELEASE_ARTIFACT_LIMITS[key]; | ||
| if (value > limit) { | ||
| throw new Error(`CLI release artifact ${key} is ${value}; limit is ${limit}`); | ||
| } | ||
| } | ||
| } |
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,40 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { describe, test } from 'node:test'; | ||
| import { | ||
| CLI_RELEASE_ARTIFACT_LIMITS, | ||
| validateCliReleaseArtifactMetrics, | ||
| } from './release-cli-artifact-policy.mjs'; | ||
|
|
||
| describe('CLI release artifact policy', () => { | ||
| test('accepts the established proof-tarball baseline', () => { | ||
| assert.doesNotThrow(() => | ||
| validateCliReleaseArtifactMetrics({ | ||
| compressedBytes: 15_005_877, | ||
| unpackedBytes: 77_684_229, | ||
| entryCount: 7_511, | ||
| }), | ||
| ); | ||
| }); | ||
|
|
||
| test('rejects each metric above its reviewed ceiling', () => { | ||
| for (const key of Object.keys(CLI_RELEASE_ARTIFACT_LIMITS)) { | ||
| const metrics = { | ||
| ...CLI_RELEASE_ARTIFACT_LIMITS, | ||
| [key]: CLI_RELEASE_ARTIFACT_LIMITS[key] + 1, | ||
| }; | ||
| assert.throws(() => validateCliReleaseArtifactMetrics(metrics), new RegExp(key)); | ||
| } | ||
| }); | ||
|
|
||
| test('rejects malformed metrics instead of coercing them', () => { | ||
| assert.throws( | ||
| () => | ||
| validateCliReleaseArtifactMetrics({ | ||
| compressedBytes: Number.NaN, | ||
| unpackedBytes: 1, | ||
| entryCount: 1, | ||
| }), | ||
| /compressedBytes/, | ||
| ); | ||
| }); | ||
| }); |
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.
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.
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.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: maka-agent/maka-agent
Length of output: 8024
🏁 Script executed:
Repository: maka-agent/maka-agent
Length of output: 2445
🏁 Script executed:
Repository: maka-agent/maka-agent
Length of output: 591
Pin npm’s dependency tree, not only its version.
The root
package.jsonpinsnpm@11.12.1, but the published package has no lockfile or shrinkwrap and declares 65 dependencies. Both global installs can therefore resolve transitive dependencies outside the repository lockfile. Add a reviewed mechanism that pins the complete npm toolchain.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 82-82: ad-hoc installation of packages (adhoc-packages): installs a package outside of a lockfile
(adhoc-packages)
Sources: Path instructions, Linters/SAST tools