Skip to content

Commit

Permalink
Provide a cleaner interface for generating (multiple) annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenFrankel committed Oct 15, 2024
1 parent d1f2819 commit c95a6a7
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,33 @@ jobs:
poetry install
- name: Test with pytest
run: |
poetry run pytest | sed -E 's/.*(UserWarning)/::warning title="${{ github.job }} (${{ matrix.python-version }}): \1"::\0/'
__generate_annotations () {
level=$1
pattern=$2
title=${3:-'\1'}
message=${4:-'\0'}
test -z "$level" \
&& echo 'Error: level is required' \
&& exit 1
test "$level" != debug \
&& test "$level" != notice \
&& test "$level" != warning \
&& test "$level" != error \
&& echo 'Error: level must be one of [ debug | notice | warning | error ]' \
&& exit 1
test -z "$pattern" \
&& echo 'Error: pattern is required' \
&& exit 1
sed -E "s/.*($pattern)/::$level title='${{ github.job }} (${{ matrix.python-version }}): $title'::$message/"
}
debug () { __generate_annotations $FUNCNAME $@; }
notice () { __generate_annotations $FUNCNAME $@; }
warning () { __generate_annotations $FUNCNAME $@; }
error () { __generate_annotations $FUNCNAME $@; }
poetry run pytest | warning UserWarning

0 comments on commit c95a6a7

Please sign in to comment.