Skip to content

Commit

Permalink
build: add ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tekumara committed Mar 15, 2023
1 parent 559872a commit c1b24f1
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion Makefile-common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
17 changes: 6 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -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

Expand Down Expand Up @@ -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 = ["."]
Expand Down

0 comments on commit c1b24f1

Please sign in to comment.