Skip to content

refactor: remove custom getInput/getBooleanInput wrappers#66

Merged
joshjohanning merged 8 commits into
mainfrom
remove-custom-getinput
Mar 30, 2026
Merged

refactor: remove custom getInput/getBooleanInput wrappers#66
joshjohanning merged 8 commits into
mainfrom
remove-custom-getinput

Conversation

@joshjohanning

@joshjohanning joshjohanning commented Mar 29, 2026

Copy link
Copy Markdown
Owner

Remove the custom getInput() and getBooleanInput() wrapper functions and replace with direct core.getInput() and core.getBooleanInput() calls.

Why

The custom wrappers added a fallback that converted dashes to underscores in env var names (INPUT_WHO_TO_GREET instead of INPUT_WHO-TO-GREET). This was meant to help with local development since shells can't export vars with hyphens, but core.getInput() already reads INPUT_* env vars on its own - the wrapper was redundant.

Changes

  • Removed getInput() and getBooleanInput() functions from src/index.js
  • Replaced getInput() calls with core.getInput()
  • Replaced getBooleanInput() calls with core.getBooleanInput() for proper case-insensitive boolean handling per YAML 1.2 Core Schema
  • Updated local dev header comments to document how core.getInput() works with env vars
  • Version bump: 2.0.0 -> 2.0.1

Replace with direct core.getInput() calls. The custom wrappers added
a redundant env var fallback (dash-to-underscore conversion) that
core.getInput() effectively handles on its own.

Update local dev header comments to reflect how core.getInput() reads
INPUT_<NAME> env vars with hyphens preserved.
Copilot AI review requested due to automatic review settings March 29, 2026 16:23
@joshjohanning

Copy link
Copy Markdown
Owner Author

@copilot I see we lowered our code coverage a bit, unsure if there are obvious candidate tests to add w/o being explicitly verbose or inane.

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 the action to remove custom input wrapper helpers and rely directly on @actions/core input APIs, simplifying input handling and updating local-development guidance accordingly.

Changes:

  • Removed custom getInput() / getBooleanInput() helpers and switched callers to core.getInput().
  • Updated local-development comment block to document hyphenated INPUT_* env var behavior.
  • Bumped package version and refreshed the coverage badge.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/index.js Removes input wrapper helpers, switches to core.getInput(), and updates local-dev instructions.
package.json Bumps package version to 2.0.1.
badges/coverage.svg Updates the displayed coverage percentage.

Comment thread src/index.js Outdated

Copilot AI commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

@copilot I see we lowered our code coverage a bit, unsure if there are obvious candidate tests to add w/o being explicitly verbose or inane.

Added two meaningful tests in commit 5519990:

  1. "should log and output repo stats when token and API data are available" — covers the block (lines 110-120) where repo stats are fetched, logged, and set as the repo-stats output. The existing token test didn't mock repos.get, so getRepoStats silently returned null and that block was never reached.

  2. "should fall back to console logging when summary write fails" — covers the inner catch block (lines 151-153) that logs results to console when core.summary.write() rejects.

Also fixed a pre-existing mock leak while I was at it: the "should handle errors gracefully" test was using mockImplementation (persistent) to make setOutput throw, which silently poisoned all subsequent tests. Changed it to mockImplementationOnce so the throw only fires once.

Coverage improved from 72.91% → 97.91% statements and 48% → 80% branches. The only uncovered line remaining is the import.meta.url direct-execution guard, which isn't practically testable in Jest.

Addresses Copilot review feedback — the previous === 'true' check was
case-sensitive and would silently treat True/TRUE as false.
core.getBooleanInput handles case variations per the Actions API.

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

Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/index.js
Comment thread __tests__/index.test.js
Prevents mock return value from persisting across tests since
jest.clearAllMocks does not reset mock implementations.

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

Copilot reviewed 3 out of 5 changed files in this pull request and generated 3 comments.

Comment thread src/index.js Outdated
Comment thread __tests__/index.test.js Outdated
Comment thread __tests__/index.test.js Outdated
- Use mockReturnValueOnce/mockResolvedValueOnce/mockRejectedValueOnce
  to prevent mock state leaking across tests
- Remove 'inline assignment' wording from local dev docs for
  consistency with other repos

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

Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/index.js
Comment thread __tests__/index.test.js
- Update README to use env(1) with hyphenated INPUT_* names,
  consistent with header comment and other repos
- Set getBooleanInput default to false in beforeEach for realistic
  mock behavior

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

Copilot reviewed 4 out of 6 changed files in this pull request and generated no new comments.

@joshjohanning joshjohanning merged commit 119c81b into main Mar 30, 2026
8 checks passed
@joshjohanning joshjohanning deleted the remove-custom-getinput branch March 30, 2026 20:20
@github-actions

Copy link
Copy Markdown

📦 Draft Release Created

A draft release v2.0.1 has been created for this PR.

🔗 View Draft Release

Next Steps

  • Review the release notes
  • Publish the release to make it permanent

This is an automated reminder from the publish-github-action workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants