Skip to content

Commit

Permalink
ci: update workflows and docs (#184)
Browse files Browse the repository at this point in the history
* ci: bump checkout version

* ci: modify caching

* ci: change pre-commit config

* ci: add uv

* ci: change manual pre-commit run

* ci: change mkdocs config
  • Loading branch information
RaczeQ authored Jan 3, 2025
1 parent ee8f38e commit fa3c03a
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 67 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
COLUMNS: 120
FORCE_TERMINAL_MODE: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -32,16 +32,17 @@ jobs:
python-version: ${{ matrix.python-version }}
architecture: x64
enable-pep582: true
cache: true
cache-dependency-path: "**/pdm.lock"
cache: false
- name: Install dependencies
run: pdm install -d -G test --skip=post_install
run: pdm install --no-default -d -G test --skip=post_install
- name: Cache OSM data
uses: actions/cache@v3
with:
path: cache
key: osm-cache-${{ matrix.os }}-${{ matrix.python-version }}
- name: Cache tox runner
# Cache only on the main branch
if: github.ref == 'refs/heads/main'
uses: actions/cache@v3
with:
path: .tox
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
Expand All @@ -22,8 +22,7 @@ jobs:
python-version: 3.12
architecture: x64
enable-pep582: true
cache: true
cache-dependency-path: "**/pdm.lock"
cache: false
- run: pip install toml
- uses: jannekem/run-python-script-action@v1
name: Rename test version
Expand Down Expand Up @@ -52,7 +51,7 @@ jobs:
MKDOCS_DEV: true
FORCE_TERMINAL_MODE: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.CICD_PAT_TOKEN }}
- name: Setup Python
Expand All @@ -66,17 +65,17 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-dev-
- name: Install pdm
run: pip install pdm
run: pip install pdm uv
- name: Regenerate lock with environment markers
run: pdm lock --update-reuse --strategy inherit_metadata
- name: Generate requirements.txt
run: pdm export --no-default -G docs -G visualization -G cli-dev -f requirements -o requirements.txt
- name: Install dependencies
run: pip install --no-deps -r requirements.txt
run: uv pip install --no-deps -r requirements.txt --system
- name: Install quackosm
run: |
pdm build -v -d dist
pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" --user
uv pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" --system
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
Expand Down Expand Up @@ -115,7 +114,7 @@ jobs:
- name: Fetch gh-pages branch
run: git fetch origin-quackosm-docs gh-pages --depth=1
- name: Publish dev documentation
run: mike deploy --remote origin-quackosm-docs --rebase --push dev
run: mike deploy --remote origin-quackosm-docs --push dev

deploy-docs:
name: Deploy documentation 📄 to Github Pages 🌐
Expand All @@ -126,7 +125,7 @@ jobs:
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'kraina-ai/quackosm-docs'
ref: 'gh-pages'
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/ci-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
needs: [run-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
Expand All @@ -25,8 +25,7 @@ jobs:
python-version: 3.12
architecture: x64
enable-pep582: true
cache: true
cache-dependency-path: "**/pdm.lock"
cache: false
- name: Publish distribution 📦 to PyPI
run: pdm publish --repository pypi --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} --verbose

Expand All @@ -43,7 +42,7 @@ jobs:
MKDOCS_DEV: false
FORCE_TERMINAL_MODE: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.CICD_PAT_TOKEN }}
- name: Setup Python
Expand All @@ -57,17 +56,17 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-prod-
- name: Install pdm
run: pip install pdm
run: pip install pdm uv
- name: Regenerate lock with environment markers
run: pdm lock --update-reuse --strategy inherit_metadata
- name: Generate requirements.txt
run: pdm export --no-default -G docs -G visualization -G cli-dev -f requirements -o requirements.txt
- name: Install dependencies
run: pip install --no-deps -r requirements.txt
run: uv pip install --no-deps -r requirements.txt --system
- name: Install quackosm
run: |
pdm build -v -d dist
pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" --user
uv pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" --system
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
Expand Down Expand Up @@ -105,8 +104,11 @@ jobs:
run: git remote add origin-quackosm-docs https://github.com/kraina-ai/quackosm-docs
- name: Fetch gh-pages branch
run: git fetch origin-quackosm-docs gh-pages --depth=1
- name: Get minor version
id: get-minor-version
run: python -c "print('MINOR_VERSION=' + '.'.join('${{github.ref_name}}'.split('.')[:2]))" >> "$GITHUB_OUTPUT"
- name: Publish latest documentation
run: mike deploy --remote origin-quackosm-docs --rebase --push --update-aliases ${{github.ref_name}} latest
run: mike deploy --remote origin-quackosm-docs --push --update-aliases ${{steps.get-minor-version.outputs.MINOR_VERSION}} latest

deploy-docs:
name: Deploy documentation 📄 to Github Pages 🌐
Expand All @@ -117,7 +119,7 @@ jobs:
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'kraina-ai/quackosm-docs'
ref: 'gh-pages'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/generate-dev-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
MKDOCS_DEV: true
FORCE_TERMINAL_MODE: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.CICD_PAT_TOKEN }}
- name: Setup Python
Expand All @@ -26,17 +26,17 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-dev-
- name: Install pdm
run: pip install pdm
run: pip install pdm uv
- name: Regenerate lock with environment markers
run: pdm lock --update-reuse --strategy inherit_metadata
- name: Generate requirements.txt
run: pdm export --no-default -G docs -G visualization -G cli-dev -f requirements -o requirements.txt
- name: Install dependencies
run: pip install --no-deps -r requirements.txt
run: uv pip install --no-deps -r requirements.txt --system
- name: Install quackosm
run: |
pdm build -v -d dist
pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" --user
uv pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" --system
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
- name: Fetch gh-pages branch
run: git fetch origin-quackosm-docs gh-pages --depth=1
- name: Publish dev documentation
run: mike deploy --remote origin-quackosm-docs --rebase --push dev
run: mike deploy --remote origin-quackosm-docs --push dev

deploy-docs-test:
name: Deploy documentation 📄 to Github Pages 🌐
Expand All @@ -86,7 +86,7 @@ jobs:
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: 'kraina-ai/quackosm-docs'
ref: 'gh-pages'
Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/manual_tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Run tests with newest and oldest dependencies"
on:
on:
workflow_dispatch:
workflow_call:
schedule:
Expand Down Expand Up @@ -27,22 +27,24 @@ jobs:
COLUMNS: 120
FORCE_TERMINAL_MODE: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pdm
run: pip install pdm
- name: Generate lock with newest dependencies
run: pdm lock --lockfile pdm.newest.lock --strategy no_cross_platform -G cli -dG test
- name: Install quackosm and tests dependencies
run: pdm install --lockfile pdm.newest.lock -G cli -dG test --skip=post_install
run: pip install pdm uv
- name: Generate requirements.txt
run: pdm export -dG test -f requirements -o requirements.test.txt
- name: Install quackosm
run: |
pdm build -v -d dist
uv pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" -r requirements.test.txt --system
- name: Run tests with pytest
run: |
pdm run pytest -v -s --durations=20 --doctest-modules --doctest-continue-on-failure quackosm
pdm run pytest -v -s --durations=20 tests/base
pdm run pytest -v -s --durations=20 tests/optional_imports
pytest -v -s --durations=20 --doctest-modules --doctest-continue-on-failure quackosm
pytest -v -s --durations=20 tests/base
pytest -v -s --durations=20 tests/optional_imports
run-tests-oldest:
name: Run tests 🛠️ on multiple systems 🖥️ and Python 🐍 versions (oldest dependencies)
Expand All @@ -58,7 +60,7 @@ jobs:
COLUMNS: 120
FORCE_TERMINAL_MODE: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-changelog-enforcer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
name: Run changelog enforcer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dangoslen/changelog-enforcer@v3
7 changes: 3 additions & 4 deletions .github/workflows/run-manual-pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Run pre-commit manual stage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
Expand All @@ -24,12 +24,11 @@ jobs:
python-version: "3.10"
architecture: x64
enable-pep582: true
cache: true
cache-dependency-path: "**/pdm.lock"
cache: false
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --hook-stage manual --verbose
- name: Show dependencies graph
run: |
pdm install -d -G license --skip=post_install
pdm install --no-default -d -G license --skip=post_install
pdm run pipdeptree --license
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ repos:
- id: mypy
additional_dependencies: ['types-requests', 'types-six']
- repo: https://github.com/pdm-project/pdm
rev: 2.17.3
rev: 2.22.0
hooks:
- id: pdm-lock-check
- id: pdm-export
args: ["-o", "requirements.txt", "--without-hashes", "-dG:all"]
args: ["-o", "requirements.txt", "--without-hashes", "-G", "cli", "-G", "index-generation", "-dG:all"]
files: ^pdm.lock$
stages: [manual]
- repo: https://github.com/kynan/nbstripout
Expand All @@ -58,9 +58,10 @@ repos:
language_version: python3.10
stages: [manual]
- repo: https://github.com/FHPythonUtils/LicenseCheck
rev: "2024.2"
rev: "2024.3"
hooks:
- id: licensecheck
args: ["-u", "requirements:requirements.txt"]
stages: [manual]

ci:
Expand Down
2 changes: 2 additions & 0 deletions docs/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ nav:
- Home: README.md
- Examples: examples
- ...
- Releases: releases
# - Contributing: CONTRIBUTING.md
20 changes: 20 additions & 0 deletions docs/copy_markdown_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Markdown files copying utility function."""

from pathlib import Path

import mkdocs_gen_files

with Path("README.md").open("rb") as src, mkdocs_gen_files.open("README.md", "wb") as dst:
dst.write(src.read())

with (
Path("CHANGELOG.md").open("rb") as src,
mkdocs_gen_files.open("releases/CHANGELOG.md", "wb") as dst,
):
dst.write(src.read())

# with (
# Path("CONTRIBUTING.md").open("rb") as src,
# mkdocs_gen_files.open("CONTRIBUTING.md", "wb") as dst,
# ):
# dst.write(src.read())
8 changes: 0 additions & 8 deletions docs/copy_readme.py

This file was deleted.

7 changes: 5 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
site_name: QuackOSM
site_url: null
site_url: https://kraina-ai.github.io/quackosm/

repo_url: https://github.com/kraina-ai/quackosm
repo_name: kraina-ai/quackosm
Expand Down Expand Up @@ -64,6 +64,8 @@ extra:
- accept
- manage
version:
alias: true
default: latest
provider: mike

extra_css:
Expand All @@ -84,9 +86,10 @@ plugins:
- mike:
canonical_version: "latest"
version_selector: true
alias_type: symlink
- gen-files:
scripts:
- docs/copy_readme.py
- docs/copy_markdown_files.py
- docs/copy_examples.py
- docs/gen_ref_pages.py
- docs/gen_cli_docs.py
Expand Down
Loading

0 comments on commit fa3c03a

Please sign in to comment.