Skip to content

Commit

Permalink
move to pyproject.toml + update CI (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored Oct 25, 2023
1 parent 889156d commit 748e373
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 74 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/requirements"
schedule:
interval: monthly
time: "04:00"
timezone: Europe/Paris

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
105 changes: 67 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,74 @@

name: Release
name: Run tests and release

on:
release:
types:
- published
push:
tags:
- "*"

env:
PROJECT_FOLDER: "pirogue"
PYTHON_VERSION_RELEASE: "3.9"
PIROGUE_VERSION: ${{ github.ref_name }}

jobs:
release:
name: Deploy to PyPi
tests:
name: "Tests"
uses: ./.github/workflows/test.yml
secrets: inherit

build-python-wheel:
name: "🐍 Python Wheel"
uses: ./.github/workflows/wheel.yml
secrets: inherit

release-gh:
name: "Release on tag 🚀"
runs-on: ubuntu-latest
needs: [build-python-wheel, tests]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

steps:
- name: Retrieve artifact from Python build
uses: actions/download-artifact@v3
with:
name: python_wheel
path: dist/

- name: Create/update release on GitHub
uses: ncipollo/[email protected]
with:
allowUpdates: true
artifacts: "builds**/*"
generateReleaseNotes: true
omitNameDuringUpdate: true
token: ${{ secrets.GITHUB_TOKEN }}

release-pypi:
name: "🐍 Release on PyPI"
runs-on: ubuntu-latest
needs: [build-python-wheel, tests]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install requirements
run: |
pip install -r requirements.txt
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-
- name: Setup pirogue
run: |
VERSION=${GITHUB_REF:-0.0.0}
VERSION=${VERSION##*/}
sed -i "s/__VERSION__/${VERSION}/g" setup.py
python setup.py install sdist
pirogue -v
- name: Deploy to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Retrieve artifact from Python build
uses: actions/download-artifact@v3
with:
name: python_wheel
path: dist/

# -- FROM HERE, A TAG IS REQUIRED ---
- name: Deploy to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Create/update release on GitHub
uses: ncipollo/[email protected]
with:
allowUpdates: true
artifacts: "dist/*.tar.gz"
generateReleaseNotes: true
omitNameDuringUpdate: true
token: ${{ secrets.GITHUB_TOKEN }}
56 changes: 22 additions & 34 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,45 +42,33 @@ jobs:
PGUSER: postgres

steps:
- uses: actions/checkout@v2
- name: Get source code
uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
cache: "pip"
cache-dependency-path: "requirements*.txt"

- name: Install requirements
run: |
pip install -r requirements.txt
pip install -r test/requirements.txt
- name: Install requirements
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('test/requirements.txt') }}
restore-keys: |
pip-${{ hashFiles('requirements.txt') }}
pip-
- name: Install pirogue
run: python -m pip install -e .

- name: Setup pirogue
run: |
VERSION=${GITHUB_REF:-0.0.0}
VERSION=${VERSION##*/}
sed -i "s/__VERSION__/${VERSION}/g" setup.py
python setup.py install
pirogue -v
- name: Setup tests
run: |
printf "[pirogue_test]\nhost=localhost\ndbname=pirogue_test_db\nuser=pirogue\npassword=1234\n\n" >> ~/.pg_service.conf
PGSERVICE=pirogue_test psql --quiet -v ON_ERROR_STOP=on -f test/demo_data.sql
- name: Setup tests
run: |
printf "[pirogue_test]\nhost=localhost\ndbname=pirogue_test_db\nuser=pirogue\npassword=1234\n\n" >> ~/.pg_service.conf
PGSERVICE=pirogue_test psql --quiet -v ON_ERROR_STOP=on -f test/demo_data.sql
- name: Run bash tests
run: ./test/test_simple_inheritance.sh

- name: Run bash tests
run: |
./test/test_simple_inheritance.sh
- name: Run Python tests
run: nose2 -v
- name: Run Python tests
run: nose2 -v


45 changes: 45 additions & 0 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "🐍 Python Wheel"

on:
pull_request:
branches:
- master
push:
branches:
- master
workflow_dispatch:
workflow_call:


jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Get source code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
cache-dependency-path: "requirements*.txt"

- name: Install project requirements
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements.txt
python -m pip install -U build
- name: Install project as a package
run: python -m pip install -e .

- name: Build a binary wheel and a source tarball
run: >-
python -m build --sdist --wheel --outdir dist/ .
- uses: actions/upload-artifact@v3
with:
name: python_wheel
path: dist/*
if-no-files-found: error
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["setuptools>=61.0", "setuptools-scm", "wheel", "setuptools-git-versioning"]
build-backend = "setuptools.build_meta"

[project]
requires-python = ">=3.9"
name = "pirogue"
authors = [
{name = "Denis Rouzaud", email = "[email protected]"},
]
description = "pirogue let you dynamically and easily create views in PostgreSQL for inheritance or join scenarios."
keywords = ["postgres"]
classifiers = [
'Topic :: Database',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Intended Audience :: System Administrators',
'Intended Audience :: Information Technology',
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
]
license = { text = "MIT License" }
dynamic = ["version", "readme", "dependencies", "optional-dependencies"]

[project.urls]
homepage = "https://opengisch.github.io/pirogue/"
repository = "https://github.com/opengisch/pirogue"
tracker = "https://github.com/opengisch/pirogue/issues"

[tool.setuptools-git-versioning]
enabled = true

[tool.setuptools.dynamic]
readme = {file = ["README.md"], content-type = "text/markdown"}
dependencies = {file = ["requirements.txt"]}
optional-dependencies.test = {file = ["requirements-test.txt"]}

[tool.isort]
profile = "black"

[tool.black]
line-length = 120
File renamed without changes.
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

0 comments on commit 748e373

Please sign in to comment.