diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 92d60e212..024db42c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,6 @@ on: branches: - main - dev - - demo - hotfix pull_request: types: @@ -14,12 +13,15 @@ on: - reopened - synchronize branches: - - main - main - dev - - demo - hotfix +permissions: + contents: read + actions: read + pull-requests: write + jobs: test: runs-on: ubuntu-latest @@ -48,11 +50,31 @@ jobs: echo "Test files found, running tests." echo "skip_tests=false" >> $GITHUB_ENV fi + - name: Run tests with coverage if: env.skip_tests == 'false' run: | - pytest --cov=. --cov-report=term-missing --cov-report=xml --ignore=tests/e2e-test/tests - + cat > .coveragerc << 'EOF' + [run] + source = src/backend + omit = + */tests/* + */test_* + EOF + pytest --cov --cov-config=.coveragerc --cov-report=term-missing --cov-report=xml --junitxml=pytest.xml --ignore=tests/e2e-test/tests + + - name: Pytest Coverage Comment + if: | + always() && + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.fork == false && + env.skip_tests == 'false' + uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0 + with: + pytest-xml-coverage-path: coverage.xml + junitxml-path: pytest.xml + report-only-changed-files: true + - name: Skip coverage report if no tests if: env.skip_tests == 'true' run: |