From 5ff5f49c20d17948cf53709bc882b39d40c04062 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Wed, 25 Oct 2023 14:06:13 +0200 Subject: [PATCH] move to pyproject.toml + update CI --- .github/dependabot.yml | 13 +++ .github/workflows/release.yml | 105 +++++++++++------- .github/workflows/test.yml | 56 ++++------ .github/workflows/wheel.yml | 45 ++++++++ pyproject.toml | 41 +++++++ .../requirements.txt => requirements-test.txt | 0 setup.cfg | 2 - 7 files changed, 188 insertions(+), 74 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/wheel.yml create mode 100644 pyproject.toml rename test/requirements.txt => requirements-test.txt (100%) delete mode 100644 setup.cfg diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1effca5 --- /dev/null +++ b/.github/dependabot.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 158f020..affbeba 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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/release-action@v1.13.0 + 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/release-action@v1.13.0 + with: + allowUpdates: true + artifacts: "dist/*.tar.gz" + generateReleaseNotes: true + omitNameDuringUpdate: true + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0200004..52016af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml new file mode 100644 index 0000000..a5c36de --- /dev/null +++ b/.github/workflows/wheel.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7b937f2 --- /dev/null +++ b/pyproject.toml @@ -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 = "info@opengis.ch"}, +] +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 diff --git a/test/requirements.txt b/requirements-test.txt similarity index 100% rename from test/requirements.txt rename to requirements-test.txt diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b88034e..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md