actions / actions/toolkit

`@action/glob`: expose a public method to test patterns on given paths

Open
#2,169 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the enhancement
The globber instance returned by glob.create should have a method test(path: string): boolean returning whether the given path matches the patterns provided on creation.

Additional information
Currently @actions/glob only allows to use a pattern to iterate through actual files existing on the runner at the time of execution. There are however use cases where we want to know which files from a given list match against a list of patterns.

We have such a use case where we first fetch the list of files changed by a PR (via a paginated oktokit's rest.pulls.listFiles request), and we want to filter them with a list of patterns, in a way consistent with how glob patterns work across github actions.

@actions/glob would seem like the library of choice for this, but because it insists on providing existing files it's not of immediate use. I ended up recreating a tree structure of empty files from the list of modified files to appease @actions/glob, but a test method would be much more natural to use. As far as I can tell this would just require exporting functionality that is already present in the library implementation.

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 at the @actions/glob implementation behind glob.create and trace the existing pattern-matching functionality that currently operates on files found on the runner. Expose a test(path: string): boolean method that evaluates the supplied path against the creation patterns, and verify it with paths that do and do not match.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.