Skip to content

Commit

Permalink
Merge pull request #128 from dorny/issue-127-fix-pattern-with-backslash
Browse files Browse the repository at this point in the history
Add option to convert backslashes in path pattern to forward slashes
  • Loading branch information
dorny authored Jun 22, 2021
2 parents ad831af + de0b4b9 commit a585725
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 25 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ jobs:
# All matched result files must be of the same format
path: ''
# The fast-glob library that is internally used interprets backslashes as escape characters.
# If enabled, all backslashes in provided path will be replaced to forward slashes and act as directory separators.
# It might be useful when path input variable is composed dynamically from existing directory paths on Windows.
path-replace-backslashes: 'false'
# Format of test results. Supported options:
# dart-json
# dotnet-trx
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ inputs:
Supports wildcards via [fast-glob](https://github.com/mrmlnc/fast-glob)
All matched result files must be of same format
required: true
path-replace-backslashes:
description: |
The fast-glob library that is internally used interprets backslashes as escape characters.
If enabled, all backslashes in provided path will be replaced by forward slashes and act as directory separators.
It might be useful when path input variable is composed dynamically from existing directory paths on Windows.
default: 'false'
required: false
reporter:
description: |
Format of test results. Supported options:
Expand Down
6 changes: 5 additions & 1 deletion 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.

42 changes: 21 additions & 21 deletions dist/licenses.txt

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

9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {JavaJunitParser} from './parsers/java-junit/java-junit-parser'
import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser'
import {MochaJsonParser} from './parsers/mocha-json/mocha-json-parser'

import {normalizeDirPath} from './utils/path-utils'
import {normalizeDirPath, normalizeFilePath} from './utils/path-utils'
import {getCheckRunContext} from './utils/github-utils'
import {Icon} from './utils/markdown-utils'

Expand All @@ -33,6 +33,7 @@ class TestReporter {
readonly artifact = core.getInput('artifact', {required: false})
readonly name = core.getInput('name', {required: true})
readonly path = core.getInput('path', {required: true})
readonly pathReplaceBackslashes = core.getInput('path-replace-backslashes', {required: false}) === 'true'
readonly reporter = core.getInput('reporter', {required: true})
readonly listSuites = core.getInput('list-suites', {required: true}) as 'all' | 'failed'
readonly listTests = core.getInput('list-tests', {required: true}) as 'all' | 'failed' | 'none'
Expand Down Expand Up @@ -71,7 +72,11 @@ class TestReporter {

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

const pattern = this.path.split(',')
// Split path pattern by ',' and optionally convert all backslashes to forward slashes
// fast-glob (micromatch) always interprets backslashes as escape characters instead of directory separators
const pathsList = this.path.split(',')
const pattern = this.pathReplaceBackslashes ? pathsList.map(normalizeFilePath) : pathsList

const inputProvider = this.artifact
? new ArtifactProvider(
this.octokit,
Expand Down

0 comments on commit a585725

Please sign in to comment.