Skip to content

Commit 57870d3

Browse files
authored
Added test and github actions
2 parents c91d60f + 63c45b8 commit 57870d3

9 files changed

Lines changed: 596 additions & 38 deletions

File tree

.github/workflows/release.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release python package
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: "3.9"
17+
- name: Install deps
18+
uses: knowsuchagency/poetry-install@v1
19+
env:
20+
POETRY_VIRTUALENVS_CREATE: false
21+
- name: Release package
22+
env:
23+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
24+
run: poetry publish --build

.github/workflows/test.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Testing taskiq-redis
2+
3+
on: push
4+
5+
jobs:
6+
black:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Set up Python
11+
uses: actions/setup-python@v2
12+
with:
13+
python-version: "3.9"
14+
- name: Install deps
15+
uses: knowsuchagency/poetry-install@v1
16+
env:
17+
POETRY_VIRTUALENVS_CREATE: false
18+
- name: Run black check
19+
run: poetry run black --check .
20+
flake8:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Set up Python
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: "3.9"
28+
- name: Install deps
29+
uses: knowsuchagency/poetry-install@v1
30+
env:
31+
POETRY_VIRTUALENVS_CREATE: false
32+
- name: Run flake8 check
33+
run: poetry run flake8 --count .
34+
mypy:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v2
38+
- name: Set up Python
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: "3.9"
42+
- name: Install deps
43+
uses: knowsuchagency/poetry-install@v1
44+
env:
45+
POETRY_VIRTUALENVS_CREATE: false
46+
- name: Run mypy check
47+
run: poetry run mypy .
48+
pytest:
49+
strategy:
50+
matrix:
51+
py_version: ["3.7", "3.8", "3.9", "3.10"]
52+
runs-on: "ubuntu-latest"
53+
steps:
54+
- uses: actions/checkout@v2
55+
- name: Set up Python
56+
uses: actions/setup-python@v2
57+
with:
58+
python-version: "${{ matrix.py_version }}"
59+
- name: Update pip
60+
run: python -m pip install -U pip
61+
- name: Install poetry
62+
run: python -m pip install poetry
63+
- name: Install deps
64+
run: poetry install
65+
env:
66+
POETRY_VIRTUALENVS_CREATE: false
67+
- name: Update docker-compose
68+
uses: KengoTODA/actions-setup-docker-compose@v1
69+
with:
70+
version: "2.16.0"
71+
- name: docker compose up
72+
run: docker-compose up -d --wait
73+
- name: Run pytest check
74+
run: poetry run pytest -vv -n auto --cov="taskiq_nats" .
75+
- name: Generate report
76+
run: poetry run coverage xml
77+
- name: Upload coverage reports to Codecov with GitHub Action
78+
uses: codecov/codecov-action@v3
79+
if: matrix.py_version == '3.9'
80+
with:
81+
token: ${{ secrets.CODECOV_TOKEN }}
82+
fail_ci_if_error: true
83+
verbose: true
84+
- name: Stop containers
85+
if: always()
86+
run: docker-compose down

docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '3.7'
2+
3+
# This docker compose is used for testing.
4+
# It contains only services required for pytest to run
5+
# successfully.
6+
services:
7+
nats:
8+
image: nats:2.9.15-alpine
9+
command:
10+
- "-m"
11+
- "8222"
12+
- "--debug"
13+
healthcheck:
14+
test:
15+
- "CMD"
16+
- "sh"
17+
- "-c"
18+
- "wget http://localhost:8222/healthz -q -O - | xargs | grep ok || exit 1"
19+
interval: 5s
20+
timeout: 3s
21+
retries: 5
22+
ports:
23+
- 8222:8222
24+
- 4222:4222

0 commit comments

Comments
 (0)