durandtibo/hya

View on GitHub
.github/workflows/coverage.yaml

Summary

Maintainability
Test Coverage
name: Code Coverage
on:
  workflow_call:
  workflow_dispatch:  # to trigger manually

jobs:
  coverage:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install Poetry
        uses: snok/install-poetry@v1

      - name: Set environment variable
        run: |
          echo $(poetry run poetry env info --path)/bin >> $GITHUB_PATH

      - name: Install packages
        run: |
          make config-poetry
          make install-all

      - name: Show installed packages
        run: |
          poetry show
          poetry show --tree

      - name: Run unit tests
        run: |
          make unit-test-cov

      - name: Upload coverage to Codecov
        if: github.repository == 'durandtibo/hya' && (github.event_name == 'push' || github.event_name == 'pull_request')
        uses: codecov/codecov-action@v4
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./coverage.xml
          # Ignore codecov failures as the codecov server is not
          # very reliable but we don't want to report a failure
          # in the github UI just because the coverage report failed to
          # be published.
          fail_ci_if_error: false

      - name: Test & publish code coverage
        uses: paambaati/codeclimate-action@v9.0.0
        env:
          CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
        with:
          coverageLocations: ./coverage.xml:coverage.py
          debug: true