Skip to content

Commit 8314d7a

Browse files
committed
chore(wheelhouse): cascade template@722b95b304
Auto-applied by socket-wheelhouse commit-cascade into socket-vscode. 25 file(s) touched: - .git-hooks/fleet/pre-push.mts - .gitattributes - .github/actions/fleet/_shared/install-tool.mjs - .github/actions/fleet/setup/external-tools.generated.json - .github/workflows/cron-weekly-fuzz.yml - .github/workflows/publish-npm.yml - .gitignore - .node-version - .npmrc - AGENTS.md - README.md - package.json - pnpm-workspace.yaml - scripts/repo/bootstrap/fleet.mjs - scripts/repo/test-extension-auth.mts - .git-hooks/fleet - .github/actions/fleet/_shared - scripts/repo/bootstrap - .git-hooks/_shared/push/release-ledger.mts - scripts/fleet/npm/native-artifact-files.mts ... and 5 more
1 parent 024c5a1 commit 8314d7a

23 files changed

Lines changed: 2136 additions & 503 deletions
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { parseRemoteCiGitHubPushUrl } from '../../../scripts/fleet/ci/gates/remote-target.mts'
2+
import {
3+
readInitializationReceipt,
4+
verifyLocalGenesis,
5+
} from '../../../scripts/fleet/release/record/genesis.mts'
6+
import { RELEASE_RECORD_BRANCH } from '../../../scripts/fleet/release/record/model.mts'
7+
8+
export async function verifyReleaseLedgerGenesisPush(
9+
lines: readonly string[],
10+
destination: string,
11+
repositoryPath: string,
12+
): Promise<boolean> {
13+
if (lines.length !== 1) {
14+
return false
15+
}
16+
const fields = lines[0]!.trim().split(/\s+/u)
17+
const [, candidateSha, remoteRef, remoteSha] = fields
18+
if (
19+
fields.length !== 4 ||
20+
remoteRef !== `refs/heads/${RELEASE_RECORD_BRANCH}` ||
21+
remoteSha !== '0'.repeat(40)
22+
) {
23+
return false
24+
}
25+
const repository = parseRemoteCiGitHubPushUrl(destination)
26+
if (!repository) {
27+
return false
28+
}
29+
const receipt = readInitializationReceipt(repository, repositoryPath)
30+
if (
31+
!receipt ||
32+
receipt.state !== 'pending' ||
33+
receipt.sha !== candidateSha ||
34+
receipt.ref !== remoteRef ||
35+
!receipt.freshSetup
36+
) {
37+
return false
38+
}
39+
await verifyLocalGenesis(repository, candidateSha!, repositoryPath)
40+
return true
41+
}

‎.git-hooks/fleet/pre-push.mts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
} from '../_shared/push/repo-gates.mts'
4848
import { scanSignedCommits } from '../_shared/push/signatures.mts'
4949
import { isDurableBackupPush } from '../_shared/push/durable-ref.mts'
50+
import { verifyReleaseLedgerGenesisPush } from '../_shared/push/release-ledger.mts'
5051
import { isSquashHistoryRepo } from '../_shared/push/squash-history.mts'
5152
import { checkPrCommitCount } from '../_shared/push/pr-commit-count.mts'
5253

@@ -62,6 +63,13 @@ const readStdin = (): Promise<string> =>
6263
process.stdin.on('end', () => resolve(buf))
6364
})
6465

66+
function resolvePushArguments(): { remote: string; destination: string } {
67+
return {
68+
remote: process.argv[2] || 'origin',
69+
destination: process.argv[3] ?? '',
70+
}
71+
}
72+
6573
const main = async (): Promise<number> => {
6674
debugCheck('Running mandatory pre-push validation…')
6775

@@ -70,12 +78,16 @@ const main = async (): Promise<number> => {
7078
return 1
7179
}
7280

73-
const remote = process.argv[2] || 'origin'
74-
// url at process.argv[3] is unused.
81+
const { remote, destination } = resolvePushArguments()
7582

7683
const stdin = await readStdin()
7784
let totalErrors = 0
7885
const refLines = splitLines(stdin.trim()).filter(Boolean)
86+
if (
87+
await verifyReleaseLedgerGenesisPush(refLines, destination, process.cwd())
88+
) {
89+
return 0
90+
}
7991
// Every range this push carries, accumulated so the file-oriented gates below
8092
// can scope to the pushed commits instead of the working tree.
8193
const pushedRanges: string[] = []

‎.gitattributes‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,16 @@ patches/fleet/run-local-ci@0.18.1.patch linguist-generated=true
119119
patches/fleet/vitest@5.0.0.patch linguist-generated=true
120120
patches/fleet/vitest@5.0.3.patch linguist-generated=true
121121
scripts/fleet linguist-generated=true
122+
scripts/fleet/npm/native-artifact-files.mts linguist-generated=true
123+
scripts/fleet/npm/native-artifacts.mts linguist-generated=true
124+
scripts/fleet/npm/native/build.mts linguist-generated=true
122125
scripts/fleet/npm/scan/receipt.mts linguist-generated=true
123126
scripts/fleet/npm/scan/staged.mts linguist-generated=true
127+
scripts/fleet/registry/napi-matrix.mts linguist-generated=true
124128
scripts/fleet/registry/npm/scan/ndjson.mts linguist-generated=true
125129
scripts/fleet/registry/npm/scan/run.mts linguist-generated=true
126130
scripts/fleet/registry/npm/staged.mts linguist-generated=true
131+
scripts/fleet/release/record/run.mts linguist-generated=true
127132
scripts/fleet/setup/bootstrap/zero-dep-packages.mjs linguist-generated=true
128133
scripts/fleet/setup/lib/check/sfw.mjs linguist-generated=true
129134
scripts/fleet/setup/lib/error-message.mjs linguist-generated=true

‎.github/actions/fleet/_shared/install-tool.mjs‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,14 @@ export async function readToolArchive({
155155
}
156156
}
157157
}
158-
const response = await fetchToolResponse(url, headers)
159-
if (!response.ok) {
160-
throw new Error(
161-
`Tool download failed at ${url}: saw HTTP ${response.status} ${response.statusText}; wanted a successful response. Check the release URL and access permissions.`,
162-
)
163-
}
164-
return new Uint8Array(await response.arrayBuffer())
158+
return downloadToolArchive(url, headers)
165159
}
166160

167161
function retryableToolDownloadError(error) {
168162
const code = error?.cause?.code ?? error?.code
163+
if (error?.name === 'TimeoutError' || error?.cause?.name === 'TimeoutError') {
164+
return true
165+
}
169166
return [
170167
'ERR_HTTP2_STREAM_ERROR',
171168
'ECONNRESET',
@@ -176,7 +173,22 @@ function retryableToolDownloadError(error) {
176173
].includes(code)
177174
}
178175

176+
async function downloadToolArchive(url, headers) {
177+
return requestToolDownload(url, headers, async response => {
178+
if (!response.ok) {
179+
throw new Error(
180+
`Tool download failed at ${url}: saw HTTP ${response.status} ${response.statusText}; wanted a successful response. Check the release URL and access permissions.`,
181+
)
182+
}
183+
return new Uint8Array(await response.arrayBuffer())
184+
})
185+
}
186+
179187
export async function fetchToolResponse(url, headers) {
188+
return requestToolDownload(url, headers, response => response)
189+
}
190+
191+
async function requestToolDownload(url, headers, consumeResponse) {
180192
for (let attempt = 0; ; attempt++) {
181193
try {
182194
// oxlint-disable-next-line socket/no-fetch-prefer-http-request -- dep-0 bootstrap
@@ -185,13 +197,14 @@ export async function fetchToolResponse(url, headers) {
185197
headers,
186198
signal: AbortSignal.timeout(120_000),
187199
})
188-
if (
189-
attempt === 2 ||
190-
![408, 429, 500, 502, 503, 504].includes(response.status)
191-
) {
192-
return response
200+
if ([408, 429, 500, 502, 503, 504].includes(response.status)) {
201+
if (attempt === 2) {
202+
return await consumeResponse(response)
203+
}
204+
await response.body?.cancel()
205+
} else {
206+
return await consumeResponse(response)
193207
}
194-
await response.body?.cancel()
195208
} catch (error) {
196209
if (attempt === 2 || !retryableToolDownloadError(error)) {
197210
throw error

‎.github/actions/fleet/setup/external-tools.generated.json‎

Lines changed: 5 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/cron-weekly-fuzz.yml‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/publish-npm.yml‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ jobs:
164164
node --input-type=module <<'NODE'
165165
import { appendFileSync } from 'node:fs';
166166
import { resolveRunPlan } from './scripts/fleet/cover/execution.mts';
167+
import { resolveShardCoverageSources } from './scripts/fleet/cover/shard/sources.mts';
167168
const plan = resolveRunPlan(process.cwd());
168169
if (plan.configErrors.length) throw new Error(plan.configErrors.join('\n'));
169170
if (!['bun', 'vitest'].includes(plan.runner)) throw new Error('Unsupported coverage runner. Fix the repository coverage settings.');
171+
if (plan.runner === 'vitest') resolveShardCoverageSources(process.cwd());
170172
appendFileSync(process.env.GITHUB_OUTPUT, `runner=${plan.runner}\n`);
171173
const config = JSON.parse(await (await import('node:fs/promises')).readFile('.config/repo/socket-wheelhouse.json', 'utf8'));
172174
appendFileSync(process.env.GITHUB_OUTPUT, `shared-build=${plan.runner === 'vitest' && Array.isArray(config.build?.coverageArtifacts) && config.build.coverageArtifacts.length > 0}\n`);
@@ -503,6 +505,8 @@ jobs:
503505
# npm's trusted-publisher config pins this GitHub environment name; the
504506
# OIDC token exchange 404s if the job runs outside it.
505507
environment: publish-npm
508+
env:
509+
MBX_REMOTE_URL: ''
506510
permissions:
507511
actions: read
508512
contents: read
@@ -638,6 +642,14 @@ jobs:
638642
fi
639643
echo "dist-tag 'latest' is allowed from $REF (consumable line: $LATEST_BRANCH)."
640644
645+
- name: Snapshot source-bound native controllers
646+
shell: bash
647+
run: |
648+
set -euo pipefail
649+
install -m 0600 scripts/fleet/registry/napi-matrix.mts "$RUNNER_TEMP/napi-matrix.mts"
650+
install -m 0600 scripts/fleet/npm/native/build.mts "$RUNNER_TEMP/native-build.mts"
651+
install -m 0600 scripts/fleet/npm/native-artifact-files.mts "$RUNNER_TEMP/native-artifact-files.mts"
652+
install -m 0600 scripts/fleet/npm/native-artifacts.mts "$RUNNER_TEMP/native-artifacts.mts"
641653
- name: Set up and install
642654
uses: ./.github/actions/fleet/setup-and-install
643655
env:
@@ -652,6 +664,15 @@ jobs:
652664
# key, hydration still pulls public GHCR anonymously.
653665
payload-token-client-id: ${{ steps.content-trust.outputs.trusted == 'true' && (secrets.SOCKET_RELEASE_CLIENT_ID || vars.SOCKET_RELEASE_CLIENT_ID) || '' }}
654666
payload-token-private-key: ${{ steps.content-trust.outputs.trusted == 'true' && secrets.SOCKET_RELEASE_APP_PRIVATE_KEY || '' }}
667+
- name: Restore source-bound native controllers
668+
shell: bash
669+
run: |
670+
set -euo pipefail
671+
mkdir -p scripts/fleet/npm/native
672+
install -m 0600 "$RUNNER_TEMP/napi-matrix.mts" scripts/fleet/registry/napi-matrix.mts
673+
install -m 0600 "$RUNNER_TEMP/native-build.mts" scripts/fleet/npm/native/build.mts
674+
install -m 0600 "$RUNNER_TEMP/native-artifact-files.mts" scripts/fleet/npm/native-artifact-files.mts
675+
install -m 0600 "$RUNNER_TEMP/native-artifacts.mts" scripts/fleet/npm/native-artifacts.mts
655676
- name: Validate publish task name
656677
env:
657678
PUBLISH_TASK_NAME: ${{ inputs.task-name }}
@@ -720,6 +741,7 @@ jobs:
720741
with:
721742
client-id: ${{ secrets.SOCKET_RELEASE_CLIENT_ID || vars.SOCKET_RELEASE_CLIENT_ID }}
722743
private-key: ${{ secrets.SOCKET_RELEASE_APP_PRIVATE_KEY }}
744+
owner: ${{ github.repository_owner }}
723745
repositories: ${{ github.event.repository.name }}
724746
# The version resolver consumes a prerelease hint, uses configured odai
725747
# for patch/minor, or defaults to minor.
@@ -769,6 +791,7 @@ jobs:
769791
GITHUB_TOKEN: ${{ github.token }}
770792
REPOSITORY: ${{ github.repository }}
771793
SERVER_URL: ${{ github.server_url }}
794+
SOURCE_SHA: ${{ github.sha }}
772795
run: |
773796
set -euo pipefail
774797
if [ "$GITHUB_REF" != "refs/heads/$DEFAULT_BRANCH" ]; then
@@ -783,13 +806,17 @@ jobs:
783806
export GIT_CONFIG_COUNT=1
784807
export GIT_CONFIG_KEY_0="http.${SERVER_URL}/.extraheader"
785808
export GIT_CONFIG_VALUE_0="AUTHORIZATION: basic ${AUTH_B64}"
786-
git fetch --no-tags --prune --depth 1 origin "+refs/heads/${DEFAULT_BRANCH}:refs/remotes/origin/${DEFAULT_BRANCH}"
787-
git checkout -q --detach "refs/remotes/origin/${DEFAULT_BRANCH}"
809+
git fetch --no-tags --prune --depth 1 origin "$SOURCE_SHA"
810+
git checkout -q --detach FETCH_HEAD
788811
install -m 0600 scripts/fleet/npm/scan/staged.mts "$RUNNER_TEMP/npm-scan-staged.mts"
789812
install -m 0600 scripts/fleet/npm/scan/receipt.mts "$RUNNER_TEMP/npm-scan-receipt.mts"
790813
install -m 0600 scripts/fleet/registry/npm/scan/ndjson.mts "$RUNNER_TEMP/npm-registry-scan-ndjson.mts"
791814
install -m 0600 scripts/fleet/registry/npm/scan/run.mts "$RUNNER_TEMP/npm-registry-scan.mts"
792815
install -m 0600 scripts/fleet/registry/npm/staged.mts "$RUNNER_TEMP/npm-registry-staged.mts"
816+
install -m 0600 scripts/fleet/registry/napi-matrix.mts "$RUNNER_TEMP/napi-matrix.mts"
817+
install -m 0600 scripts/fleet/npm/native/build.mts "$RUNNER_TEMP/native-build.mts"
818+
install -m 0600 scripts/fleet/npm/native-artifact-files.mts "$RUNNER_TEMP/native-artifact-files.mts"
819+
install -m 0600 scripts/fleet/npm/native-artifacts.mts "$RUNNER_TEMP/native-artifacts.mts"
793820
- name: Verify release source before setup
794821
shell: bash
795822
env:
@@ -877,11 +904,17 @@ jobs:
877904
- name: Restore trusted scan controller
878905
shell: bash
879906
run: |
907+
set -euo pipefail
880908
install -m 0600 "$RUNNER_TEMP/npm-scan-staged.mts" scripts/fleet/npm/scan/staged.mts
881909
install -m 0600 "$RUNNER_TEMP/npm-scan-receipt.mts" scripts/fleet/npm/scan/receipt.mts
882910
install -m 0600 "$RUNNER_TEMP/npm-registry-scan-ndjson.mts" scripts/fleet/registry/npm/scan/ndjson.mts
883911
install -m 0600 "$RUNNER_TEMP/npm-registry-scan.mts" scripts/fleet/registry/npm/scan/run.mts
884912
install -m 0600 "$RUNNER_TEMP/npm-registry-staged.mts" scripts/fleet/registry/npm/staged.mts
913+
mkdir -p scripts/fleet/npm/native
914+
install -m 0600 "$RUNNER_TEMP/napi-matrix.mts" scripts/fleet/registry/napi-matrix.mts
915+
install -m 0600 "$RUNNER_TEMP/native-build.mts" scripts/fleet/npm/native/build.mts
916+
install -m 0600 "$RUNNER_TEMP/native-artifact-files.mts" scripts/fleet/npm/native-artifact-files.mts
917+
install -m 0600 "$RUNNER_TEMP/native-artifacts.mts" scripts/fleet/npm/native-artifacts.mts
885918
- name: Validate publish task name
886919
env:
887920
PUBLISH_TASK_NAME: ${{ inputs.task-name }}

0 commit comments

Comments
 (0)