actions / actions/toolkit

Factor out `parseYAMLBoolean` from `core.getBooleanInput`

Open
#1,302 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

The (relatively new) function getBooleanInput in core bundles the parsing of a YAML boolean with getInput. However, that parsing functionality would be useful on its own.
I suggest to factor out function parseYAMLBoolean(text: string): boolean from getBooleanInput such that the latter is essentially just a composition of parseYAMLBoolean and getInput:

function getBooleanInput(name: string, options?: InputOptions): boolean { 
  try {
    return parseYAMLBoolean(getInput(name, options));
  } catch ... {
   // Throw the informative error referring to "name" here
  }
}

https://github.com/actions/toolkit/blob/b2d865f18051b214475dae41766e9970fd68ca12/packages/core/src/core.ts#L164-L181

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/core/src/core.ts at getBooleanInput, using the linked lines as the entry point. Separate the YAML boolean parsing into the proposed standalone function while keeping getBooleanInput responsible for the informative error referring to the input name. Done means the parser is independently usable and getBooleanInput still composes it with getInput.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.