Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
gboeing committed Dec 8, 2024
1 parent a2f0975 commit e2c621a
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/build-publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and publish Docker image

on:
push:
tags:
- 'v*'
schedule:
- cron: "30 6 * * 1" # every monday at 06:30 UTC
workflow_dispatch:

jobs:
build_publish_docker:
if: ${{ github.repository == 'gboeing/osmnx' }}
name: Build/publish image to Docker Hub
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}

- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./environments/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'schedule' }}
tags: ${{ steps.meta.outputs.tags }}
46 changes: 46 additions & 0 deletions .github/workflows/build-publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and publish to PyPI

on:
push:
tags:
- 'v*'
schedule:
- cron: "0 6 * * 1" # every monday at 06:00 UTC
workflow_dispatch:

jobs:
build_publish_pypi:
if: ${{ github.repository == 'gboeing/osmnx' }}
name: Build/publish package to PyPI
runs-on: ubuntu-latest

defaults:
run:
shell: bash -elo pipefail {0}

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Build and check package
run: |
python -m pip install --user hatch twine validate-pyproject[all]
python -m validate_pyproject ./pyproject.toml
python -m hatch build --clean
python -m twine check --strict ./dist/*
- name: Publish package to PyPI
if: ${{ github.event_name != 'schedule' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository-url: https://test.pypi.org/legacy/
print-hash: true
verbose: true
verify-metadata: true
33 changes: 33 additions & 0 deletions .github/workflows/test-docs-linkcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build docs and check links

on:
schedule:
- cron: "30 4 * * 1" # every monday at 04:30 UTC
workflow_dispatch:

jobs:
test_docs_linkcheck:
if: ${{ github.repository == 'gboeing/osmnx' }}
name: Build docs and check links
runs-on: ubuntu-latest

defaults:
run:
shell: bash -elo pipefail {0}

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install requirements
run: |
python -m pip install --user furo "sphinx==7.*" sphinx-autodoc-typehints
python -m pip check
- name: Build docs and check links
run: python -m sphinx -E -W --keep-going -b linkcheck ./docs/source ./docs/build/linkcheck
41 changes: 41 additions & 0 deletions .github/workflows/test-latest-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test latest/pre-release dependency versions

on:
schedule:
- cron: "30 5 * * 1" # every monday at 05:30 UTC
workflow_dispatch:

jobs:
test_latest_deps:
if: ${{ github.repository == 'gboeing/osmnx' }}
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

defaults:
run:
shell: bash -elo pipefail {0}

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install OSMnx with latest/pre-release dependencies
run: |
python -m pip install --pre -r ./environments/tests/requirements-test-latest-deps.txt
python -m pip install -e .
python -m pip check
python -m pip list -v
python -m pip show osmnx
python --version
- name: Test code
run: pytest --verbose --maxfail=1
41 changes: 41 additions & 0 deletions .github/workflows/test-minimum-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test minimum dependency versions

on:
schedule:
- cron: "0 5 * * 1" # every monday at 05:00 UTC
workflow_dispatch:

jobs:
test_minimum_deps:
if: ${{ github.repository == 'gboeing/osmnx' }}
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

defaults:
run:
shell: bash -elo pipefail {0}

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Create environment with minimum dependency versions
uses: mamba-org/setup-micromamba@v2
with:
cache-environment: true
environment-file: ./environments/tests/env-test-minimum-deps.yml
post-cleanup: none

- name: Install OSMnx
run: |
python -m pip install -e .
python -m pip check
micromamba list
python -m pip show osmnx
- name: Test code
run: pytest --verbose --maxfail=1
3 changes: 2 additions & 1 deletion environments/docker/docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -e
#docker image prune -af && docker system prune -af && docker volume prune -af && docker system df
docker login
docker buildx build --no-cache --pull --push --platform=linx/amd64,linux/arm64 -f ./environments/docker/Dockerfile -t gboeing/osmnx:test .
docker buildx build --no-cache --pull --push --platform=linux/amd64,linux/arm64 -f ./environments/docker/Dockerfile -t gboeing/osmnx:test .
IMPORTED_VERSION=$(docker run --rm gboeing/osmnx:test /bin/bash -c "ipython -c \"import osmnx; print(osmnx.__version__)\"")
echo "Imported $IMPORTED_VERSION"
31 changes: 31 additions & 0 deletions environments/tests/env-test-minimum-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Pin dependencies to minimum required minor versions. Allows you to create a
# conda env to run the test suite against the oldest supported versions of
# Python and the package's required dependencies.
name: env-test-minimal

channels:
- conda-forge

dependencies:
# pin minimum supported python version from pyproject.toml
- python=3.9

# pin required dependencies' min versions from pyproject.toml
- geopandas=1.0
- networkx=2.5
- numpy=1.22
- pandas=1.4
- requests=2.27
- shapely=2.0

# pin optional dependencies' min versions from pyproject.toml
- matplotlib=3.5
- rasterio=1.3
- rio-vrt=0.3
- scikit-learn=0.23
- scipy=1.5

# testing
- lxml
- pytest
- typeguard
26 changes: 26 additions & 0 deletions environments/tests/requirements-test-latest-deps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# requirements
geopandas
networkx
numpy
pandas
requests
shapely

# extras
matplotlib
rasterio
rio-vrt
scikit-learn
scipy

# linting/testing
lxml
pre-commit
pytest
pytest-cov
typeguard

# docs
furo
sphinx == 7.*
sphinx-autodoc-typehints

0 comments on commit e2c621a

Please sign in to comment.