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

Use micromatch instead of minimatch #46

Merged
merged 2 commits into from
Oct 23, 2020
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v2.5.1
- [Improved path matching with micromatch](https://github.com/dorny/paths-filter/pull/46)

## v2.5.0
- [Support workflows triggered by any event](https://github.com/dorny/paths-filter/pull/44)

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,24 @@ doesn't allow this because they doesn't work on a level of individual jobs or st
For more scenarios see [examples](#examples) section.

## Notes:
- Paths expressions are evaluated using [minimatch](https://github.com/isaacs/minimatch) library.
- Paths expressions are evaluated using [micromatch](https://github.com/micromatch/micromatch) library.
Documentation for path expression format can be found on project github page.
- Minimatch [dot](https://www.npmjs.com/package/minimatch#dot) option is set to true.
- Micromatch [dot](https://github.com/micromatch/micromatch#options) option is set to true.
Globbing will match also paths where file or folder name starts with a dot.
- It's recommended to quote your path expressions with `'` or `"`. Otherwise you will get an error if it starts with `*`.
- Local execution with [act](https://github.com/nektos/act) works only with alternative runner image. Default runner doesn't have `git` binary.
- Use: `act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04`


# What's New
- Paths expressions are now evaluated using [micromatch](https://github.com/micromatch/micromatch) library
- Support workflows triggered by any event
- Fixed compatibility with older (<2.23) versions of git
- Support for tag pushes and tags as a base reference
- Fixes for various edge cases when event payload is incomplete
- Supports local execution with [act](https://github.com/nektos/act)
- Fixed behavior of feature branch workflow:
- Detects only changes introduced by feature branch. Later modifications on base branch are ignored.
- Detects only changes introduced by feature branch. Later modifications on base branch are ignored
- Filter by type of file change:
- Optionally consider if file was added, modified or deleted

Expand Down
19 changes: 19 additions & 0 deletions __tests__/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ describe('matching tests', () => {
expect(match.dot).toEqual(files)
})

test('matches all except tsx and less files (negate a group with or-ed parts)', () => {
const yaml = `
backend:
- '!(**/*.tsx|**/*.less)'
`
const filter = new Filter(yaml)
const tsxFiles = modified(['src/ui.tsx'])
const lessFiles = modified(['src/ui.less'])
const pyFiles = modified(['src/server.py'])

const tsxMatch = filter.match(tsxFiles)
const lessMatch = filter.match(lessFiles)
const pyMatch = filter.match(pyFiles)

expect(tsxMatch.backend).toEqual([])
expect(lessMatch.backend).toEqual([])
expect(pyMatch.backend).toEqual(pyFiles)
})

test('matches path based on rules included using YAML anchor', () => {
const yaml = `
shared: &shared
Expand Down