Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test and documentation for any-glob-to-all-files #733

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Expand Up @@ -69,7 +69,7 @@ The fields are defined as follows:
- `head-branch`: match regexps against the head branch name
- `changed-files`: match glob patterns against the changed paths
- `any-glob-to-any-file`: ANY glob must match against ANY changed file
- `any-glob-to-all-files`: ANY glob must match against ALL changed files
- `any-glob-to-all-files`: ANY SINGLE glob must match against ALL changed files
- `all-globs-to-any-file`: ALL globs must match against ANY changed file
- `all-globs-to-all-files`: ALL globs must match against ALL changed files

Expand Down Expand Up @@ -128,7 +128,19 @@ Documentation:
# Add 'Documentation' label to any change to .md files within the entire repository
Documentation:
- changed-files:
- any-glob-to-any-file: '**/*.md'
- any-glob-to-any-file:
- '*.md'
- '**/*.md'

# Add 'one-resolution' label to any change touching only files in a single directory
one-resolution:
- changed-files:
- any-glob-to-all-files: ['default/*', 'hicolor/*', 'large/*', 'locolor/*', 'mini/*']

# Add 'Audio' label to any change touching only audio files in subdirectories
Audio:
- changed-files:
- any-glob-to-all-files: '{**/*.mp3,**/*.wav,**/*.ogg,**/*.flac}'

# Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
source:
Expand Down
16 changes: 15 additions & 1 deletion __tests__/changedFiles.test.ts
Expand Up @@ -211,8 +211,9 @@ describe('checkIfAllGlobsMatchAnyFile', () => {

describe('checkIfAnyGlobMatchesAllFiles', () => {
const changedFiles = ['foo.txt', 'bar.txt'];
const changedFiles2 = ['foo.txt', 'bar.txt', 'baz.md'];

describe('when any given glob pattern matched all files', () => {
describe('when any single glob pattern matched all files', () => {
const globPatterns = ['*.md', '*.txt'];

it('returns true', () => {
Expand All @@ -225,6 +226,19 @@ describe('checkIfAnyGlobMatchesAllFiles', () => {
});
});

describe('when any of the given glob patterns in braces match all files', () => {
const globPatterns = ['{*.md,*.txt}', '*.mp3'];

it('returns true', () => {
const result = checkIfAnyGlobMatchesAllFiles(
changedFiles2,
globPatterns,
false
);
expect(result).toBe(true);
});
});

describe('when none of the given glob patterns matched all files', () => {
const globPatterns = ['*.md', 'bar.txt', 'foo.txt'];

Expand Down