Skip to content
alert-octagon

GitHub Action

Annotations Failure Action

v0.0.1-alpha.1 Pre-release

Annotations Failure Action

alert-octagon

Annotations Failure Action

Allow to turn certain annotations (e.g. from problem matchers) into run failures

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Annotations Failure Action

uses: root-project/[email protected]

Learn more about this action in root-project/annotation-failure-action

Choose a version

Annotation Failure Action

image

Causes the build to fail if certain annotations are created. This is useful in conjuntion with problem matchers 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

  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.

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