Skip to content

[jsweep] Clean action_setup_otlp.cjs#34578

Merged
pelikhan merged 1 commit into
mainfrom
signed/jsweep/action-setup-otlp-b85448b5477bc57e
May 25, 2026
Merged

[jsweep] Clean action_setup_otlp.cjs#34578
pelikhan merged 1 commit into
mainfrom
signed/jsweep/action-setup-otlp-b85448b5477bc57e

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 25, 2026

Summary

This PR cleans up action_setup_otlp.cjs as part of the jsweep initiative. It removes an unused path module import, replaces a dynamic path.join(__dirname, ...) require with a static relative require, and refactors writeEnvLine to accept an explicit fileLabel parameter instead of inferring the destination file name by comparing paths against process.env.GITHUB_OUTPUT.

Changes

File Change type Detail
actions/setup/js/action_setup_otlp.cjs modified Remove unused path import, static relative require, explicit fileLabel param on writeEnvLine
actions/setup/js/action_setup_otlp.test.cjs modified Add INPUT_PARENT_SPAN_ID handling test suite covering absent, present, normalised, hyphen-fallback, and env-var-backfill cases

Motivation & context

Part of the ongoing jsweep cleanup pass across the actions/setup/js/ files. The path import was dead code, the dynamic require was unnecessary complexity, and the implicit destination-file inference in writeEnvLine was fragile. Making fileLabel explicit improves readability and removes a hidden dependency on process.env.GITHUB_OUTPUT comparisons inside the helper.

Impact assessment

Dimension Assessment
Breaking change No – purely internal refactor; public behaviour is unchanged
Test coverage New INPUT_PARENT_SPAN_ID handling test suite added covering five scenarios: absent input, present value, uppercase normalisation, hyphen-form fallback, and env-var backfill
Runtime behaviour No observable change at runtime; the refactor preserves existing logic while removing the dynamic path resolution

Testing

The updated test file adds a dedicated INPUT_PARENT_SPAN_ID handling suite that exercises: (1) missing input being handled gracefully, (2) a valid parent span ID being written correctly, (3) uppercase input being normalised, (4) the hyphen-form alias falling back as expected, and (5) an env-var backfill path being exercised when the value is already set in the environment.

Generated by PR Description Updater for issue #34578 · sonnet46 1.4M ·

- Remove unused `path` module dependency; use `require('./send_otlp_span.cjs')` directly
- Add explicit `fileLabel` parameter to `writeEnvLine` to remove fragile
  `filePath === process.env.GITHUB_OUTPUT` comparison
- Add 6 new tests covering INPUT_PARENT_SPAN_ID handling (pass-through,
  lowercase normalisation, logging, hyphen-form fallback, env-var normalisation)

All 45 tests pass (39 original + 6 new).

Co-authored-by: Copilot <[email protected]>
@pelikhan pelikhan marked this pull request as ready for review May 25, 2026 05:26
Copilot AI review requested due to automatic review settings May 25, 2026 05:26
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 25, 2026

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 25, 2026

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #34578 does not have the 'implementation' label and has 0 new lines in default business logic directories (threshold: 100).

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 25, 2026

🧪 Test Quality Sentinel completed test quality analysis.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 25, 2026

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs a small cleanup of the action_setup_otlp.cjs helper used by setup.sh and actions/setup/index.js, and extends the unit tests to cover previously untested INPUT_PARENT_SPAN_ID behavior.

Changes:

  • Simplify send_otlp_span.cjs loading by switching to a relative require() and dropping the unused path dependency.
  • Make writeEnvLine logging more explicit by passing a fileLabel rather than inferring it from runtime path comparisons.
  • Add test coverage for INPUT_PARENT_SPAN_ID parsing/normalization, including hyphen/underscore env-var forms.
Show a summary per file
File Description
actions/setup/js/action_setup_otlp.cjs Removes path usage, simplifies require, and makes env/output write logging explicit via fileLabel.
actions/setup/js/action_setup_otlp.test.cjs Adds tests covering INPUT_PARENT_SPAN_ID normalization, logging, and hyphen-form fallback behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@github-actions github-actions Bot mentioned this pull request May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 75/100 — Acceptable

Analyzed 6 test(s): 6 design, 0 implementation, 0 guideline violation(s).

📊 Metrics & Test Classification (6 tests analyzed)
Metric Value
New/modified tests analyzed 6
✅ Design tests (behavioral contracts) 6 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 3 (50%)
Duplicate test clusters 0
Test inflation detected Yes (49 test lines / 10 prod lines ≈ 4.9:1)
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Issues Detected
should pass parentSpanId=undefined when INPUT_PARENT_SPAN_ID is not set action_setup_otlp.test.cjs ✅ Design Edge case: absent env var → undefined
should pass the parent span ID to sendJobSetupSpan when INPUT_PARENT_SPAN_ID is set action_setup_otlp.test.cjs ✅ Design Happy path only
should normalize INPUT_PARENT_SPAN_ID to lowercase action_setup_otlp.test.cjs ✅ Design Edge case: uppercase normalization
should log the INPUT_PARENT_SPAN_ID value when set action_setup_otlp.test.cjs ✅ Design Happy path only
should accept the hyphen form INPUT_PARENT-SPAN-ID as a fallback action_setup_otlp.test.cjs ✅ Design Edge case: hyphen-form fallback
should set INPUT_PARENT_SPAN_ID env var from the hyphen form when only hyphen form is present action_setup_otlp.test.cjs ✅ Design Side-effect assertion on process.env

Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 0 tests
  • 🟨 JavaScript (*.test.cjs, *.test.js): 6 tests (vitest)

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). Test inflation (4.9:1 test-to-production line ratio) reduced the score from 85 → 75 but does not fail the check — all new lines cover previously-untested INPUT_PARENT_SPAN_ID behavior paths that are genuinely new in this PR.

📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 1M ·

Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Quality Sentinel: 75/100. Test quality is acceptable - 0% of new tests are implementation tests (threshold: 30%).

Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd and /zoom-out — approving with one minor suggestion.

📋 Key Themes & Highlights

Key Themes

  • fileLabel refactor: Clean improvement — the explicit parameter replaces a fragile side-channel env comparison. Only gap: no test verifies that the correct label ("GITHUB_OUTPUT" / "GITHUB_ENV") appears in the logged output at each call site.
  • New INPUT_PARENT_SPAN_ID tests: Six well-structured tests covering the happy path, normalisation, and the hyphen-form fallback. Good addition.

Positive Highlights

  • ✅ Removing the path module dependency is a clean simplification
  • fileLabel parameter makes writeEnvLine self-documenting and removes implicit coupling to process.env
  • ✅ New tests follow the existing suite conventions and are easy to read
  • ✅ All CI checks pass per PR description

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 1.2M


it("should set INPUT_PARENT_SPAN_ID env var from the hyphen form when only hyphen form is present", async () => {
delete process.env.INPUT_PARENT_SPAN_ID;
process.env["INPUT_PARENT-SPAN-ID"] = "aabbccddeeff0011";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] No test verifies the log output from the updated writeEnvLine after the fileLabel refactor.

The PR's main production change is replacing the filePath === process.env.GITHUB_OUTPUT ternary with an explicit fileLabel string — but no test asserts that console.log is called with "GITHUB_OUTPUT" or "GITHUB_ENV". If the wrong label is passed at a call site, tests won't catch it.

💡 Suggested addition
it("should log GITHUB_OUTPUT when writing trace-id to github output", async () => {
  process.env.OTEL_TRACE_ID = "a".repeat(32);
  await run();
  expect(console.log).toHaveBeenCalledWith(
    expect.stringContaining("written to GITHUB_OUTPUT")
  );
});

it("should log GITHUB_ENV when writing trace context to github env", async () => {
  process.env.OTEL_TRACE_ID = "a".repeat(32);
  process.env.GITHUB_ENV = "/tmp/github_env";
  await run();
  expect(console.log).toHaveBeenCalledWith(
    expect.stringContaining("written to GITHUB_ENV")
  );
});

One test per file destination is enough to lock in the intent of the refactor.

@pelikhan pelikhan merged commit 55ce9a5 into main May 25, 2026
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants