{"id":2722,"library":"pytest-github-actions-annotate-failures","title":"pytest-github-actions-annotate-failures","description":"A pytest plugin designed to enhance GitHub Actions workflows by annotating failed tests directly in the pull request or commit view. It parses pytest output and generates GitHub workflow commands to create inline annotations for test failures, providing immediate feedback on problematic code lines. The project is actively maintained under the pytest-dev organization, with its latest version being 0.4.0.","status":"active","version":"0.4.0","language":"en","source_language":"en","source_url":"https://github.com/pytest-dev/pytest-github-actions-annotate-failures","tags":["pytest","github-actions","ci","testing","plugin","workflow"],"install":[{"cmd":"pip install pytest-github-actions-annotate-failures","lang":"bash","label":"Install plugin"}],"dependencies":[{"reason":"Core dependency as this is a pytest plugin.","package":"pytest","optional":false}],"imports":[],"quickstart":{"code":"mkdir my_project\ncd my_project\n\n# Create a test file\ncat <<EOF > test_example.py\ndef test_passing():\n    assert True\n\ndef test_failing():\n    assert False\nEOF\n\n# Create GitHub Actions workflow file\nmkdir -p .github/workflows\ncat <<EOF > .github/workflows/ci.yml\nname: Test with Annotations\non: [push, pull_request]\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v4\n    - name: Set up Python\n      uses: actions/setup-python@v5\n      with:\n        python-version: '3.10'\n    - name: Install dependencies\n      run: pip install pytest pytest-github-actions-annotate-failures\n    - name: Run tests with annotations\n      run: pytest\nEOF\n\n# To see it in action, commit these files to a GitHub repository\n# and push. The workflow will run and failed tests will show\n# annotations in the 'Checks' or 'Actions' tab.","lang":"bash","description":"This quickstart demonstrates how to set up `pytest-github-actions-annotate-failures` in a basic GitHub Actions workflow. Once installed and integrated, failed tests will automatically produce inline annotations in your GitHub pull requests or commit details, pointing directly to the line of code that caused the failure. No special command-line flags are typically needed for activation, as pytest discovers the plugin automatically upon installation."},"warnings":[{"fix":"Ensure your GitHub Actions workflow or local environment uses Python 3.10+ and pytest 7.0.0+.","message":"Version 0.4.0 and later require Python >=3.10 and Pytest >=7.0.0. Older Python or Pytest versions are not supported and will likely lead to installation or runtime errors.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Set the `PYTEST_RUN_PATH` environment variable to the path of your test directory relative to the repository root. For example, `env: PYTEST_RUN_PATH: src/tests` in your workflow step.","message":"If your tests are located in a subdirectory relative to the repository root (e.g., `src/tests/`), GitHub Actions may not correctly link annotations to the source files.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you relied on annotations for intermediate rerun failures, be aware of this change in behavior. There is no direct fix to revert to the old behavior; adapt your workflow expectations accordingly.","message":"As of version 0.4.0, when `pytest-github-actions-annotate-failures` is used in conjunction with `pytest-rerunfailures`, only the *final* test failure is annotated. In previous versions (0.3.0 and older), annotations were added for all failed runs, including intermediate reruns.","severity":"breaking","affected_versions":">=0.4.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}