https://github.com/root-project/annotation-failure-action
GitHub action that extends the usage of workflow annotations
https://github.com/root-project/annotation-failure-action
Last synced: 8 months ago
JSON representation
GitHub action that extends the usage of workflow annotations
- Host: GitHub
- URL: https://github.com/root-project/annotation-failure-action
- Owner: root-project
- Created: 2023-06-28T12:41:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-29T14:37:11.000Z (almost 3 years ago)
- Last Synced: 2025-08-28T00:40:20.805Z (10 months ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Annotation Failure Action

Causes the build to fail if certain annotations are created. This is useful in
conjuntion with
[problem matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md)
to fail the workflow on compiler warnings without enabling `-Werror`.
## Inputs
### GH\_TOKEN
**required** This workflow requires an access token with yet to be determined permissions to
read annotations (but likely `checks` and `actions`).
### workflow\_id
**required** The id of the workflow to check annotations for. For jobs checking their own
annotations, `${{ github.run_id }}` works. For jobs triggered by `workflow_run`,
`${{ github.event.workflow_run.id }}` finds the `run_id` of the run that
triggered this run.
### filter
**optional** A regex filter that causes job failures when it's (partially) matching
an annotation whose severity is 'warning' or higher. It matches against the
annotation's title and message concatinated.
Without a filter, any annotation of severity warning or higher causes a build
failure.
A useful regex for gcc is `\[-W[A-Za-z\-]+?\]`.
This matches the diagnostic flag hints such as `[-Wdeprecated-declarations]` in `warning: āDā is deprecated [-Wdeprecated-declarations]`.
An alternative would be to search for `warning: ` and alike.
## Example usage
Check for annotations within the same workflow
```yaml
matrix-build-step-with-problem-matcher:
[...]
assert-annotations:
name: Check for compiler warnings
needs: [matrix-build-step-with-problem-matcher]
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
actions: read
steps:
- name: Check for gcc compiler warnings
env:
filter: '\[-W[A-Za-z\-]+?\]'
workflow_id: ${{ github.run_id }}
GH_TOKEN: ${{ github.token }}
uses: root-project/annotation-failure-action@main
```
Check for annotations from a different workflow using `on: workflow_run`.
```yaml
name: Read annotations
on:
workflow_run:
workflows: [annotation-creating-workflow]
types:
- completed
jobs:
read_annotations:
name: Check for compiler warnings
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
actions: read
steps:
- name: Check for annotations in the run that triggered this
env:
workflow_id: ${{ github.event.workflow_run.id }}
GH_TOKEN: ${{ github.token }}
uses: root-project/annotation-failure-action@main
```