Skip to content

Commit

Permalink
Add github workflows. (#40)
Browse files Browse the repository at this point in the history
* Add github workflows which run tests.

* Add several badges.
  • Loading branch information
jayvynl committed Sep 10, 2023
1 parent 1d79a49 commit cb8b5cd
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 50 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/base-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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

on:
workflow_call:

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
django-version: ["32", "40", "41", "42"]
include:
- python-version: "3.7"
django-version: "32"

name: Python${{ matrix.python-version }} Django${{ matrix.django-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
- name: Lint code
run: tox -e lint
- 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 }}
12 changes: 12 additions & 0 deletions .github/workflows/test-before-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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

on:
pull_request:
branches: [ "main" ]

jobs:
test:
uses: ./.github/workflows/base-test.yml
12 changes: 12 additions & 0 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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

on:
push:
branches: [ "main" ]

jobs:
test:
uses: ./.github/workflows/base-test.yml
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 1.1.2
- Use [flake8](https://flake8.pycqa.org/) to lint code.
- Add GitHub action which runs tests.

### 1.1.1
- [Black](https://github.com/psf/black) code style.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Django ClickHouse Database Backend
===
[![PyPI - Version](https://img.shields.io/pypi/v/django-clickhouse-backend)](https://pypi.org/project/django-clickhouse-backend)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-clickhouse-backend)](https://pypi.org/project/django-clickhouse-backend)
[![PyPI django version](https://img.shields.io/pypi/frameworkversions/django/django-clickhouse-backend)](https://pypi.org/project/django-clickhouse-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)
[![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
71 changes: 22 additions & 49 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,80 +1,52 @@
x-base-service: &base-service
image: clickhouse/clickhouse-server:23.6.2.18
restart: always
environment:
- "CLICKHOUSE_DB=other"
ulimits:
nofile:
soft: 262144
hard: 262144
healthcheck:
test: ["CMD", "clickhouse-client", "-q", "SELECT 1"]
interval: 30s
timeout: 5s
retries: 3

services:
node1:
image: clickhouse/clickhouse-server:23.6.2.18
<<: *base-service
container_name: clickhouse-node1
restart: always
environment:
- "CLICKHOUSE_DB=other"
volumes:
- "node1:/var/lib/clickhouse/"
- "./clickhouse-config/node1/:/etc/clickhouse-server/config.d/"
ports:
- "127.0.0.1:9000:9000"
ulimits:
nofile:
soft: 262144
hard: 262144
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8123/ping"]
interval: 30s
timeout: 5s
node2:
image: clickhouse/clickhouse-server:23.6.2.18
<<: *base-service
container_name: clickhouse-node2
restart: always
environment:
- "CLICKHOUSE_DB=other"
volumes:
- "node2:/var/lib/clickhouse/"
- "./clickhouse-config/node2/:/etc/clickhouse-server/config.d/"
ports:
- "127.0.0.1:9001:9000"
ulimits:
nofile:
soft: 262144
hard: 262144
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8123/ping"]
interval: 30s
timeout: 5s
node3:
image: clickhouse/clickhouse-server:23.6.2.18
<<: *base-service
container_name: clickhouse-node3
restart: always
environment:
- "CLICKHOUSE_DB=other"
volumes:
- "node3:/var/lib/clickhouse/"
- "./clickhouse-config/node3/:/etc/clickhouse-server/config.d/"
ports:
- "127.0.0.1:9002:9000"
ulimits:
nofile:
soft: 262144
hard: 262144
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8123/ping"]
interval: 30s
timeout: 5s
node4:
image: clickhouse/clickhouse-server:23.6.2.18
<<: *base-service
container_name: clickhouse-node4
restart: always
environment:
- "CLICKHOUSE_DB=other"
volumes:
- "node4:/var/lib/clickhouse/"
- "./clickhouse-config/node4/:/etc/clickhouse-server/config.d/"
ports:
- "127.0.0.1:9003:9000"
ulimits:
nofile:
soft: 262144
hard: 262144
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8123/ping"]
interval: 30s
timeout: 5s

volumes:
node1:
name: clickhouse-node1
Expand All @@ -84,6 +56,7 @@ volumes:
name: clickhouse-node3
node4:
name: clickhouse-node4

networks:
default:
name: clickhouse-net
name: clickhouse-net
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commands =
description = lint code
skip_install = true
deps =
flake8==6.1.0
flake8
commands =
flake8 --max-line-length=88 --extend-ignore=E203,E501 {[variables]code}

Expand Down

0 comments on commit cb8b5cd

Please sign in to comment.