Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

♻️ Refactor build system to use Hatch instead of Poetry #85

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,26 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Get full python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install poetry
run: |
python -m pip install --upgrade pip
python -m pip install "poetry>=1.2.0a1"
python -m poetry plugin add poetry-version-plugin
- name: Configure poetry
run: python -m poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v1
cache: "pip"
cache-dependency-path: requirements.txt
- uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
- name: Install Dependencies
run: python -m poetry install
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}-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/gh-action-pypi-publish@v1.6.4
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Dump GitHub context
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
python -m poetry config pypi-token.pypi $PYPI_TOKEN
bash scripts/publish.sh
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
33 changes: 12 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Test

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
workflow_dispatch:
Expand All @@ -22,39 +24,28 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: requirements.txt
# Allow debugging with tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Get full python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install poetry
run: |
python -m pip install --upgrade pip
python -m pip install "poetry>=1.2.0a1,<=1.2.0b1"
python -m poetry plugin add poetry-version-plugin
- name: Configure poetry
run: python -m poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v1
- uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: python -m poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}-test-v03
- name: Install Dependencies
run: python -m poetry install
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements.txt
- name: Lint
run: python -m poetry run bash scripts/lint.sh
run: bash scripts/lint.sh
- name: Test
run: python -m poetry run bash scripts/test.sh
run: bash scripts/test.sh
- name: Upload coverage
uses: codecov/codecov-action@v2
49 changes: 21 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[tool.poetry]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "typer-cli"
version = "0"
description = "Run Typer scripts with completion, without having to create a package, using Typer CLI."
authors = ["Sebastián Ramírez <tiangolo@gmail.com>"]
readme = "README.md"
requires-python = ">=3.7"
license = "MIT"
homepage = "https://github.com/tiangolo/typer-cli"
repository = "https://github.com/tiangolo/typer-cli"
documentation = "https://typer.tiangolo.com/typer-cli/"
authors = [
{name = "Sebastián Ramírez", email = "tiangolo@gmail.com"},
]
classifiers = [
"Environment :: Console",
"Intended Audience :: Developers",
Expand All @@ -34,32 +37,22 @@ classifiers = [
"License :: OSI Approved :: MIT License"
]

[tool.poetry.dependencies]
python = "^3.7"
typer = ">=0.4.0,<=0.7.0"
colorama = "^0.4.3"
shellingham = "^1.3.2"
dynamic = ["version"]
dependencies = [
"typer >=0.4.0,<=0.7.0",
"colorama >=0.4.3,<=0.5.0",
"shellingham >=1.3.2,<=1.4.0",
]

[tool.poetry.dev-dependencies]
pytest = "^7.0.1"
black = "^22.3"
pytest-cov = "^2.8.1"
pytest-xdist = "^2.1.0"
pytest-sugar = "^0.9.2"
mypy = "^0.910"
flake8 = "^4.0.1"
isort = "^5.0.6"
autoflake = "^1.3.1"
[project.urls]
Homepage = "https://github.com/tiangolo/typer-cli"
Documentation = "https://typer.tiangolo.com/typer-cli/"

[tool.poetry.scripts]
[project.scripts]
typer = "typer_cli.main:main"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.poetry-version-plugin]
source = "init"
[tool.hatch.version]
path = "typer_cli/__init__.py"

[tool.isort]
profile = "black"
15 changes: 15 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Self
-e .

# Test
pytest == 7.0.1
pytest-cov == 2.10.1
pytest-xdist == 2.1.0
pytest-sugar == 0.9.2

# Format and lint
black == 22.3
mypy == 0.910
flake8 == 4.0.1
isort == 5.0.6
autoflake == 1.3.1