Simpler structure for configuration.

Open
#715 9 comments 7 reactions 0 assignees View on GitHub

@joshdales is already working on this.

Since Feb 16, 2025.

  • #847 by @joshdales — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
ci-cd

Research direction

The issue does not name specific files or tests; start by locating the TypeScript configuration parser and its configuration tests. Done means the proposed mapping-based YAML structure is accepted, its schema and related behavior are covered, and existing configuration handling remains consistent with the v5 format.

Written by the indexing model from the issue text.

Description

feature request

Description:

Instead of requiring every single level of keys below the top level in the configuration file to have a list as a value, restructure to use mappings whenever possible.

In effect, change the config structure so that the following:

some_label:
  - any:
      - changed-files:
          - any-glob-to-any-file:
              - pattern1
              - pattern2
  - all:
      - head-branches:
          - pattern3
      - base-branches:
          - pattern4

instead is represented like this:

some_label:
  any:
    changed-files:
      any-glob-to-any-file:
        - pattern1
        - pattern2
  all:
      head-branches:
        - pattern3
      base-branches:
        - pattern4

Justification:

The config format used in v4 utilized type based discrimination of the list items for each label in the config to maintain backwards compatibility despite the addition of the all and any syntax. I would argue that requiring a list in this case was less than ideal (JS/TS should be able to easily differentiate between an array and an object, and that type of differentiation would have made the config a bit easier to understand logically), but the backwards compatibility aspect was useful because the new config parser still supported the old format.

With v5 though, this habit of making value under each label be a list of objects or strings was kept and further propagated to the new ‘sub’ configuration items, despite the fact that the new config format is not at all backwards compatible with the old formats.

This has a number of distinct disadvantages for end users:

  • The resultant config files include excess boilerplate structure that do not contribute anything to the actual meaning of the configuration, opening up significant possibility of confusion on the part of users who are trying to understand (or write) a given configuration.
  • This format is at best rather difficult to write an accurate schema for, if not outright impossible depending on how pedantic you want to be. This makes it harder for users to validate the config file before committing it or before merging changes to it, which is particularly significant because the normal usage of this action as a pull_request_target hook instead of a pull_request hook means that an invalid config file won’t actually show any errors until after it’s merged, at which point it will fail workflow runs on unrelated PRs.

I also strongly suspect that the code doing the parsing is, in fact, more complex than it would need to be if this proposal were implemented, so this may have long-term benefits for the maintainability of the code.

Are you willing to submit a PR?

Unfortunately not, as I have no background working with TypeScript and recognize that this will probably require some nontrivial changes to the code that parses the config file.

Dominant language
TypeScript
Stars
2.5k
Forks
488
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from actions/labeler

All issues in actions/labeler

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.