microsoft / microsoft/typespec

Problem matcher for typespec diagnostic in github actions

Open
#3,139 0 comments 0 reactions 0 assignees View on GitHub
triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Clear and concise description of the problem

Github actions support problem matchers which will automatically detect diagnostic and annotate the code where the problem occured

https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md

I wrote a problem matcher in [my repo]( https://github.com/timotheeguerin/tsp-playground/pull/1)

## Suggestion

we provide a built-in way of doing this. Either by providing a `setup-tsp` github action or some other way

## Workaround

One could use it today by doing the following steps:

1. Copy this content into `.github/tsp.json`
```json
{
"problemMatcher": [
{
"owner": "tsp",
"pattern": [
{
"regexp": "^(?:\\x1b\\[[\\d;]+m)*([^\\s][^\u001b]*)(?:\\x1b\\[[\\d;]+m)*:(?:\\x1b\\[[\\d;]+m)*(\\d+)(?:\\x1b\\[[\\d;]+m)*:(?:\\x1b\\[[\\d;]+m)*(\\d+)(?:\\x1b\\[[\\d;]+m)*\\s+-\\s+(?:\\x1b\\[[\\d;]+m)*(error|warning)(?:\\x1b\\[[\\d;]+m)*\\s+(?:\\x1b\\[[\\d;]+m)*([a-z0-9\\-]+)(?:\\x1b\\[[\\d;]+m)*\\s*:\\s*(?:\\x1b\\[[\\d;]+m)*([^\u001b]*)(?:\\x1b\\[[\\d;]+m)*$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
}
]
}
```

Add this step to your github action:
```
- run: echo "::add-matcher::.github/tsp.json"
name: Add tsp problem matcher
```

result:
image

Example PR https://github.com/timotheeguerin/tsp-playground/pull/1

### Checklist

- [X] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [docs](https://typespec.io/docs/).
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.