Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): GitHub test workflow annotations for UserWarnings (and possibly other cases) #2721

Open
ReubenFrankel opened this issue Oct 16, 2024 · 1 comment
Assignees
Labels
kind/Feature New feature or request valuestream/SDK

Comments

@ReubenFrankel
Copy link
Contributor

Feature scope

Taps (catalog, state, tests, etc.)

Description

How do you feel about using workflow commands to create annotations for things like the UserWarning messages that are output? This could be useful in to highlight issues at a glance, rather than having to trawl through the Pytest output log.

Here's a POC I put together for tap-spotify:

    - name: Test with pytest
      run: |
        __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

https://github.com/Matatika/tap-spotify/actions/runs/11362287222

@edgarrmondragon
Copy link
Collaborator

Something like that would indeed be nice.

I'll try to revive pytest-dev/pytest-github-actions-annotate-failures#68.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/Feature New feature or request valuestream/SDK
Projects
None yet
Development

No branches or pull requests

2 participants