Skip to content

Commit

Permalink
Merge pull request #11 from mirumee/refactor
Browse files Browse the repository at this point in the history
Code refactor, cleanup and improvements
  • Loading branch information
pkucmus authored Jul 1, 2024
2 parents 725c856 + b7ed384 commit eff024d
Show file tree
Hide file tree
Showing 51 changed files with 1,722 additions and 1,315 deletions.
90 changes: 55 additions & 35 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
@@ -1,53 +1,73 @@
name: Code Quality

on: [push]
on:
push:

jobs:
coverage:
name: Coverage
format-check:
name: Format Check
runs-on: ubuntu-latest
env:
COVERAGE: 90
steps:
- name: Checkout source code
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

- name: Install Poetry
uses: snok/install-poetry@v1.3.4
with:
version: 1.8.2
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-1.7.1-${{ hashFiles('**/poetry.lock') }}
- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Run checks
run: |
hatch fmt --check
type-check:
name: Type Check
needs: [format-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install library
run: poetry install --no-interaction
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

# - name: Check coverage
# run: poetry run pytest --cov=smyth --cov-fail-under=${{ env.COVERAGE }} src
- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: mypy
run: poetry run mypy src
Ruff:
name: Ruff
- name: Run type checks
run: |
hatch run types:check
unit-test:
name: Unit Test
needs: [format-check, type-check]
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
steps:
- name: Ruff Check
uses: jpetrucciani/ruff-check@main
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
path: "."
python-version: ${{ matrix.python-version }}

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Run tests
if: ${{ matrix.python-version != '3.12' }}
run: |
hatch test -i python=${{ matrix.python-version }}
- name: Run tests with coverage
if: ${{ matrix.python-version == '3.12' }}
run: |
hatch test --cover -i python=${{ matrix.python-version }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'release/')}}
32 changes: 32 additions & 0 deletions .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy documentation

on:
push:
branches:
- main

jobs:
docs-publish:
name: publish documentation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Build documentation
run: hatch run docs:deploy
19 changes: 5 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
name: release
name: Publish

on:
release:
types:
- published

env:
STABLE_PYTHON_VERSION: '3.12'
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
pypi-publish:
name: upload release to PyPI
Expand All @@ -23,19 +18,15 @@ jobs:
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml

- name: Install Poetry
uses: snok/install-poetry@v1.3.4
with:
version: 1.8.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Build package
run: poetry build
run: hatch build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ __pycache__

package
*.zip
.mypy_cache
.coverage
Loading

0 comments on commit eff024d

Please sign in to comment.