[jsweep] Clean action_setup_otlp.cjs#25237
Closed
github-actions[bot] wants to merge 1 commit intomainfrom
Closed
Conversation
- Move dynamic require() of send_otlp_span.cjs from inside run() to module level, enabling consistent testability via CJS module cache patching - Change destructured appendFileSync to fs.appendFileSync pattern so tests can spy on the function through the shared module reference - Remove unused path require (no longer needed after top-level require) - Add comprehensive test file with 29 test cases covering: - OTEL endpoint present/absent behavior - INPUT_TRACE_ID propagation (including hyphen form) - SETUP_START_MS parsing - GITHUB_OUTPUT trace-id writing - GITHUB_ENV trace/span/timestamp writing - Error propagation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Summary
Cleaned
action_setup_otlp.cjs(Node.js context) by improving testability and adding a comprehensive test suite.Context Type
Node.js — This file runs directly via
node action_setup_otlp.cjsfromsetup.shor throughactions/setup/index.js.Changes
action_setup_otlp.cjsrequire()to module level: Therequire(path.join(__dirname, "send_otlp_span.cjs"))insiderun()was moved to a top-levelconst sendOtlpSpan = require("./send_otlp_span.cjs"). This mirrors the pattern inaction_conclusion_otlp.cjsand enables tests to patch module exports via the shared CJS module cache.appendFileSyncpattern: Changedconst { appendFileSync } = require("fs")(destructured, un-mockable) toconst fs = require("fs")withfs.appendFileSync(...)calls. This allowsvi.spyOn(fsMod, "appendFileSync")to intercept calls in tests.pathrequire: No longer needed after eliminating the dynamicpath.join(__dirname, ...)require.action_setup_otlp.test.cjs(new file)Added 29 test cases covering:
runas a functionTest Improvements
Validation ✅
All four checks passed:
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npm run test:js -- --no-file-parallelism action_setup_otlp→ 29/29 passed ✓