From 3040d085ca3da0ee5516056c20192aa478c9a370 Mon Sep 17 00:00:00 2001 From: Giacomo Pope Date: Tue, 23 Jul 2024 17:27:06 +0100 Subject: [PATCH 1/2] add coveralls CLI --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + 2 files changed, 44 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca1e5f3..55c1e03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,3 +121,46 @@ jobs: - name: Run unit tests run: | pytest + + coveralls: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Display Python version + run: python -c "import sys; print(sys.version)" + + - name: Display installed python package versions + run: | + pip list || : + + - name: Install coverage + run: | + pip install coverage + + - name: Install pytest + run: | + pip install pytest + + - name: Install build dependencies + run: | + pip install -r requirements.txt + + - name: Display installed python package versions + run: | + pip list || : + + - name: Run unit tests with coverage + run: | + coverage run -m pytest + + - name: Report Coveralls + run: curl -sL https://coveralls.io/coveralls-linux.tar.gz | tar -xz && ./coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 3959358..cedc257 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/.DS_Store __pycache__ docs/build +.coverage From ccc6aa92666c3a067a734473ae6ae7d4ed2ee9e8 Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Tue, 23 Jul 2024 20:23:48 +0200 Subject: [PATCH 2/2] collect coverage from all python versions in parallel Signed-off-by: Hubert Kario --- .github/workflows/ci.yml | 64 +++++++++++++++------------------------- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55c1e03..6250404 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,9 +109,9 @@ jobs: - name: Display installed python package versions run: | pip list || : - - name: Install pytest + - name: Install test requirements run: | - pip install pytest + pip install pytest coverage coveralls - name: Install build dependencies run: | pip install -r requirements.txt @@ -120,47 +120,29 @@ jobs: pip list || : - name: Run unit tests run: | - pytest - + coverage run --branch -m pytest + - name: Print collected coverage + run: | + coverage report + - name: Publish coverage to Coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.name }} + COVERALLS_PARALLEL: true + COVERALLS_SERVICE_NAME: github + run: | + coveralls coveralls: + name: Indicate completion to coveralls + needs: test runs-on: ubuntu-latest + container: python:3-slim steps: - - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Display Python version - run: python -c "import sys; print(sys.version)" - - - name: Display installed python package versions - run: | - pip list || : - - - name: Install coverage - run: | - pip install coverage - - - name: Install pytest - run: | - pip install pytest - - - name: Install build dependencies - run: | - pip install -r requirements.txt - - - name: Display installed python package versions - run: | - pip list || : - - - name: Run unit tests with coverage + - name: Install coveralls run: | - coverage run -m pytest - - - name: Report Coveralls - run: curl -sL https://coveralls.io/coveralls-linux.tar.gz | tar -xz && ./coveralls + pip3 install --upgrade coveralls + - name: Report to Coveralls env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_SERVICE_NAME: github + run: coveralls --finish