Skip to content

Commit ab2d68d

Browse files
committed
coverage
Add test coverage to ci and send data to coveralls, add coverage badge.
1 parent cb8b5cd commit ab2d68d

File tree

8 files changed

+43
-18
lines changed

8 files changed

+43
-18
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
source = clickhouse_backend

.github/workflows/base-test.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
33

4-
name: Base-Test
4+
name: Base test
55

66
on:
77
workflow_call:
@@ -14,10 +14,10 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
python-version: ["3.8", "3.9", "3.10", "3.11"]
17-
django-version: ["32", "40", "41", "42"]
17+
django-version: ["3.2", "4.0", "4.1", "4.2"]
1818
include:
1919
- python-version: "3.7"
20-
django-version: "32"
20+
django-version: "3.2"
2121

2222
name: Python${{ matrix.python-version }} Django${{ matrix.django-version }}
2323
steps:
@@ -33,8 +33,31 @@ jobs:
3333
python -m pip install tox
3434
- name: Lint code
3535
run: tox -e lint
36+
- name: Cache docker image
37+
uses: actions/cache@v3
38+
with:
39+
path: /var/lib/docker/image/overlay2
40+
key: docker-image-${{ hashFiles('compose.yaml') }}
3641
- name: Start clickhouse cluster
3742
run: docker compose up -d --wait
3843
- name: Run test
3944
# Run tox using the version of Python in `PATH`
4045
run: tox -e py-django${{ matrix.django-version }}
46+
- name: Coveralls Parallel
47+
uses: coverallsapp/github-action@v2
48+
with:
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
flag-name: run-${{ join(matrix.*, '-') }}
51+
parallel: true
52+
53+
coveralls-finish:
54+
55+
needs: test
56+
if: ${{ always() }}
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Coveralls Finished
60+
uses: coverallsapp/github-action@v2
61+
with:
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
parallel-finished: true

.github/workflows/test-before-pr.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
4-
name: Test before pull request
1+
name: Test before PR
52

63
on:
74
pull_request:

.github/workflows/test-main.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
4-
name: test
1+
name: Test main
52

63
on:
74
push:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.coverage
12
.idea
23
.tox
34
venv
@@ -6,4 +7,4 @@ django_clickhouse_backend.egg-info
67
build
78
dist
89
tests/unsupported/
9-
example/testapp/migrations/[0-9]*
10+
example/testapp/migrations/[0-9]*

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### 1.1.2
22
- Use [flake8](https://flake8.pycqa.org/) to lint code.
33
- Add GitHub action which runs tests.
4+
- Add test coverage to ci and send data to coveralls, add coverage badge.
45

56
### 1.1.1
67
- [Black](https://github.com/psf/black) code style.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Django ClickHouse Database Backend
66
[![PyPI - Downloads](https://img.shields.io/pypi/dm/django-clickhouse-backend)](https://pypi.org/project/django-clickhouse-backend)
77
[![GitHub licence](https://img.shields.io/github/license/jayvynl/django-clickhouse-backend)](https://github.com/jayvynl/django-clickhouse-backend/blob/main/LICENSE)
88
[![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)
9+
[![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)
910
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1011

1112
Django clickhouse backend is a [django database backend](https://docs.djangoproject.com/en/4.1/ref/databases/) for

tox.ini

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
[tox]
22
requires =
33
tox>=4
4-
env_list = format, py37-django32, py{38,39,310,311}-django{32,40,41,42}
4+
env_list = py3.7-django3.2, py{3.8,3.9,3.10,3.11}-django{3.2,4.0,4.1,4.2}
55

66
[variables]
77
code = clickhouse_backend example tests
88

99
[testenv]
1010
deps =
11-
django32: Django>=3.2,<4.0
12-
django40: Django>=4.0,<4.1
13-
django41: Django>=4.1,<4.2
14-
django42: Django>=4.2,<4.3
11+
django3.2: Django>=3.2,<4.0
12+
django4.0: Django>=4.0,<4.1
13+
django4.1: Django>=4.1,<4.2
14+
django4.2: Django>=4.2,<4.3
15+
coverage
1516
commands =
16-
python tests/runtests.py --failfast --debug-sql {posargs}
17+
# Use local clickhouse_backend package so that coverage works properly.
18+
pip install -e .
19+
coverage run tests/runtests.py --debug-sql {posargs}
1720

1821
[testenv:lint]
1922
description = lint code

0 commit comments

Comments
 (0)