From fa3c03a9baacecbd4b4bb8fae63da834e25ed4af Mon Sep 17 00:00:00 2001 From: Kamil Raczycki Date: Fri, 3 Jan 2025 01:05:31 +0100 Subject: [PATCH] ci: update workflows and docs (#184) * 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 --- .github/workflows/_tests.yml | 9 ++++---- .github/workflows/ci-dev.yml | 17 +++++++------- .github/workflows/ci-prod.yml | 20 ++++++++-------- .github/workflows/generate-dev-docs.yml | 12 +++++----- .github/workflows/manual_tests.yml | 24 +++++++++++--------- .github/workflows/run-changelog-enforcer.yml | 2 +- .github/workflows/run-manual-pre-commit.yml | 7 +++--- .pre-commit-config.yaml | 7 +++--- docs/.pages | 2 ++ docs/copy_markdown_files.py | 20 ++++++++++++++++ docs/copy_readme.py | 8 ------- mkdocs.yml | 7 ++++-- pdm.lock | 17 +++++++------- pyproject.toml | 4 ++-- 14 files changed, 89 insertions(+), 67 deletions(-) create mode 100644 docs/copy_markdown_files.py delete mode 100644 docs/copy_readme.py diff --git a/.github/workflows/_tests.yml b/.github/workflows/_tests.yml index 6131a4e2..ed395724 100644 --- a/.github/workflows/_tests.yml +++ b/.github/workflows/_tests.yml @@ -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: @@ -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 diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml index 143424be..63935b79 100644 --- a/.github/workflows/ci-dev.yml +++ b/.github/workflows/ci-dev.yml @@ -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: @@ -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 @@ -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 @@ -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" @@ -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 🌐 @@ -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' diff --git a/.github/workflows/ci-prod.yml b/.github/workflows/ci-prod.yml index 9ba37a67..bfddead4 100644 --- a/.github/workflows/ci-prod.yml +++ b/.github/workflows/ci-prod.yml @@ -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: @@ -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 @@ -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 @@ -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" @@ -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 🌐 @@ -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' diff --git a/.github/workflows/generate-dev-docs.yml b/.github/workflows/generate-dev-docs.yml index ed4fde5a..a8c2ed3d 100644 --- a/.github/workflows/generate-dev-docs.yml +++ b/.github/workflows/generate-dev-docs.yml @@ -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 @@ -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" @@ -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 🌐 @@ -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' diff --git a/.github/workflows/manual_tests.yml b/.github/workflows/manual_tests.yml index fd7c16ef..a06b3a95 100644 --- a/.github/workflows/manual_tests.yml +++ b/.github/workflows/manual_tests.yml @@ -1,5 +1,5 @@ name: "Run tests with newest and oldest dependencies" -on: +on: workflow_dispatch: workflow_call: schedule: @@ -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) @@ -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: diff --git a/.github/workflows/run-changelog-enforcer.yml b/.github/workflows/run-changelog-enforcer.yml index 26755537..b4aad099 100644 --- a/.github/workflows/run-changelog-enforcer.yml +++ b/.github/workflows/run-changelog-enforcer.yml @@ -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 diff --git a/.github/workflows/run-manual-pre-commit.yml b/.github/workflows/run-manual-pre-commit.yml index 3520bdb8..dd52d832 100644 --- a/.github/workflows/run-manual-pre-commit.yml +++ b/.github/workflows/run-manual-pre-commit.yml @@ -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: @@ -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/action@v3.0.0 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c139a20f..4009685a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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: diff --git a/docs/.pages b/docs/.pages index ea746d5f..144b61d7 100644 --- a/docs/.pages +++ b/docs/.pages @@ -2,3 +2,5 @@ nav: - Home: README.md - Examples: examples - ... + - Releases: releases + # - Contributing: CONTRIBUTING.md diff --git a/docs/copy_markdown_files.py b/docs/copy_markdown_files.py new file mode 100644 index 00000000..6c001cc7 --- /dev/null +++ b/docs/copy_markdown_files.py @@ -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()) diff --git a/docs/copy_readme.py b/docs/copy_readme.py deleted file mode 100644 index c22b6f99..00000000 --- a/docs/copy_readme.py +++ /dev/null @@ -1,8 +0,0 @@ -"""Readme 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()) diff --git a/mkdocs.yml b/mkdocs.yml index 900af36b..0c93b96d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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 @@ -64,6 +64,8 @@ extra: - accept - manage version: + alias: true + default: latest provider: mike extra_css: @@ -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 diff --git a/pdm.lock b/pdm.lock index ce40bcb8..809d7541 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "cli", "cli-dev", "dev", "docs", "license", "lint", "test"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:ad4e7cdbb535cf1c3e1f6d1e4c88bafb9d857840be9948ed429ad5423ed0f2cc" +content_hash = "sha256:f6187013d8a4ece44577a32d503e1d859cd7d612f2106e956c6651eaa3dacd28" [[metadata.targets]] requires_python = ">=3.9" @@ -1223,7 +1223,6 @@ version = "8.4.0" requires_python = ">=3.8" summary = "Read metadata from Python packages" groups = ["default", "docs", "license"] -marker = "python_version < \"3.10\"" dependencies = [ "typing-extensions>=3.6.4; python_version < \"3.8\"", "zipp>=0.5", @@ -1239,7 +1238,6 @@ version = "6.4.4" requires_python = ">=3.8" summary = "Read resources from Python packages" groups = ["cli-dev", "docs"] -marker = "python_version < \"3.10\"" dependencies = [ "zipp>=3.1.0; python_version < \"3.10\"", ] @@ -2085,18 +2083,22 @@ files = [ [[package]] name = "mike" -version = "1.1.2" +version = "2.1.3" summary = "Manage multiple versions of your MkDocs-powered documentation" groups = ["docs"] dependencies = [ - "jinja2", + "importlib-metadata", + "importlib-resources", + "jinja2>=2.7", "mkdocs>=1.0", + "pyparsing>=3.0", + "pyyaml-env-tag", "pyyaml>=5.1", "verspec", ] files = [ - {file = "mike-1.1.2-py3-none-any.whl", hash = "sha256:4c307c28769834d78df10f834f57f810f04ca27d248f80a75f49c6fa2d1527ca"}, - {file = "mike-1.1.2.tar.gz", hash = "sha256:56c3f1794c2d0b5fdccfa9b9487beb013ca813de2e3ad0744724e9d34d40b77b"}, + {file = "mike-2.1.3-py3-none-any.whl", hash = "sha256:d90c64077e84f06272437b464735130d380703a76a5738b152932884c60c062a"}, + {file = "mike-2.1.3.tar.gz", hash = "sha256:abd79b8ea483fb0275b7972825d3082e5ae67a41820f8d8a0dc7a3f49944e810"}, ] [[package]] @@ -4603,7 +4605,6 @@ version = "3.20.1" requires_python = ">=3.8" summary = "Backport of pathlib-compatible object wrapper for zip files" groups = ["default", "cli-dev", "docs", "license"] -marker = "python_version < \"3.10\"" files = [ {file = "zipp-3.20.1-py3-none-any.whl", hash = "sha256:9960cd8967c8f85a56f920d5d507274e74f9ff813a0ab8889a5b5be2daf44064"}, {file = "zipp-3.20.1.tar.gz", hash = "sha256:c22b14cc4763c5a5b04134207736c107db42e9d3ef2d9779d465f5f1bcba572b"}, diff --git a/pyproject.toml b/pyproject.toml index aea8a6e9..c26b3f39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,7 +91,7 @@ docs = [ "ipykernel", "mkdocs-gen-files", "mkdocs-awesome-pages-plugin", - "mike>=1,<2", + "mike>=2", "black", "jupyter", "nbconvert", @@ -103,7 +103,7 @@ docs = [ "adjustText", "contextily", ] -license = ["licensecheck", "pipdeptree"] +license = ["licensecheck==2024.3", "pipdeptree"] cli-dev = ["ipywidgets", "folium", "matplotlib>=3.2.0", "mapclassify"] [tool.pdm.scripts]