From dc5bea6976afb53c20baa0c9fa754686f2bf15bb Mon Sep 17 00:00:00 2001 From: DanCardin Date: Wed, 20 Sep 2023 07:13:02 -0400 Subject: [PATCH] feat: Add CI. --- .github/workflows/release.yml | 37 +++++++++++++++++ .github/workflows/test.yml | 77 +++++++++++++++++++++++++++++++++++ poetry.lock | 26 +++++++----- pyproject.toml | 2 +- src/cappa/invoke.py | 2 +- 5 files changed, 131 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..884ff3e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Github Release/Publish PyPi + +on: + push: + tags: + - "v*.*.*" + +jobs: + gh-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Release + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/cappa + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Install poetry + uses: abatilo/actions-poetry@v2.0.0 + with: + poetry-version: 1.2.2 + - name: Checkout + uses: actions/checkout@v1 + - name: Build dist + run: poetry build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..9b593c6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,77 @@ +name: Test + +on: + pull_request: + branches: + - main + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + + - name: Install poetry + uses: abatilo/actions-poetry@v2.0.0 + with: + poetry-version: 1.2.2 + + - name: Set up cache + uses: actions/cache@v3 + with: + path: ~/.cache/pypoetry/virtualenvs + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + ${{ runner.os }}-poetry- + + - name: Install dependencies + run: poetry install -E rich + + - name: Run Linters + run: poetry run make lint + + - name: Run tests + run: poetry run make test + + - name: Store test result artifacts + uses: actions/upload-artifact@v3 + with: + path: coverage.xml + + - name: Coveralls + env: + COVERALLS_FLAG_NAME: run-${{ inputs.working-directory }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_PARALLEL: true + run: | + pip install tomli coveralls + coveralls --service=github + + finish: + needs: + - test + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip install tomli coveralls + coveralls --service=github --finish diff --git a/poetry.lock b/poetry.lock index 3ecdfad..3c46743 100644 --- a/poetry.lock +++ b/poetry.lock @@ -11,6 +11,9 @@ files = [ {file = "annotated_types-0.5.0.tar.gz", hash = "sha256:47cdc3490d9ac1506ce92c7aaa76c579dc3509ff11e098fc867e5130ab7be802"}, ] +[package.dependencies] +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} + [[package]] name = "attrs" version = "23.1.0" @@ -519,18 +522,19 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no [[package]] name = "rich" -version = "13.5.2" +version = "13.5.3" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = true python-versions = ">=3.7.0" files = [ - {file = "rich-13.5.2-py3-none-any.whl", hash = "sha256:146a90b3b6b47cac4a73c12866a499e9817426423f57c5a66949c086191a8808"}, - {file = "rich-13.5.2.tar.gz", hash = "sha256:fb9d6c0a0f643c99eed3875b5377a184132ba9be4d61516a55273d3554d75a39"}, + {file = "rich-13.5.3-py3-none-any.whl", hash = "sha256:9257b468badc3d347e146a4faa268ff229039d4c2d176ab0cffb4c4fbc73d5d9"}, + {file = "rich-13.5.3.tar.gz", hash = "sha256:87b43e0543149efa1253f485cd845bb7ee54df16c9617b8a893650ab84b4acb6"}, ] [package.dependencies] markdown-it-py = ">=2.2.0" pygments = ">=2.13.0,<3.0.0" +typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] @@ -588,13 +592,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.7.1" -description = "Backported and Experimental Type Hints for Python 3.7+" +version = "4.8.0" +description = "Backported and Experimental Type Hints for Python 3.8+" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, - {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, + {file = "typing_extensions-4.8.0-py3-none-any.whl", hash = "sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"}, + {file = "typing_extensions-4.8.0.tar.gz", hash = "sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef"}, ] [[package]] @@ -613,9 +617,9 @@ mypy-extensions = ">=0.3.0" typing-extensions = ">=3.7.4" [extras] -rich = ["rich", "rich-argparse"] +color = ["rich", "rich-argparse"] [metadata] lock-version = "2.0" -python-versions = "^3.10" -content-hash = "c31ece6b00f870d8ec4306cd50393c37d88baec4aba9d28688e99d8e0ab23040" +python-versions = "^3.8" +content-hash = "0001d7d645e0d6853e2504d8e29ee677747f5b67f7d4145e796e04f9220039ac" diff --git a/pyproject.toml b/pyproject.toml index ffadf83..a0ac44d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ packages = [{include = "cappa", from = "src"}] color = ["rich", "rich-argparse"] [tool.poetry.dependencies] -python = "^3.10" +python = "^3.8" typing-extensions = "^4.7.1" typing-inspect = "^0.9.0" docstring-parser = "^0.15" diff --git a/src/cappa/invoke.py b/src/cappa/invoke.py index 24ad77a..94afaf5 100644 --- a/src/cappa/invoke.py +++ b/src/cappa/invoke.py @@ -5,7 +5,7 @@ import typing from dataclasses import dataclass -from typing_extensions import Callable, get_type_hints # type: ignore +from typing_extensions import Callable, get_type_hints from cappa.command import Command, HasCommand from cappa.typing import find_type_annotation