Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
Add test coverage to ci and send data to coveralls, add coverage badge.
  • Loading branch information
jayvynl committed Sep 11, 2023
1 parent cb8b5cd commit ab2d68d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source = clickhouse_backend
29 changes: 26 additions & 3 deletions .github/workflows/base-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Base-Test
name: Base test

on:
workflow_call:
Expand All @@ -14,10 +14,10 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
django-version: ["32", "40", "41", "42"]
django-version: ["3.2", "4.0", "4.1", "4.2"]
include:
- python-version: "3.7"
django-version: "32"
django-version: "3.2"

name: Python${{ matrix.python-version }} Django${{ matrix.django-version }}
steps:
Expand All @@ -33,8 +33,31 @@ jobs:
python -m pip install tox
- name: Lint code
run: tox -e lint
- name: Cache docker image
uses: actions/cache@v3
with:
path: /var/lib/docker/image/overlay2
key: docker-image-${{ hashFiles('compose.yaml') }}
- name: Start clickhouse cluster
run: docker compose up -d --wait
- name: Run test
# Run tox using the version of Python in `PATH`
run: tox -e py-django${{ matrix.django-version }}
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true

coveralls-finish:

needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
5 changes: 1 addition & 4 deletions .github/workflows/test-before-pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Test before pull request
name: Test before PR

on:
pull_request:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: test
name: Test main

on:
push:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.coverage
.idea
.tox
venv
Expand All @@ -6,4 +7,4 @@ django_clickhouse_backend.egg-info
build
dist
tests/unsupported/
example/testapp/migrations/[0-9]*
example/testapp/migrations/[0-9]*
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 1.1.2
- Use [flake8](https://flake8.pycqa.org/) to lint code.
- Add GitHub action which runs tests.
- Add test coverage to ci and send data to coveralls, add coverage badge.

### 1.1.1
- [Black](https://github.com/psf/black) code style.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Django ClickHouse Database Backend
[![PyPI - Downloads](https://img.shields.io/pypi/dm/django-clickhouse-backend)](https://pypi.org/project/django-clickhouse-backend)
[![GitHub licence](https://img.shields.io/github/license/jayvynl/django-clickhouse-backend)](https://github.com/jayvynl/django-clickhouse-backend/blob/main/LICENSE)
[![GitHub Action: Test](https://github.com/jayvynl/django-clickhouse-backend/actions/workflows/test-main.yml/badge.svg)](https://github.com/jayvynl/django-clickhouse-backend/actions/workflows/test-main.yml)
[![Coverage Status](https://coveralls.io/repos/github/jayvynl/django-clickhouse-backend/badge.svg?branch=main)](https://coveralls.io/github/jayvynl/django-clickhouse-backend?branch=main)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

Django clickhouse backend is a [django database backend](https://docs.djangoproject.com/en/4.1/ref/databases/) for
Expand Down
15 changes: 9 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
[tox]
requires =
tox>=4
env_list = format, py37-django32, py{38,39,310,311}-django{32,40,41,42}
env_list = py3.7-django3.2, py{3.8,3.9,3.10,3.11}-django{3.2,4.0,4.1,4.2}

[variables]
code = clickhouse_backend example tests

[testenv]
deps =
django32: Django>=3.2,<4.0
django40: Django>=4.0,<4.1
django41: Django>=4.1,<4.2
django42: Django>=4.2,<4.3
django3.2: Django>=3.2,<4.0
django4.0: Django>=4.0,<4.1
django4.1: Django>=4.1,<4.2
django4.2: Django>=4.2,<4.3
coverage
commands =
python tests/runtests.py --failfast --debug-sql {posargs}
# Use local clickhouse_backend package so that coverage works properly.
pip install -e .
coverage run tests/runtests.py --debug-sql {posargs}

[testenv:lint]
description = lint code
Expand Down

0 comments on commit ab2d68d

Please sign in to comment.