From 54822de4f918db0b6857af28f324ff91bc45e8e1 Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Thu, 6 Jun 2024 00:23:15 +0300 Subject: [PATCH] chore(core): Display status on readme (#589) Make the Readme display some more details regarding the project: - using ruff (just a nice reference) - pypi version (good visibility) - license (good visibility) - supported python versions (good visibility) - code coverage reporting (main driver for this PR) ![image](https://github.com/testcontainers/testcontainers-python/assets/7189138/1e8897b6-15eb-47eb-a1e7-42caa7db1eca) Relates to #544 - export code coverage (e.g. to codecov) --- .github/workflows/ci-core.yml | 31 ++++++++++++++++++++++++++++++- Makefile | 7 +++++++ README.md | 7 +++++++ pyproject.toml | 2 +- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-core.yml b/.github/workflows/ci-core.yml index f794f98e..0f6a5e4e 100644 --- a/.github/workflows/ci-core.yml +++ b/.github/workflows/ci-core.yml @@ -9,7 +9,7 @@ on: branches: [main] jobs: - test: + run-tests-and-coverage: runs-on: ubuntu-22.04 strategy: fail-fast: false @@ -27,5 +27,34 @@ jobs: run: poetry build && poetry run twine check dist/*.tar.gz - name: Run tests run: make core/tests + - name: Rename coverage file + run: mv .coverage .coverage.${{ matrix.python-version}} + - name: "Save coverage artifact" + uses: actions/upload-artifact@v4 + with: + name: "coverage-artifact-${{ matrix.python-version}}" + path: ".coverage.*" + retention-days: 1 - name: Run doctests run: make core/doctests + + coverage-compile: + needs: "run-tests-and-coverage" + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: ./.github/actions/setup-env + - name: Install Python dependencies + run: poetry install --all-extras + - name: "Download coverage artifacts" + uses: actions/download-artifact@v4 + with: + pattern: "coverage-artifact-*" + merge-multiple: true + - name: Compile coverage + run: make coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/Makefile b/Makefile index 1816f64b..b7bf2826 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,13 @@ tests : ${TESTS} ${TESTS} : %/tests : poetry run pytest -v --cov=testcontainers.$* $*/tests +# Target to combine and report coverage. +coverage: + poetry run coverage combine + poetry run coverage report + poetry run coverage xml + poetry run coverage html + # Target to lint the code. lint: pre-commit run -a diff --git a/README.md b/README.md index 036723d6..434d0698 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) +[![image](https://img.shields.io/pypi/v/testcontainers.svg)](https://pypi.python.org/pypi/testcontainers) +[![image](https://img.shields.io/pypi/l/testcontainers.svg)](https://github.com/testcontainers/testcontainers-python/blob/main/LICENSE) +[![image](https://img.shields.io/pypi/pyversions/testcontainers.svg)](https://pypi.python.org/pypi/testcontainers) +[![codecov](https://codecov.io/gh/testcontainers/testcontainers-python/branch/master/graph/badge.svg)](https://codecov.io/gh/testcontainers/testcontainers-python) + + # Testcontainers Python `testcontainers-python` facilitates the use of Docker containers for functional and integration testing. diff --git a/pyproject.toml b/pyproject.toml index 6bc84171..181a12a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -159,7 +159,7 @@ priority = "primary" line-length = 120 [tool.pytest.ini_options] -addopts = "--cov-report=term --cov-report=html --tb=short --strict-markers" +addopts = "--tb=short --strict-markers" log_cli = true log_cli_level = "INFO"