Conversation
… normalization The two-key lookup pattern for normalizing GitHub Actions inputs (handling both INPUT_X and INPUT_X-HYPHEN forms) was introduced in PR #24823 and repeated in three places: index.js, action_setup_otlp.cjs, and action_conclusion_otlp.cjs. Extract a getActionInput(name) helper in action_input_utils.cjs that: - Checks both the underscore (standard) and hyphen (some runner versions) forms - Trims whitespace from the result (aligning with GitHub Actions conventions) - Documents the rationale once, rather than repeating it at each call site This reduces code duplication, removes repetitive comments, and makes it easy to add new inputs with the same normalization in the future. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors duplicated GitHub Actions input env-var normalization (underscore vs hyphen forms) into a shared helper to keep behavior consistent across setup/conclusion OTLP scripts and the setup action entrypoint.
Changes:
- Added shared
getActionInput(name)helper for underscore/hyphen lookup with trimming. - Added unit tests covering lookup precedence and trimming behavior.
- Replaced duplicated inline normalization logic in
index.js,action_setup_otlp.cjs, andaction_conclusion_otlp.cjswith helper calls.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/action_input_utils.cjs | New helper to read INPUT_* values across underscore/hyphen variants. |
| actions/setup/js/action_input_utils.test.cjs | New vitest unit coverage for helper behavior (fallback, precedence, trim). |
| actions/setup/js/action_setup_otlp.cjs | Uses helper for TRACE_ID and JOB_NAME normalization before span export/env propagation. |
| actions/setup/js/action_conclusion_otlp.cjs | Uses helper for JOB_NAME normalization when constructing conclusion span name. |
| actions/setup/index.js | Uses helper for three inputs and centralizes the runner hyphen-variant explanation. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 1
|
|
||
| /** | ||
| * Read a GitHub Actions input value, handling both the standard underscore form | ||
| * (INPUT_<NAME>) and the hyphen form (INPUT_<NAM-E>) preserved by some runner versions. |
There was a problem hiding this comment.
Doc comment uses the placeholder INPUT_<NAM-E>, which looks like a typo and is confusing (it suggests a character was dropped). Consider rewording to something like INPUT_<NAME-WITH-HYPHENS> or giving a concrete example (e.g. INPUT_JOB-NAME) so the underscore vs hyphen forms are unambiguous.
Suggested change
| * (INPUT_<NAME>) and the hyphen form (INPUT_<NAM-E>) preserved by some runner versions. | |
| * (INPUT_<NAME>) and the hyphen form (INPUT_<NAME-WITH-HYPHENS>) preserved by some runner versions. |
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.
The two-key lookup pattern for normalizing GitHub Actions inputs (handling both
INPUT_XandINPUT_X-HYPHENforms) was introduced in PR #24823 and duplicated across three files:index.js,action_setup_otlp.cjs, andaction_conclusion_otlp.cjs.Files Simplified
actions/setup/js/action_input_utils.cjs(new) — sharedgetActionInput(name)helper that checks both underscore and hyphen env var forms and trims the resultactions/setup/js/action_input_utils.test.cjs(new) — unit tests for the helperactions/setup/js/action_setup_otlp.cjs— replaced two verbose inline normalization blocks withgetActionInput("TRACE_ID")andgetActionInput("JOB_NAME")actions/setup/js/action_conclusion_otlp.cjs— replaced inline normalization block withgetActionInput("JOB_NAME")actions/setup/index.js— replaced three separate multi-line normalization blocks with threegetActionInput()callsImprovements Made
action_input_utils.cjs) instead of being repeated at every call siteChanges Based On
Recent changes from:
Testing
getActionInput(5 tests, all pass)action_conclusion_otlp.cjspass (21 tests)action_setup_otlp.cjspass (20 tests, 1 pre-existing timing flake unrelated to this change)make lint-cjs)Review Focus
Please verify:
getActionInputhelper is a clean, well-named abstraction.trim()now being applied uniformly (previouslyindex.jsdid not trim — whitespace in input values would be unusual but.trim()aligns with GitHub Actions conventions)Automated by Code Simplifier Agent - analyzing code from the last 24 hours