[jsweep] Clean action_setup_otlp.cjs#32756
Conversation
Extract writeEnvLine helper to DRY up repetitive appendFileSync + console.log patterns for writing trace/span IDs to GITHUB_OUTPUT and GITHUB_ENV. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors OTLP setup output/env file writes by extracting a small helper to reduce repeated append-and-log blocks without changing behavior.
Changes:
- Added
writeEnvLine(...)helper for GitHub Actions file writes. - Replaced repeated
appendFileSync/console.logblocks with helper calls. - Cached
GITHUB_OUTPUTandGITHUB_ENVenvironment values locally.
Show a summary per file
| File | Description |
|---|---|
actions/setup/js/action_setup_otlp.cjs |
Refactors trace/span ID and job-start timestamp writes to use a shared helper. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /zoom-out and /improve-codebase-architecture — this is a clean refactor/cleanup PR with no behaviour changes.
Key Themes
- Shallow helper abstraction:
writeEnvLinere-inspectsprocess.env.GITHUB_OUTPUTto decide between"GITHUB_OUTPUT"and"GITHUB_ENV"in its log message, leaking the caller's domain back into the helper. The deletion test passes — the helper earns its keep — but its interface can be deepened by removing this reverse-lookup. - Inconsistent
logLabelusage: GITHUB_OUTPUT call sites embed the value in the label (trace-id=${traceId}) while GITHUB_ENV call sites only pass the key name. Uniform format would make log scanning easier.
Positive Highlights
- ✅ Excellent DRY improvement — 6 copy-pasted
if/appendFileSync/console.logblocks reduced to single-line calls - ✅ JSDoc with typed parameters is a nice addition
- ✅ Capturing
githubOutput/githubEnvas localconstis the right instinct for repeated env lookups - ✅
String(Math.floor(nowMs()))ensures type safety with the{string} valuecontract - ✅ 39 existing tests all still pass — no regression risk
Verdict
Approving — both suggestions above are non-blocking improvements to polish an already solid refactor.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · ● 3.4M
|
@copilot review all comments |
The automated Copilot review ( |
|
|
Summary
Cleaned
actions/setup/js/action_setup_otlp.cjsby extracting awriteEnvLinehelper to DRY up the six repetitiveappendFileSync + console.logcall-pairs that wrote trace/span IDs toGITHUB_OUTPUTandGITHUB_ENV.Context
Execution context: Pure Node.js (invoked from
actions/setup/index.jsandsetup.sh) —console.logis the correct output method here.Changes
writeEnvLine(filePath, key, value, logLabel)helper that guards onfilePathandvalue, appends thekey=value\nline, and logs[otlp] <logLabel> written to GITHUB_OUTPUT|GITHUB_ENV.if (...) { appendFileSync(...); console.log(...); }blocks with single-linewriteEnvLine(...)calls.githubOutput/githubEnvinto localconstvariables to avoid repeatedprocess.envlookups.Type Checking
File already had
@ts-check(not@ts-nocheck). Added JSDoc for the newwriteEnvLinehelper. All type errors: none.Test Coverage
Existing test file already has 39 comprehensive tests covering:
SETUP_START_MSvalid / invalid / missing variants (6 cases)INPUT_TRACE_IDnormalization, fallback form, preference (8 cases)INPUT_JOB_NAMEnormalizationGITHUB_OUTPUTwrites (5 cases)GITHUB_ENVwrites (8 cases)No additional tests needed — coverage is already thorough.
Validation
npx prettier --check action_setup_otlp.cjs✅npx tsc --noEmit✅npx vitest run action_setup_otlp.test.cjs— 39/39 passed ✅Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
traces.example.comSee Network Configuration for more information.