Skip to content

Commit

Permalink
Hatch (#331)
Browse files Browse the repository at this point in the history
* hath / versioning

* update workflows

* lint on py39

* add pinned requirements

* ignore all venvs

* update testing and release workflows

* ident

* _

* manual trigger create pinned dependencies

* add dependabot config

* upper limit panel version

* update rtd

* remove poetry lockfile
  • Loading branch information
Jhsmit authored Aug 8, 2023
1 parent 63b1660 commit 47f14a1
Show file tree
Hide file tree
Showing 17 changed files with 1,711 additions and 4,962 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Linting
on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- run: python -m pip install black[jupyter]
- run: |
black . --check
33 changes: 33 additions & 0 deletions .github/workflows/pin_requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Generate Requirements Files

on:
workflow_dispatch:

jobs:
generate-requirements:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.9"]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install pip-tools
run: pip install pip-tools

- name: Generate requirements file
run: pip-compile --extra web --output-file requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt pyproject.toml

- name: Upload requirements file
uses: actions/upload-artifact@v3
with:
name: requirements-${{ matrix.os }}-${{ matrix.python-version }}
path: requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt
11 changes: 4 additions & 7 deletions .github/workflows/pypi_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: |
pip install poetry-dynamic-versioning
- name: Install Hatch
run: pip install hatch
- name: Build
run: poetry build
- name: Publish distribution 📦 to Test PyPI
run: hatch build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
11 changes: 4 additions & 7 deletions .github/workflows/pypi_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: |
pip install poetry-dynamic-versioning
- name: Install Hatch
run: pip install hatch
- name: Build
run: poetry build
run: hatch build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
75 changes: 12 additions & 63 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
name: Testing and Linting
name: Testing
on: [push]

# adapted from: https://github.com/tiangolo/poetry-version-plugin
jobs:
linting:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
#----------------------------------------------
# load pip cache if cache exists
#----------------------------------------------
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: ${{ runner.os }}-pip
#----------------------------------------------
# install and run linters
#----------------------------------------------
- run: python -m pip install black
- run: |
black . --check
test:
needs: linting
strategy:
fail-fast: true
matrix:
Expand All @@ -40,50 +14,25 @@ jobs:
shell: bash
runs-on: ${{ matrix.os }}
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3

- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- 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 }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
cache: pip
cache-dependency-path: requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt

- name: Install pinned requirements
run: |
poetry install --no-interaction --no-root --all-extras
#----------------------------------------------
# install root project
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction --all-extras
#----------------------------------------------
# run test suite
#----------------------------------------------
python -m pip install --upgrade pip
pip install -r requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt --prefer-binary
- name: Install test requirements
run: pip install .[test]

- name: Run tests
run: |
source $VENV
pytest tests/
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ celerybeat-schedule
.env

# virtualenv
.venv
.venv*
venv/
ENV/

Expand All @@ -106,6 +106,5 @@ ENV/
# Dask
dask-worker-space/


# Generated conda requirements file
_req-*.txt
# Hatch-vcs generated version file
_version.py
8 changes: 8 additions & 0 deletions dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
requirements:
- file: "requirements/requirements-*.txt"
Loading

0 comments on commit 47f14a1

Please sign in to comment.