Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RELEASE #3

Merged
merged 13 commits into from
Nov 12, 2023
17 changes: 17 additions & 0 deletions .github/dependabot.yml
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"
49 changes: 37 additions & 12 deletions .github/workflows/release.yml
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"
152 changes: 108 additions & 44 deletions .github/workflows/test.yml
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) }}
29 changes: 6 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,10 @@ repos:

- repo: local
hooks:
- id: black
name: Format with Black
entry: poetry run black
language: system
- id: lint
name: Linter
entry: "bash scripts/lint.sh"
language: python
types: [python]

- id: mypy
name: Validate types with MyPy
entry: poetry run mypy
language: system
types: [python]
pass_filenames: false
args: [taskiq_faststream]

- id: ruff
name: Run ruff lints
entry: poetry run ruff
language: system
pass_filenames: false
types: [python]
args:
- "--fix"
- "taskiq_faststream"
- "tests"
require_serial: true
verbose: true
59 changes: 59 additions & 0 deletions CONTRIBUTING.md
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
```
Loading