Skip to content

Commit c90f3dd

Browse files
authored
RELEASE
2 parents 51172c4 + f614761 commit c90f3dd

24 files changed

+925
-1084
lines changed

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
# GitHub Actions
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"
13+
# Python
14+
- package-ecosystem: "pip" # See documentation for possible values
15+
directory: "/" # Location of package manifests
16+
schedule:
17+
interval: "weekly"

.github/workflows/release.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
11
name: Release python package
22

33
on:
4-
push:
5-
tags:
6-
- "*"
4+
workflow_run:
5+
workflows: [Test]
6+
types: [completed]
77

88
jobs:
9-
deploy:
9+
publish:
10+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1011
runs-on: ubuntu-latest
12+
1113
steps:
14+
- name: Dump GitHub context
15+
env:
16+
GITHUB_CONTEXT: ${{ toJson(github) }}
17+
run: echo "$GITHUB_CONTEXT"
18+
1219
- uses: actions/checkout@v4
13-
- name: Install poetry
14-
run: pipx install poetry
20+
1521
- name: Set up Python
1622
uses: actions/setup-python@v4
1723
with:
18-
python-version: "3.11"
19-
- name: Install deps
20-
run: poetry install
21-
- name: Release package
24+
python-version: "3.8"
25+
cache: "pip"
26+
cache-dependency-path: pyproject.toml
27+
28+
- uses: actions/cache@v3
29+
id: cache
30+
with:
31+
path: ${{ env.pythonLocation }}
32+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
33+
34+
- name: Install build dependencies
35+
if: steps.cache.outputs.cache-hit != 'true'
36+
run: pip install build
37+
38+
- name: Build distribution
39+
run: python -m build
40+
41+
- name: Publish
42+
uses: pypa/[email protected]
43+
with:
44+
password: ${{ secrets.PYPI_TOKEN }}
45+
46+
- name: Dump GitHub context
2247
env:
23-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
24-
run: poetry publish --build
48+
GITHUB_CONTEXT: ${{ toJson(github) }}
49+
run: echo "$GITHUB_CONTEXT"

.github/workflows/test.yml

Lines changed: 108 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,122 @@
1-
name: Testing package
1+
name: Test
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [opened, synchronize]
49

510
jobs:
6-
lint:
7-
strategy:
8-
matrix:
9-
cmd:
10-
- black
11-
- mypy
12-
- ruff
11+
static_analysis:
12+
if: github.event.pull_request.draft == false
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Install poetry
17-
run: pipx install poetry
18-
- name: Set up Python
19-
uses: actions/setup-python@v4
16+
- uses: actions/setup-python@v4
2017
with:
21-
python-version: "3.9"
22-
cache: "poetry"
23-
- name: Install deps
24-
run: poetry install
25-
- name: Run lint check
26-
run: poetry run pre-commit run -a ${{ matrix.cmd }}
27-
pytest:
28-
permissions:
29-
checks: write
30-
pull-requests: write
31-
contents: write
18+
python-version: 3.8
19+
- name: Install Dependencies and library
20+
shell: bash
21+
run: |
22+
set -ux
23+
python -m pip install --upgrade pip
24+
pip install -e ".[dev]"
25+
26+
- name: Run black
27+
shell: bash
28+
run: black taskiq_faststream
29+
30+
- name: Run mypy
31+
shell: bash
32+
run: mypy taskiq_faststream
33+
34+
- name: Run ruff
35+
shell: bash
36+
run: ruff taskiq_faststream
37+
38+
test:
39+
if: github.event.pull_request.draft == false
40+
runs-on: ubuntu-latest
3241
strategy:
3342
matrix:
34-
py_version: ["3.8", "3.9", "3.10", "3.11"]
35-
os: [ubuntu-latest, windows-latest]
36-
runs-on: "${{ matrix.os }}"
43+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
44+
pydantic-version: ["pydantic-v1", "pydantic-v2"]
45+
fail-fast: false
46+
3747
steps:
3848
- uses: actions/checkout@v4
39-
- name: Install poetry
40-
run: pipx install poetry
4149
- name: Set up Python
4250
uses: actions/setup-python@v4
4351
with:
44-
python-version: "${{ matrix.py_version }}"
45-
cache: "poetry"
46-
- name: Install deps
47-
run: poetry install
48-
- name: Run pytest check
49-
run: poetry run pytest -vv -n auto --cov="taskiq_faststream" .
50-
- name: Generate report
51-
run: poetry run coverage xml
52-
- name: Upload coverage reports to Codecov with GitHub Action
53-
uses: codecov/codecov-action@v3
54-
if: matrix.os == 'ubuntu-latest' && matrix.py_version == '3.9'
55-
with:
56-
token: ${{ secrets.CODECOV_TOKEN }}
57-
fail_ci_if_error: false
58-
verbose: true
52+
python-version: ${{ matrix.python-version }}
53+
- uses: actions/cache@v3
54+
id: cache
55+
with:
56+
path: ${{ env.pythonLocation }}
57+
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03
58+
- name: Install Dependencies
59+
if: steps.cache.outputs.cache-hit != 'true'
60+
run: pip install -e .[test]
61+
- name: Install Pydantic v1
62+
if: matrix.pydantic-version == 'pydantic-v1'
63+
run: pip install "pydantic>=1.10,<2"
64+
- name: Install Pydantic v2
65+
if: matrix.pydantic-version == 'pydantic-v2'
66+
run: pip install --pre "pydantic>=2,<3"
67+
- run: mkdir coverage
68+
- name: Test
69+
run: bash scripts/test.sh
70+
env:
71+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
72+
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
73+
- name: Store coverage files
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: coverage
77+
path: coverage
78+
79+
coverage-combine:
80+
needs: [test]
81+
runs-on: ubuntu-latest
82+
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- uses: actions/setup-python@v4
87+
with:
88+
python-version: '3.8'
89+
90+
- name: Get coverage files
91+
uses: actions/download-artifact@v3
92+
with:
93+
name: coverage
94+
path: coverage
95+
96+
- run: pip install coverage[toml]
97+
98+
- run: ls -la coverage
99+
- run: coverage combine coverage
100+
- run: coverage report
101+
- run: coverage html --show-contexts --title "taskiq-faststream coverage for ${{ github.sha }}"
102+
103+
- name: Store coverage html
104+
uses: actions/upload-artifact@v3
105+
with:
106+
name: coverage-html
107+
path: htmlcov
108+
109+
# https://github.com/marketplace/actions/alls-green#why
110+
check: # This job does nothing and is only used for the branch protection
111+
if: github.event.pull_request.draft == false
112+
113+
needs:
114+
- coverage-combine
115+
116+
runs-on: ubuntu-latest
117+
118+
steps:
119+
- name: Decide whether the needed jobs succeeded or failed
120+
uses: re-actors/alls-green@release/v1
121+
with:
122+
jobs: ${{ toJSON(needs) }}

.pre-commit-config.yaml

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,10 @@ repos:
1616

1717
- repo: local
1818
hooks:
19-
- id: black
20-
name: Format with Black
21-
entry: poetry run black
22-
language: system
19+
- id: lint
20+
name: Linter
21+
entry: "bash scripts/lint.sh"
22+
language: python
2323
types: [python]
24-
25-
- id: mypy
26-
name: Validate types with MyPy
27-
entry: poetry run mypy
28-
language: system
29-
types: [python]
30-
pass_filenames: false
31-
args: [taskiq_faststream]
32-
33-
- id: ruff
34-
name: Run ruff lints
35-
entry: poetry run ruff
36-
language: system
37-
pass_filenames: false
38-
types: [python]
39-
args:
40-
- "--fix"
41-
- "taskiq_faststream"
42-
- "tests"
24+
require_serial: true
25+
verbose: true

CONTRIBUTING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Development
2+
3+
After cloning the project, you'll need to set up the development environment. Here are the guidelines on how to do this.
4+
5+
## Virtual Environment with `venv`
6+
7+
Create a virtual environment in a directory using Python's `venv` module:
8+
9+
```bash
10+
python -m venv venv
11+
```
12+
13+
That will create a `./venv/` directory with Python binaries, allowing you to install packages in an isolated environment.
14+
15+
## Activate the Environment
16+
17+
Activate the new environment with:
18+
19+
```bash
20+
source ./venv/bin/activate
21+
```
22+
23+
Ensure you have the latest pip version in your virtual environment:
24+
25+
```bash
26+
python -m pip install --upgrade pip
27+
```
28+
29+
## Installing Dependencies
30+
31+
After activating the virtual environment as described above, run:
32+
33+
```bash
34+
pip install -e ".[dev]"
35+
```
36+
37+
This will install all the dependencies and your local project in your virtual environment.
38+
39+
### Using Your local Project
40+
41+
If you create a Python file that imports and uses **taskiq_faststream**, and run it with the Python from your local environment, it will use your local **taskiq_faststream** source code.
42+
43+
Whenever you update your local **taskiq_faststream** source code, it will automatically use the latest version when you run your Python file again. This is because it is installed with `-e`.
44+
45+
This way, you don't have to "install" your local version to be able to test every change.
46+
47+
## Running Tests
48+
49+
### Pytest
50+
51+
To run tests with your current FastStream application and Python environment, use:
52+
53+
```bash
54+
pytest tests
55+
# or
56+
./scripts/test.sh
57+
# with coverage output
58+
./scripts/test-cov.sh
59+
```

0 commit comments

Comments
 (0)