Skip to content

Commit

Permalink
Use micromatch instead of minimatch (#46)
Browse files Browse the repository at this point in the history
* Use micromatch instead of minimatch

micromatch claims to support full Bash 4.3 spec and it actually passes all the tests. 
For example this fixes processing of '!(**/*.tsx|**/*.less)' pattern - needed by #45

* Update CHANGELOG.md
  • Loading branch information
dorny committed Oct 23, 2020
1 parent 7b5334d commit b37d4e9
Show file tree
Hide file tree
Showing 7 changed files with 12,063 additions and 9,005 deletions.
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

0 comments on commit b37d4e9

Please sign in to comment.