Skip to content

[code-simplifier] Simplify action_setup_otlp.cjs: dedupe conditional writeEnvLine calls - #52622

Open
github-actions[bot] wants to merge 2 commits into
mainfrom
code-simplifier/otlp-setup-dedup-e2426191b330fb97
Open

[code-simplifier] Simplify action_setup_otlp.cjs: dedupe conditional writeEnvLine calls#52622
github-actions[bot] wants to merge 2 commits into
mainfrom
code-simplifier/otlp-setup-dedup-e2426191b330fb97

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Simplified actions/setup/js/action_setup_otlp.cjs to remove repeated conditional writeEnvLine boilerplate in the run() function's trace/span propagation section.

Files simplified

  • actions/setup/js/action_setup_otlp.cjs

Changes

  • Extracted a small writeIfValid(filePath, key, value, logLabel, fileLabel, isValid) helper inside run() to replace 5 nearly-identical if (isValid...) writeEnvLine(...) lines (3 for GITHUB_OUTPUT, 2 for GITHUB_ENV) with single-line calls.
  • No behavior change: same log messages, same file writes, same conditions (isValidTraceId / isValidSpanId).

Validation

  • make build — passes
  • Targeted vitest run js/action_setup_otlp.test.cjs js/action_otlp.test.cjs — same pass/fail counts before and after the change (14 pre-existing failures at baseline, unrelated to this edit and due to environment/module-mocking issues in this sandbox, not the code change). No new failures introduced.
  • make fmt — no diffs produced by formatter.

Process notes

This run used the deterministic precomputed inputs (recent-context.json, source-files.json, history-summary.json) without re-fetching PR/commit history via GitHub tools, per the token-efficiency guardrails. Candidate files were triaged with a scope-filter pass; most of the 20 candidates were sample/demo/small files or already well-organized (e.g. add_reaction.cjs) and were skipped. purity_scan.go (830 lines) was inspected but judged too risky to simplify without deeper review of its fixed-point analysis logic, so it was left untouched this run.

Recent related activity in the repo (PR #52565 shared-prompt extraction, PR #52542 shared reporting import) reflects an ongoing push toward de-duplicating repeated code across the workflow tooling, which motivated searching for similar opportunities in actions/setup/js.

Generated by 🔧 Code Simplifier · auto · 64.1 AIC · ⌖ 10.4 AIC · ⊞ 9.1K ·

  • expires on Aug 14, 2026, 8:03 PM UTC-08:00

Extract a writeIfValid helper to remove repeated if(isValid...) writeEnvLine(...)
patterns for trace-id/span-id/parent-span-id output and env propagation.
Behavior unchanged; all log messages and file writes are identical.

Source: recent activity around #52565 (shared prompt extraction) and
#52542 (shared reporting import) motivated looking for similar
duplication-reduction opportunities in actions/setup/js.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review August 14, 2026 06:13
Copilot AI balanced review requested due to automatic review settings August 14, 2026 06:13
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

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

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

No actionable review findings for PR #52622 after analyzing the changed lines; no GitHub write beyond completion signal needed.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #52622

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

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

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

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions github-actions Bot left a comment

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.

net: -8 lines possible.

Generated by ✂️ Ponytail Reviewer for #52622 · auto · 17.2 AIC · ⌖ 4.5 AIC · ⊞ 6.8K
Comment /ponytail to run again


// Always expose trace ID as a step output for cross-job correlation, even
// when OTLP is not configured. This ensures needs.*.outputs.setup-trace-id
// is populated for downstream jobs regardless of observability configuration.

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.

L179-189: yagni: 11-line helper (6 params + 8-line JSDoc) replacing 5 near-identical one-line if calls. Diff grew from 5 to 18 lines for the "dedup". Keep the plain if (isValidX(v)) writeEnvLine(...) lines, or shrink the helper to a 1-line arrow fn without the JSDoc.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors OTLP trace/span propagation to reduce repeated validation-and-write logic without changing behavior.

Changes:

  • Adds a local writeIfValid helper.
  • Uses it for five GITHUB_OUTPUT and GITHUB_ENV writes.
Show a summary per file
File Description
actions/setup/js/action_setup_otlp.cjs Deduplicates validation-gated environment/output writes.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions github-actions Bot left a comment

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.

Clean refactor. The new writeIfValid helper correctly eliminates the repeated if (isValid(value)) writeEnvLine(...) pattern without changing any behavior. All call sites are updated consistently.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 16.4 AIC · ⌖ 10.7 AIC · ⊞ 5.4K

@github-actions github-actions Bot left a comment

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.

Skills-Based Review 🧠

Applied /codebase-design — approving with one minor documentation suggestion.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ Clean extraction of repeated if (isValid...) writeEnvLine(...) pattern into a well-documented helper
  • ✅ No behaviour change: same guards, same file writes, same log labels
  • ✅ JSDoc comment aids future readers; @param coverage is good
  • ✅ Build and targeted tests pass; no new failures introduced

Minor Issue

  • The @param {string} value annotation should be {string | undefined} since process.env.* values can be undefined — see inline comment.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 24.2 AIC · ⌖ 7.32 AIC · ⊞ 7K
Comment /matt to run again

Comment thread actions/setup/js/action_setup_otlp.cjs Outdated
* @param {string} fileLabel
* @param {(value: string) => boolean} isValid
*/
const writeIfValid = (filePath, key, value, logLabel, fileLabel, isValid) => {

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.

[/codebase-design] The JSDoc types value as string, but environment variables (process.env.*) are string | undefined. The helper already passes value straight to writeEnvLine after the guard, so the practical risk is low — but the type annotation is misleading.

💡 Suggested fix

Change the @param annotation:

 * `@param` {string | undefined} value

This makes it clear to future readers why the isValid guard is necessary.

@copilot please address this.

@github-actions github-actions Bot mentioned this pull request Aug 14, 2026
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick nudge: this PR looks mergeable. Please run the pr-finisher skill, confirm all review feedback is addressed, and post a concise handoff for maintainers with current merge readiness.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 18 AIC · ⌖ 6.7 AIC · ⊞ 6.1K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@copilot Quick nudge: this PR looks mergeable. Please run the pr-finisher skill, confirm all review feedback is addressed, and post a concise handoff for maintainers with current merge readiness.

...

Update complete on e540029265.

  • Addressed actionable review feedback in actions/setup/js/action_setup_otlp.cjs by shrinking writeIfValid to a one-line guard + write expression and reducing helper docs to only the non-obvious types.
  • Targeted validation passed: npx vitest run js/action_setup_otlp.test.cjs js/action_otlp.test.cjs (69/69 tests).
  • CI snapshot: recent PR runs were successful; one older run was cancelled with no failed jobs. After this push, CI status is stale/unverified until a maintainer re-triggers runs.
  • Current PR state is still mergeable_state=blocked with an unresolved review thread visible in GitHub.

Maintainer handoff: re-trigger CI on current HEAD, resolve the remaining thread if satisfied by commit e540029265, then merge.

Copilot AI requested a review from gh-aw-bot August 14, 2026 06:36
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.

3 participants