Skip to content

Commit

Permalink
Merge pull request #308 from tj-actions/feat/add-support-for-validati…
Browse files Browse the repository at this point in the history
…ng-glob-patterns
  • Loading branch information
jackton1 committed Aug 8, 2022
2 parents bc84298 + 2ff9fd3 commit 3a01363
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
config_path: ".eslintrc.json"
ignore_path: ".eslintignore"

- name: Run build
- name: Run build and test
run: |
yarn all
Expand Down
18 changes: 2 additions & 16 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,11 @@ test('returns the paths of the filtered files in the paths-output-file', async (

await run()

expect(core.setOutput).toHaveBeenNthCalledWith(1, 'paths', EXPECTED_FILENAMES)

expect(core.setOutput).toHaveBeenNthCalledWith(
2,
'paths-output-file',
pathsOutputFile
)
})

test('returns warning for no match found', async () => {
mockedEnv({
...defaultEnv,
INPUT_FILES: '-**.yml'
})

// @ts-ignore
core.warning = jest.fn()

await run()

expect(core.warning).toBeCalledWith(
'No match found for specified patterns. Ensure that subdirectory patterns are prefixed with "**/" and all multi line string patterns are specified without quotes. See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet'
)
})
8 changes: 0 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,21 @@
"dependencies": {
"@actions/core": "1.9.0",
"@actions/exec": "1.1.1",
"@actions/github": "5.0.3",
"@actions/glob": "0.3.0",
"@actions/io": "1.1.2",
"temp-dir": "2.0.0",
"uuid": "8.3.2"
},
"devDependencies": {
"@types/jest": "28.1.6",
"@types/jest": "^28.1.6",
"@types/node": "18.6.4",
"@types/uuid": "8.3.4",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "5.32.0",
"@vercel/ncc": "0.34.0",
"eslint": "8.21.0",
"eslint-plugin-github": "4.3.7",
"eslint-plugin-jest": "26.8.0",
"eslint-plugin-prettier": "4.2.1",
"jest": "28.1.3",
"js-yaml": "4.1.0",
"mocked-env": "1.3.5",
"prettier": "2.7.1",
"ts-jest": "28.0.7",
"typescript": "4.7.4"
Expand Down
15 changes: 0 additions & 15 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,6 @@ export async function run(): Promise<void> {
core.setOutput('paths-output-file', pathsOutputFile)
core.saveState('paths-output-file', pathsOutputFile)
core.info(`Successfully created paths-output-file: ${pathsOutputFile}`)
} else {
const allPatterns = filePatterns
.split('\n')
.filter(
p =>
!DEFAULT_EXCLUDED_FILES.map(
ep => `!${path.join(workingDirectory, ep.replace(/^!/, ''))}`
).includes(p) && p !== ''
)

if (allPatterns.length > 0) {
core.warning(
'No match found for specified patterns. Ensure that subdirectory patterns are prefixed with "**/" and all multi line string patterns are specified without quotes. See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet'
)
}
}
}

Expand Down

0 comments on commit 3a01363

Please sign in to comment.