Repository navigation
runtime-node: detect the running commit and default the release to it; report test under test runners - #55
Merged
Merged
Conversation
…; report test under test runners - One list of commit variables (packages/runtime-node/src/deployment.ts), used by initAutterServer, initAutterLogging, enrichDeployment, `autter-runtime verify` and @autter/runtime-cli's release resolution (bundled into the CLI by path; no new dependency). Only 7-40 hexadecimal characters count as a commit. Never runs git at runtime. - initAutterServer sets the resource attribute deployment.commit whenever a commit is found. - Release default when `release` is unset: AUTTER_RELEASE, else the full detected commit. `release: false` or AUTTER_DETECT_RELEASE=false: none. - Environment default: the option, else NODE_ENV, else `test` when JEST_WORKER_ID, VITEST or NODE_TEST_CONTEXT is set, else `production`. - The CLI's upload release now follows the same order (AUTTER_RELEASE, then the shared commit list, then git rev-parse HEAD) so uploaded maps match the SDK's default release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…variables first in the shared list - The source-map CLI's default release is --release, else AUTTER_RELEASE, else exactly the old rule (first non-empty of GITHUB_SHA, VERCEL_GIT_COMMIT_SHA, CF_PAGES_COMMIT_SHA, GIT_SHA, any value), else the first commit among the SDK's other commit variables, else git HEAD. A build with GITHUB_SHA and GIT_SHA both set, or GIT_SHA=v1.2.3, uploads under the same release as before (and as the browser snippets report). RELEASE_ENV_VARS is the old four again. - The shared commit list puts the CLI's four first, after AUTTER_COMMIT, so the SDK's default release matches the CLI's upload release for a commit in any one variable (tested). - cli.ts --release help, build.ts doc comment and the README describe the rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What users saw
releasesent errors with no release at all, so Autter could not say "broke in release X", resolve the deploy's commit and pull request, or pick the right source maps. Most hosting platforms already put the commit in the environment (VERCEL_GIT_COMMIT_SHA,RENDER_GIT_COMMIT,GITHUB_SHA, ...), but the SDK only read it in the optionalenrichDeployment()enricher, and never put it on the resource.node --test) were reported asproduction, mixed in with real traffic, because the environment fell back toproductionwheneverNODE_ENVwas unset.verify, and the source-map CLI) disagreed on names and order, and none of them checked the value was a commit.What changes
One commit list (
packages/runtime-node/src/deployment.ts,COMMIT_ENV_VARS):AUTTER_COMMIT, GITHUB_SHA, VERCEL_GIT_COMMIT_SHA, CF_PAGES_COMMIT_SHA, GIT_SHA, GIT_COMMIT, COMMIT_SHA, SOURCE_COMMIT, RENDER_GIT_COMMIT, RAILWAY_GIT_COMMIT_SHA, HEROKU_SLUG_COMMIT, SOURCE_VERSION, tried in that order: Autter's own, then the four the source-map CLI has always read, in its order, so the SDK's default release is the release the CLI uploads maps under. Only 7 to 40 hexadecimal characters count as a commit; a variable holding anything else (a branch,refs/heads/main, a tag) is skipped and the next one is tried. The SDK reads environment variables only and never runs git or any subprocess.Used by
initAutterServer,initAutterLogging,enrichDeployment(),npx @autter/runtime-node verify, and@autter/runtime-cli's release resolution.runtime-corecould not hold it: it is a private packageruntime-clidoes not depend on, and making it one would change the CLI's build and package.json. Instead the file is dependency-free andruntime-cli/src/release.tsimports it by path, so tsup bundles it into the CLI (the same pattern asruntime-node/src/verify.tsimportingotlp-ingester/src/compat.ts). The published CLI gains no dependency; there is one definition, not a copy.Commit on the resource:
initAutterServersetsdeployment.commiton the resource (spans and metrics) whenever a commit is found, whatever the release.Release default (behaviour change): when
releaseis not passed, the release isAUTTER_RELEASE, else the detected commit as the full value. An explicitreleasealways wins.release: false, orAUTTER_DETECT_RELEASE=false, reports no release, as before. Same forinitAutterLogging.verifyuses the same default and now sends and reports the commit (commitin--json).Environment default: the
environmentoption, elseNODE_ENV, elsetestwhen a test runner is detected (JEST_WORKER_ID,VITESTorNODE_TEST_CONTEXTset), elseproduction. Explicit values always win. One helper forinitAutterServerandinitAutterLogging.Source-map CLI (unchanged for existing builds): the default upload release is
--release, elseAUTTER_RELEASE(new), else exactly the old rule (the first ofGITHUB_SHA,VERCEL_GIT_COMMIT_SHA,CF_PAGES_COMMIT_SHA,GIT_SHAthat is set, any value, in that order), else (new) the first commit among the SDK's other commit variables, elsegit rev-parse HEAD(build time only). A build withGITHUB_SHAandGIT_SHAboth set, or withGIT_SHA=v1.2.3, uploads under the same release as before, which is also what the browser snippetsautter-runtime setupprints report. The--releasehelp, the plugins' doc comment and the CLI README describe the rule. A test checks that for a commit in any single commit variable the SDK's default release equals the CLI's default release.Places that read the release, checked with a 40-character SHA
symbolicate.ts), and the frame stays as parsed. Browser releases are separate and unchanged.compat.ts) anddoctordo not read the release.service.versionon the logs resource; the ingester keeps up to 200 characters.verify: release step passes with a detected SHA (tested).@autter/runtime-nextpasses options through toinitAutterServer; its tests pass unchanged, also withGITHUB_SHAset. No change there.Tests
packages/runtime-node/test/environment.test.mjs: the helpers (environment order, hex-only commits and the shared order, release order and opt-outs,enrichDeployment), and end to end in child processes against a local collector: whatinitAutterServerputs on its span and log resources and whatinitAutterLoggingputs on its log resource, for each rule. The children get an environment with every variable these rules read removed, because this suite itself runs undernode --test(which setsNODE_TEST_CONTEXT) and CI setsGITHUB_SHA.verify.test.mjs: clears every commit variable in its children; new case for the default release, the commit and the opt-out.runtime-cliupload.test.mjs: release order withAUTTER_RELEASE;GITHUB_SHAstill wins over a differentGIT_SHA;GIT_SHA=v1.2.3is still the release; other commit variables only when they hold a commit.GITHUB_SHA/CIset; runtime-cli, runtime-next and runtime-edge suites pass.Docs and the changelog are written separately for this batch of Runtime changes; this PR does not edit
CHANGELOG.mdordocs/.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.