From c1b24f1c86e1fbc3ee9af8bd1efdca89c420ad40 Mon Sep 17 00:00:00 2001 From: Oliver Mannion <125105+tekumara@users.noreply.github.com> Date: Wed, 15 Mar 2023 14:40:26 +1100 Subject: [PATCH] build: add ci workflow --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++++++++++++++ Makefile-common.mk | 6 +++++- pyproject.toml | 17 ++++++--------- 3 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..65002ba --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + release: + types: [published] +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Cache virtualenv + id: cache-venv + uses: actions/cache@v3 + with: + path: .venv + key: ${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-venv-${{ hashFiles('pyproject.toml') }} + - name: Cache pre-commit + id: cache-pre-commit + uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: ${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + - name: make install + if: steps.cache-venv.outputs.cache-hit != 'true' + run: make install + - name: make hooks + run: make hooks + - name: Build python distribution + run: make dist + if: github.event.action == 'published' + - name: Publish to pypi + if: github.event.action == 'published' + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: make publish diff --git a/Makefile-common.mk b/Makefile-common.mk index e2406c6..c34c9b5 100644 --- a/Makefile-common.mk +++ b/Makefile-common.mk @@ -16,7 +16,7 @@ $(pip): $(venv)/bin/python --version $(pip) install pip~=22.3 wheel~=0.37 -$(venv): pyproject.toml $(pip) +$(venv): $(if $(value CI),|,) pyproject.toml $(pip) $(pip) install -e '.[dev, notebook]' touch $(venv) @@ -52,6 +52,10 @@ dist: $(venv) rm -rf build dist *.egg-info $(venv)/bin/python -m build --sdist --wheel +## publish to pypi +publish: $(venv) + $(venv)/bin/twine upload dist/* + ## run pre-commit git hooks on all files hooks: $(venv) $(venv)/bin/pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage push diff --git a/pyproject.toml b/pyproject.toml index a456272..5d48e4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "fakesnow" description = "Mock SnowflakeDB locally" -version = "0.0.0" +dynamic = ["version"] readme = "README.md" requires-python = ">=3.9" dependencies = [ @@ -24,24 +24,19 @@ dev = [ "pre-commit~=3.0", "pytest~=7.2", "ruff~=0.0.235", + "twine~=4.0", ] # for debugging, see https://duckdb.org/docs/guides/python/jupyter.html -notebook = [ - "duckdb-engine", - "ipykernel", - "jupysql", - "snowflake-sqlalchemy", -] +notebook = ["duckdb-engine", "ipykernel", "jupysql", "snowflake-sqlalchemy"] [tool.setuptools.packages.find] where = ["."] exclude = ["tests*"] -# use PyCharm default line length of 120 - [build-system] -requires = ["setuptools~=66.1", "wheel~=0.37"] +requires = ["setuptools~=67.6", "setuptools_scm[toml]~=7.1", "wheel~=0.40"] +# use PyCharm default line length of 120 [tool.black] line-length = 120 @@ -78,7 +73,7 @@ ignore = [ # allow == True because pandas dataframes overload equality "E712", # only relevant for python >= 3.10 - "B905" + "B905", ] # first-party imports for sorting src = ["."]