-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
925 additions
and
1,084 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
# GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
# Python | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,49 @@ | ||
name: Release python package | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
workflow_run: | ||
workflows: [Test] | ||
types: [completed] | ||
|
||
jobs: | ||
deploy: | ||
publish: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install deps | ||
run: poetry install | ||
- name: Release package | ||
python-version: "3.8" | ||
cache: "pip" | ||
cache-dependency-path: pyproject.toml | ||
|
||
- uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish | ||
|
||
- name: Install build dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: pip install build | ||
|
||
- name: Build distribution | ||
run: python -m build | ||
|
||
- name: Publish | ||
uses: pypa/[email protected] | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
|
||
- name: Dump GitHub context | ||
env: | ||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} | ||
run: poetry publish --build | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,122 @@ | ||
name: Testing package | ||
name: Test | ||
|
||
on: push | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
lint: | ||
strategy: | ||
matrix: | ||
cmd: | ||
- black | ||
- mypy | ||
- ruff | ||
static_analysis: | ||
if: github.event.pull_request.draft == false | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
cache: "poetry" | ||
- name: Install deps | ||
run: poetry install | ||
- name: Run lint check | ||
run: poetry run pre-commit run -a ${{ matrix.cmd }} | ||
pytest: | ||
permissions: | ||
checks: write | ||
pull-requests: write | ||
contents: write | ||
python-version: 3.8 | ||
- name: Install Dependencies and library | ||
shell: bash | ||
run: | | ||
set -ux | ||
python -m pip install --upgrade pip | ||
pip install -e ".[dev]" | ||
- name: Run black | ||
shell: bash | ||
run: black taskiq_faststream | ||
|
||
- name: Run mypy | ||
shell: bash | ||
run: mypy taskiq_faststream | ||
|
||
- name: Run ruff | ||
shell: bash | ||
run: ruff taskiq_faststream | ||
|
||
test: | ||
if: github.event.pull_request.draft == false | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
py_version: ["3.8", "3.9", "3.10", "3.11"] | ||
os: [ubuntu-latest, windows-latest] | ||
runs-on: "${{ matrix.os }}" | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
pydantic-version: ["pydantic-v1", "pydantic-v2"] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "${{ matrix.py_version }}" | ||
cache: "poetry" | ||
- name: Install deps | ||
run: poetry install | ||
- name: Run pytest check | ||
run: poetry run pytest -vv -n auto --cov="taskiq_faststream" . | ||
- name: Generate report | ||
run: poetry run coverage xml | ||
- name: Upload coverage reports to Codecov with GitHub Action | ||
uses: codecov/codecov-action@v3 | ||
if: matrix.os == 'ubuntu-latest' && matrix.py_version == '3.9' | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: false | ||
verbose: true | ||
python-version: ${{ matrix.python-version }} | ||
- uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test-v03 | ||
- name: Install Dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: pip install -e .[test] | ||
- name: Install Pydantic v1 | ||
if: matrix.pydantic-version == 'pydantic-v1' | ||
run: pip install "pydantic>=1.10,<2" | ||
- name: Install Pydantic v2 | ||
if: matrix.pydantic-version == 'pydantic-v2' | ||
run: pip install --pre "pydantic>=2,<3" | ||
- run: mkdir coverage | ||
- name: Test | ||
run: bash scripts/test.sh | ||
env: | ||
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} | ||
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} | ||
- name: Store coverage files | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage | ||
path: coverage | ||
|
||
coverage-combine: | ||
needs: [test] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.8' | ||
|
||
- name: Get coverage files | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: coverage | ||
path: coverage | ||
|
||
- run: pip install coverage[toml] | ||
|
||
- run: ls -la coverage | ||
- run: coverage combine coverage | ||
- run: coverage report | ||
- run: coverage html --show-contexts --title "taskiq-faststream coverage for ${{ github.sha }}" | ||
|
||
- name: Store coverage html | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-html | ||
path: htmlcov | ||
|
||
# https://github.com/marketplace/actions/alls-green#why | ||
check: # This job does nothing and is only used for the branch protection | ||
if: github.event.pull_request.draft == false | ||
|
||
needs: | ||
- coverage-combine | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Development | ||
|
||
After cloning the project, you'll need to set up the development environment. Here are the guidelines on how to do this. | ||
|
||
## Virtual Environment with `venv` | ||
|
||
Create a virtual environment in a directory using Python's `venv` module: | ||
|
||
```bash | ||
python -m venv venv | ||
``` | ||
|
||
That will create a `./venv/` directory with Python binaries, allowing you to install packages in an isolated environment. | ||
|
||
## Activate the Environment | ||
|
||
Activate the new environment with: | ||
|
||
```bash | ||
source ./venv/bin/activate | ||
``` | ||
|
||
Ensure you have the latest pip version in your virtual environment: | ||
|
||
```bash | ||
python -m pip install --upgrade pip | ||
``` | ||
|
||
## Installing Dependencies | ||
|
||
After activating the virtual environment as described above, run: | ||
|
||
```bash | ||
pip install -e ".[dev]" | ||
``` | ||
|
||
This will install all the dependencies and your local project in your virtual environment. | ||
|
||
### Using Your local Project | ||
|
||
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. | ||
|
||
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`. | ||
|
||
This way, you don't have to "install" your local version to be able to test every change. | ||
|
||
## Running Tests | ||
|
||
### Pytest | ||
|
||
To run tests with your current FastStream application and Python environment, use: | ||
|
||
```bash | ||
pytest tests | ||
# or | ||
./scripts/test.sh | ||
# with coverage output | ||
./scripts/test-cov.sh | ||
``` |
Oops, something went wrong.