Repository navigation
ci: opt out of manual publish approval - W-24872687 - #819
Conversation
|
This PR lacks any commits of the 'fix' or 'feat' type, and therefore will not trigger a release. To silence all further warnings, react to this warning comment (or any other) with the 👀 emoji. NOTE: If your repo uses squash commits, make sure to add the appropriate conventional commit prefix (e.g., 'fix:', 'feat:', 'chore:', etc) in the squash commit message. |
E2E Test Results SummaryRun: 2171 Test Results
Passing Rate by File
ArtifactsView detailed test reports in the Artifacts section. Some tests failed |
E2E Test Results SummaryRun: 2178 Test Results
Passing Rate by File
ArtifactsView detailed test reports in the Artifacts section. Some tests failed |
madhur310
left a comment
There was a problem hiding this comment.
Automated review pass focused on correctness and maintainability. One confirmed correctness bug, plus several duplication/staleness findings below. The previously-flagged blocker (require-approval: 'false' relying on an input that didn't exist on vscode-manual-publish.yml@main) is now resolved since salesforcecli/github-workflows#209 merged — no comment needed for that one.
One more not inlined because the file isn't touched by this diff: .github/workflows/release-npm.yml's header comment (line 5) still says the extension API "must be released only with its matching VSIX through publish-extension-api.yml", but that workflow is neutered to a stub pointing at paired-hotfix-release.yml by this PR. Worth a follow-up to update that comment.
| [ | ||
| 'log', | ||
| '--format=%B%x00', | ||
| `${baselineTag}..${resolvedSourceSha}`, |
There was a problem hiding this comment.
git log baselineTag..resolvedSourceSha only checks reachability, not ancestry — it doesn't verify resolvedSourceSha actually descends from baselineTag. If source_sha is on a branch that forked from a point before the last apex-language-server-extension-api-v* tag (e.g. a long-lived hotfix branch), git describe can still resolve some reachable tag as the "baseline", and this range will enumerate that divergent branch's own commits as if they were ahead of the real last release. That lets a hotfix compute/publish an API version relative to the wrong baseline without erroring. Worth adding an explicit ancestry check (e.g. git merge-base --is-ancestor baselineTag resolvedSourceSha) before trusting the commit range.
| - name: Checkout paired release source | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ inputs.source_sha }} | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Assert checkout identity | ||
| id: source | ||
| run: | | ||
| SHA=$(git rev-parse HEAD) | ||
| [ "$SHA" = "${SOURCE_SHA,,}" ] || { echo 'Checkout SHA mismatch.'; exit 1; } | ||
| echo "sha=$SHA" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Enable Corepack | ||
| run: corepack enable | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: '22.x' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile |
There was a problem hiding this comment.
This checkout/Corepack/setup-node/install block is repeated verbatim across verify-source, marketplace-guard (lines ~269-285), and verify-host-publication (lines ~373-389) in this same file (and again in resume-paired-hotfix-api.yml's verify-prior-pair). Worth factoring into a composite action to keep the copies from drifting.
| metadata.hostPublication = { status: 'version-available', checkedAt: new Date().toISOString(), | ||
| version: metadata.sourceHostPackageVersion, immutableIdentityVerified: false }; | ||
| fs.writeFileSync(path, JSON.stringify(metadata, null, 2) + '\n'); | ||
| NODE | ||
|
|
||
| - name: Upload Marketplace guard metadata | ||
| if: always() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: paired-marketplace-guard-${{ github.run_id }} | ||
| overwrite: true | ||
| path: api-release/extension-api-release.json | ||
| if-no-files-found: error | ||
| retention-days: 90 |
There was a problem hiding this comment.
hostPublication: { status: 'version-available', ... } is written here but nothing downstream reads it — verify-host-publication later overwrites metadata.hostPublication with its own status: 'verified' object without checking this one first. Likewise the paired-marketplace-guard-* artifact uploaded below doesn't appear to be consumed by any later job. If neither is used for anything beyond debugging, consider dropping them.
| STATUS=$(curl --silent --show-error --output api-release/registry-response.json --write-out '%{http_code}' \ | ||
| "https://registry.npmjs.org/@salesforce%2Fapex-language-server-extension-api/$API_VERSION") | ||
| case "$STATUS" in | ||
| 404) ;; | ||
| 200) echo 'API version already exists and is immutable.'; exit 1 ;; | ||
| *) echo "Registry lookup failed: HTTP $STATUS"; exit 1 ;; | ||
| esac |
There was a problem hiding this comment.
This 404-or-fail-closed registry check duplicates the identical case "$STATUS" block in api-version-guard above (lines 330-336). Could be a shared step/composite action instead of two copies.
| const view = spec => JSON.parse(execFileSync('npm', ['view', spec, '--json', '--registry=https://registry.npmjs.org', '--prefer-online'], { encoding: 'utf8' })); | ||
| const version = view(`${process.env.PACKAGE_NAME}@${process.env.API_VERSION}`); | ||
| const tags = view(process.env.PACKAGE_NAME)['dist-tags']; |
There was a problem hiding this comment.
view(pkg@version) and view(pkg) here are two separate npm view network calls per retry attempt, but npm view <pkg>@<version> --json alone already includes the package-wide dist-tags map in its output (confirmed against the public registry) — so the second call is redundant and could be dropped to halve the registry calls in this retry loop. Same pattern repeats in resume-paired-hotfix-api.yml's publish-api job.
| - name: Verify Marketplace host checksum | ||
| run: | | ||
| node <<'NODE' | ||
| const assert = require('node:assert/strict'); | ||
| const fs = require('node:fs'); | ||
| const { execFileSync } = require('node:child_process'); | ||
| const path = 'api-release/extension-api-release.json'; | ||
| const metadata = JSON.parse(fs.readFileSync(path, 'utf8')); | ||
| const marketplace = JSON.parse(execFileSync('pnpm', ['exec', 'vsce', 'show', 'salesforce.apex-language-server-extension', '--json'], | ||
| { cwd: 'packages/apex-lsp-vscode-extension', encoding: 'utf8' })); | ||
| assert(Array.isArray(marketplace.versions), 'Marketplace response must include versions'); | ||
| const versions = marketplace.versions.filter(entry => entry.targetPlatform !== 'web' && entry.version === metadata.sourceHostPackageVersion); | ||
| assert.equal(versions.length, 1, 'Expected exactly one matching non-web Marketplace host version'); | ||
| const checksums = (versions[0].properties || []).filter(property => property.key === 'Microsoft.VisualStudio.Services.VsixSha256'); | ||
| assert.equal(checksums.length, 1, 'Expected Marketplace VSIX SHA256 property'); | ||
| const sha256 = checksums[0].value; | ||
| assert.match(sha256, /^[0-9a-f]{64}$/i, 'Expected valid Marketplace VSIX SHA256'); | ||
| assert.equal(sha256.toLowerCase(), metadata.hostVsixSha256, 'Marketplace host checksum must match paired VSIX'); | ||
| NODE |
There was a problem hiding this comment.
Duplicates the Marketplace-checksum verification logic in paired-hotfix-release.yml's verify-host-publication job (lines ~397-415) almost verbatim. Same candidate for extraction as the other duplicated blocks between this file and the main paired-hotfix-release.yml.
| - name: Publish or verify the paired API tarball | ||
| id: npm | ||
| run: | | ||
| node <<'NODE' | ||
| const assert = require('node:assert/strict'); | ||
| const crypto = require('node:crypto'); | ||
| const { execFileSync } = require('node:child_process'); | ||
| const fs = require('node:fs'); | ||
| const metadataPath = 'api-release/extension-api-release.json'; | ||
| const metadata = JSON.parse(fs.readFileSync(metadataPath, 'utf8')); | ||
| const tarball = fs.readFileSync('api-release/extension-api.tgz'); | ||
| assert.equal(crypto.createHash('sha256').update(tarball).digest('hex'), metadata.tarballSha256, 'API tarball checksum must match original metadata'); | ||
| const integrity = 'sha512-' + crypto.createHash('sha512').update(tarball).digest('base64'); | ||
| const view = spec => JSON.parse(execFileSync('npm', ['view', spec, '--json', '--registry=https://registry.npmjs.org', '--prefer-online'], { encoding: 'utf8' })); | ||
| let version; | ||
| try { | ||
| version = view(`${process.env.PACKAGE_NAME}@${process.env.API_VERSION}`); | ||
| assert(version && typeof version === 'object', 'Expected npm version metadata'); | ||
| } catch (error) { | ||
| let code; | ||
| try { code = JSON.parse(String(error.stdout)).error?.code; } catch {} | ||
| if (code !== 'E404') throw error; | ||
| } | ||
| if (!version) { | ||
| execFileSync('npm', ['publish', './api-release/extension-api.tgz', '--access', 'public', '--tag', process.env.DIST_TAG, '--ignore-scripts', '--registry=https://registry.npmjs.org'], { stdio: 'inherit' }); | ||
| } | ||
| let verified = false; | ||
| for (let attempt = 0; attempt < 6; attempt++) { | ||
| try { | ||
| const actualVersion = view(`${process.env.PACKAGE_NAME}@${process.env.API_VERSION}`); | ||
| const tags = view(process.env.PACKAGE_NAME)['dist-tags']; | ||
| metadata.npmVerification = { checkedAt: new Date().toISOString(), version: actualVersion.version, | ||
| distTag: process.env.DIST_TAG, distTagVersion: tags[process.env.DIST_TAG], integrity: actualVersion.dist.integrity }; | ||
| verified = actualVersion.version === process.env.API_VERSION && tags[process.env.DIST_TAG] === process.env.API_VERSION && actualVersion.dist.integrity === integrity; | ||
| metadata.npmVerification.verified = verified; | ||
| } catch (error) { | ||
| metadata.npmVerification = { checkedAt: new Date().toISOString(), verified: false, error: error.message }; | ||
| } | ||
| fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2) + '\n'); | ||
| if (verified) break; | ||
| if (attempt < 5) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10000); | ||
| } | ||
| if (!verified) throw new Error('Post-publish npm verification failed; inspect release metadata'); | ||
| if (version) console.log('npm version already matches the verified paired tarball'); | ||
| NODE |
There was a problem hiding this comment.
This publish-and-verify retry loop duplicates paired-hotfix-release.yml's publish-api job (lines ~458-500) almost line-for-line, including the Atomics.wait sleep idiom. Given how easy it'd be for these two copies to silently diverge on a retry-count or backoff tweak, this seems worth sharing via a script/composite action rather than copy-pasting.
| - name: Stage flat extension VSIX artifacts | ||
| if: ${{ inputs.flatten-vsix-artifacts }} | ||
| run: | | ||
| mkdir -p vsix-staging | ||
| shopt -s nullglob | ||
| VSIX_FILES=(packages/apex-lsp-vscode-extension/*.vsix) | ||
| [ "${#VSIX_FILES[@]}" -gt 0 ] || { echo 'No extension VSIXs found.'; exit 1; } | ||
| for vsix in "${VSIX_FILES[@]}"; do | ||
| cp "$vsix" vsix-staging/ | ||
| done |
There was a problem hiding this comment.
Two things here: (1) this flatten path only copies *.vsix and drops the checksum files (*.vsix.md5, checksums.md5, checksums.json) that the non-flattened upload path includes — if any downstream consumer of the flattened artifact expects checksums, they'll be silently missing. (2) flatten-vsix-artifacts is a boolean added to this shared package.yml purely to serve paired-hotfix-release.yml's one caller; worth confirming this is intended to become general-purpose rather than a special case bolted onto shared infra for a single pipeline.
| if (process.env.SHARED_WORKFLOWS_DIR) { | ||
| const shared = readFileSync(join(process.env.SHARED_WORKFLOWS_DIR, '.github/workflows/vscode-manual-publish.yml'), 'utf8'); | ||
| const action = readFileSync(join(process.env.SHARED_WORKFLOWS_DIR, '.github/actions/publish-vsix/action.yml'), 'utf8'); |
There was a problem hiding this comment.
This cross-repo contract test (comparing against salesforcecli/github-workflows's vscode-manual-publish.yml / publish-vsix/action.yml) only runs when SHARED_WORKFLOWS_DIR is set, but no workflow or script in this repo sets that env var — so as far as I can tell this never actually runs in CI and would only catch drift if someone runs it manually with that checkout present locally.
| assert.match(workflow, /extension\/package\.json/, 'inspects packaged host identity'); | ||
| assert.match(workflow, /createHash\('sha256'\)/, 'computes host checksum from VSIX bytes'); | ||
| assert.match(workflow, /marketplace-guard:[\s\S]*?needs: \[verify-source, verify-pair\]/, 'checks publication safety after recording artifact identity'); | ||
| assert.doesNotMatch(workflow, /No safe Marketplace identity verification path/, 'removes unconditional publication blocker'); |
There was a problem hiding this comment.
Minor: this assertion checks that the workflow text doesn't contain the literal string "No safe Marketplace identity verification path" — git log -S shows that exact string never existed anywhere in this repo's history before this PR's own commit, so the assertion isn't guarding against a real prior regression. Not a bug, just flagging in case it was meant to reference wording that got renamed/reworded differently than intended.
|
@madhur310 I have addressed the baseline ancestry validation and removed the inactive cross-repository contract-test block. I also corrected the stale header to point to . Are there any additional details or concerns you want addressed beyond the current review threads? |
|
Correction to my prior comment: I have addressed the baseline ancestry validation and removed the inactive cross-repository contract-test block. I also corrected the stale |
E2E Test Results SummaryRun: 2205 Test Results
Passing Rate by File
ArtifactsView detailed test reports in the Artifacts section. Some tests failed |
E2E Test Results SummaryRun: 2205 Test Results
Passing Rate by File
Specs With No ResultsThe following specs did not produce test results. This usually means the job crashed before tests ran (e.g. build failure, infra error, dependency download timeout).
ArtifactsView detailed test reports in the Artifacts section. Some tests failed or did not run |
Summary
0.11.75.Dependency
Requires salesforcecli/github-workflows#209 to merge first, because it adds the shared
require-approvalinput.Test Plan
YAML.load_file.git diff --check.@W-24872687@