Skip to content

Commit a585725

Browse files
authored
Merge pull request #128 from dorny/issue-127-fix-pattern-with-backslash
Add option to convert backslashes in path pattern to forward slashes
2 parents ad831af + de0b4b9 commit a585725

File tree

6 files changed

+46
-25
lines changed

6 files changed

+46
-25
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ jobs:
119119
# All matched result files must be of the same format
120120
path: ''
121121
122+
# The fast-glob library that is internally used interprets backslashes as escape characters.
123+
# If enabled, all backslashes in provided path will be replaced to forward slashes and act as directory separators.
124+
# It might be useful when path input variable is composed dynamically from existing directory paths on Windows.
125+
path-replace-backslashes: 'false'
126+
122127
# Format of test results. Supported options:
123128
# dart-json
124129
# dotnet-trx

action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ inputs:
1515
Supports wildcards via [fast-glob](https://github.com/mrmlnc/fast-glob)
1616
All matched result files must be of same format
1717
required: true
18+
path-replace-backslashes:
19+
description: |
20+
The fast-glob library that is internally used interprets backslashes as escape characters.
21+
If enabled, all backslashes in provided path will be replaced by forward slashes and act as directory separators.
22+
It might be useful when path input variable is composed dynamically from existing directory paths on Windows.
23+
default: 'false'
24+
required: false
1825
reporter:
1926
description: |
2027
Format of test results. Supported options:

dist/index.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {JavaJunitParser} from './parsers/java-junit/java-junit-parser'
1616
import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser'
1717
import {MochaJsonParser} from './parsers/mocha-json/mocha-json-parser'
1818

19-
import {normalizeDirPath} from './utils/path-utils'
19+
import {normalizeDirPath, normalizeFilePath} from './utils/path-utils'
2020
import {getCheckRunContext} from './utils/github-utils'
2121
import {Icon} from './utils/markdown-utils'
2222

@@ -33,6 +33,7 @@ class TestReporter {
3333
readonly artifact = core.getInput('artifact', {required: false})
3434
readonly name = core.getInput('name', {required: true})
3535
readonly path = core.getInput('path', {required: true})
36+
readonly pathReplaceBackslashes = core.getInput('path-replace-backslashes', {required: false}) === 'true'
3637
readonly reporter = core.getInput('reporter', {required: true})
3738
readonly listSuites = core.getInput('list-suites', {required: true}) as 'all' | 'failed'
3839
readonly listTests = core.getInput('list-tests', {required: true}) as 'all' | 'failed' | 'none'
@@ -71,7 +72,11 @@ class TestReporter {
7172

7273
core.info(`Check runs will be created with SHA=${this.context.sha}`)
7374

74-
const pattern = this.path.split(',')
75+
// Split path pattern by ',' and optionally convert all backslashes to forward slashes
76+
// fast-glob (micromatch) always interprets backslashes as escape characters instead of directory separators
77+
const pathsList = this.path.split(',')
78+
const pattern = this.pathReplaceBackslashes ? pathsList.map(normalizeFilePath) : pathsList
79+
7580
const inputProvider = this.artifact
7681
? new ArtifactProvider(
7782
this.octokit,

0 commit comments

Comments
 (0)