Support relative paths in problemMatchers to support monorepos
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Background
I'm working on CI/CD automation for a repository that includes multiple components, each in a subdirectory. Each component directory contains a Dockerfile, and in the course of building images errors are emitted with paths relative to the subdirectory of each component.
Example repository tree:
components/project1/Dockerfile
components/project1/src/example.fake
components/project2/Dockerfile
components/project2/src/example2.fake
Example error emitted during project1 build:
src/example.fake: syntax error
Describe the enhancement
To support monorepos, problem matchers should provide some mechanism for setting a static prefix to be applied to all errors emitted in a region of job output. I was not able to determine how to use the fromPath in Actions' problem matchers for my use case, as the build process being executed has no awareness of its fully qualified path and thus can't include it in error output.
Possible implementations
One approach might be to ask integrators to embed this information in the problem matcher configuration itself, possibly via a field similar to VS Code Tasks fileLocation property. This would require problem matchers to be imported into each repository and include a fileLocation field.
components/project1/.github/tsc.json
{
"problemMatcher": [
{
"owner": "tsc",
"fileLocation": ["relative", "components/project1"],
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
}
]
}
]
}
Another approach that used an action command could retain the use of shared matchers, like the one from setup-node above, and be integrated with existing matrix builds like so:
strategy:
matrix:
component:
- project1
- project2
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: |
# Tell the tsc matcher configured by setup-node to assume errors are relative to each component
echo "::set-matcher-prefix owner=tsc:components/${{ matrix.component }}:"
- name: Build and push Docker image
uses: docker/build-push-action@v1
with:
path: components/${{ matrix.component }}
...
- run: |
# Clear prefix for subsequent steps
echo "::set-matcher-prefix owner=tsc::"
If there's an alternative approach or workaround I'm possibly missing here, please let me know! Thanks for your time. 😄
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the problem matcher configuration in components/project1/.github/tsc.json and the proposed ::set-matcher-prefix command flow. Define how a relative path prefix should be configured or applied per component, including clearing it for later steps, and validate the behavior against the project1/project2 matrix example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, github-actions
- Domain
- ci-cd, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100