From a830792b2f2fd672eec116303f6eb9d3fb9bb64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kucmus?= Date: Thu, 28 Mar 2024 22:00:40 +0100 Subject: [PATCH] add CI/CD --- .github/workflows/code_quality.yaml | 53 +++++++++++++++++++++++++++++ .github/workflows/publish.yml | 41 ++++++++++++++++++++++ pyproject.toml | 13 ++++++- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/code_quality.yaml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/code_quality.yaml b/.github/workflows/code_quality.yaml new file mode 100644 index 0000000..d841d80 --- /dev/null +++ b/.github/workflows/code_quality.yaml @@ -0,0 +1,53 @@ +name: Code Quality + +on: [push] + +jobs: + coverage: + name: Coverage + runs-on: ubuntu-latest + env: + COVERAGE: 90 + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + 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 dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + - name: Install library + run: poetry install --no-interaction + + # - name: Check coverage + # run: poetry run pytest --cov=smyth --cov-fail-under=${{ env.COVERAGE }} src + + - name: mypy + run: poetry run mypy src + Ruff: + name: Ruff + runs-on: ubuntu-latest + steps: + - name: Ruff Check + uses: jpetrucciani/ruff-check@main + with: + path: "." diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..227bfc7 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ +name: release + +on: + release: + types: + - published + +env: + STABLE_PYTHON_VERSION: '3.12' + PYTHONUNBUFFERED: "1" + FORCE_COLOR: "1" + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + 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: Build package + run: poetry build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index 208da59..64040d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,18 @@ description = "" authors = ["Mirumee "] readme = "README.md" packages = [{include = "smyth", from = "src"}] -license = "MIT" +license = "BSD-3-Clause" +repository = "https://github.com/mirumee/smyth" +classifiers = [ + "Programming Language :: Python", + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Internet :: WWW/HTTP :: HTTP Servers", + "Topic :: Software Development", +] [tool.poetry.dependencies] python = "^3.12"