From 238f798b8d783178d9fa1d0d616408c4db827eff Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Wed, 15 May 2024 10:45:12 +0300 Subject: [PATCH] try code coverage --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++ .github/workflows/coverage.yml | 21 +++++++++++++++++ requirements-dev.txt | 1 + 3 files changed, 63 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..7df32110 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: + pull_request: + push: + branches: [ main, feat/* ] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + name: Check coverage + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install deps + run: pip install -r requirements-dev.txt + + - name: Launch tests & generate report + run: pytest . + + - name: Coverage comment + id: coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ github.token }} + VERBOSE: true + + - name: Store Pull Request comment to be posted + uses: actions/upload-artifact@v2 + if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' + with: + # If you use a different name, update COMMENT_ARTIFACT_NAME accordingly + name: python-coverage-comment-action + # If you use a different name, update COMMENT_FILENAME accordingly + path: python-coverage-comment-action.txt diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..b30177d4 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,21 @@ +name: Post coverage comment + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +jobs: + test: + name: Run tests & display coverage + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + steps: + + - name: Post comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} + VERBOSE: true diff --git a/requirements-dev.txt b/requirements-dev.txt index 494509ba..ca70c452 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,5 @@ pytest +pytest-cov flake8 autopep8 pre-commit