Skip to content

Commit

Permalink
refactor: bigger code upgrade and improves
Browse files Browse the repository at this point in the history
- add github workflows
- update project.toml by disable multi parts to not see every needed fix now
- improve tests cases
- improve code quality
- ...
  • Loading branch information
MVladislav committed Dec 21, 2024
1 parent 7cc746e commit 7c001d6
Show file tree
Hide file tree
Showing 77 changed files with 2,708 additions and 2,742 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: CI

on:
push:
branches:
- main
- dev
pull_request:
workflow_dispatch:

env:
UV_CACHE_DIR: /tmp/.uv-cache
PROJECT_PATH: "amqtt"

jobs:
code-quality:
name: Check code quality
runs-on: ubuntu-latest

steps:
# https://github.com/actions/checkout
- name: ⤵️ Checkout repository
uses: actions/checkout@v4

# https://github.com/astral-sh/setup-uv
- name: 🏗 Install uv and Python
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
cache-local-path: ${{ env.UV_CACHE_DIR }}
python-version: "3.13"

- name: 🏗 Install the project
run: uv sync --locked --dev

- name: Run mypy
run: uv run --frozen mypy ${{ env.PROJECT_PATH }}/
- name: Pylint review
run: uv run --frozen pylint ${{ env.PROJECT_PATH }}/

tests:
name: Run tests
runs-on: ubuntu-latest

strategy:
matrix:
python-version:
- "3.12"
- "3.13"

steps:
# https://github.com/actions/checkout
- name: ⤵️ Checkout repository
uses: actions/checkout@v4

# https://github.com/astral-sh/setup-uv
- name: 🏗 Install uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
cache-local-path: ${{ env.UV_CACHE_DIR }}
python-version: ${{ matrix.python-version }}

- name: 🏗 Install the project
run: uv sync --locked --dev

- name: Run pytest
run: uv run --frozen pytest tests --cov=./ --cov-report=xml --junitxml=pytest-report.xml

# https://github.com/actions/upload-artifact
- name: Upload test report
uses: actions/upload-artifact@v4
with:
name: pytest-report-${{ matrix.python-version }}
path: pytest-report.xml

# https://github.com/actions/upload-artifact
- name: Upload coverage results
uses: actions/upload-artifact@v4
with:
name: coverage-results-${{ matrix.python-version }}
path: coverage.xml

# # https://github.com/codecov/codecov-action
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v5
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
48 changes: 48 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: CodeQL

on:
push:
branches:
- main
- dev
pull_request:
workflow_dispatch:
# schedule:
# - cron: "20 10 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["python"]

steps:
# https://github.com/actions/checkout
- name: Checkout repository
uses: actions/checkout@v4

# https://github.com/github/codeql-action
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

# https://github.com/github/codeql-action
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# https://github.com/github/codeql-action
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
74 changes: 37 additions & 37 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
# name: Python package

on:
push:
branches: [master, v0.10.x]
pull_request:
branches: [master, v0.10.x]
# on:
# push:
# branches: [master, v0.10.x]
# pull_request:
# branches: [master, v0.10.x]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
# jobs:
# build:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python -
$HOME/.local/bin/poetry install --extras ci
- name: Lint with flake8 and black
run: |
$HOME/.local/bin/poetry run flake8 tests/ amqtt/ --count --statistics --show-source
$HOME/.local/bin/poetry run black . --check
- name: Test with pytest
run: |
$HOME/.local/bin/poetry run pytest --cov amqtt --cov tests --cov-report=term --cov-report=xml
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# curl -sSL https://install.python-poetry.org | python -
# $HOME/.local/bin/poetry install --extras ci
# - name: Lint with flake8 and black
# run: |
# $HOME/.local/bin/poetry run flake8 tests/ amqtt/ --count --statistics --show-source
# $HOME/.local/bin/poetry run black . --check
# - name: Test with pytest
# run: |
# $HOME/.local/bin/poetry run pytest --cov amqtt --cov tests --cov-report=term --cov-report=xml

- name: Upload coverage data to coveralls.io
run: |
$HOME/.local/bin/poetry run coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Upload coverage data to coveralls.io
# run: |
# $HOME/.local/bin/poetry run coveralls --service=github
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Release Drafter

on:
push:
tags:
# Push events to matching v*, i.e. v1.0, v20.15.10
- "v*"
workflow_dispatch:

jobs:
update_release_draft:
name: Update Release Draft
runs-on: ubuntu-latest

permissions:
contents: write

steps:
# https://github.com/release-drafter/release-drafter
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions amqtt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# See the file license.txt for copying permission.
"""INIT."""

__version__ = "0.10.0"
__version__ = "0.11.0-beta2"
Loading

0 comments on commit 7c001d6

Please sign in to comment.