Bump uv #2366
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Docs | |
"on": | |
workflow_call: | |
inputs: | |
dependency-graph-output: | |
description: 'Location in the repository of the dependency graph image.' | |
default: './docs/assets/dependencies.mmd' | |
required: false | |
type: string | |
push: | |
branches: | |
- main | |
# Defaults sets in workflow_call.inputs or workflow_dispatch.inputs are not propagated to other events. | |
# We have to manually manage them: https://github.com/orgs/community/discussions/39357#discussioncomment-7500641 | |
env: | |
dependency-graph-output: > | |
${{ inputs.dependency-graph-output == null && './docs/assets/dependencies.mmd' || inputs.dependency-graph-output }} | |
concurrency: | |
# Group workflow jobs so new commits cancels in-progress execution triggered by previous commits. | |
# Source: https://mail.python.org/archives/list/pypa-committers@python.org/thread/PCBCQMJF64JGRBOX7E2EE4YLKHT4DI55/ | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
autofix-typo: | |
name: Fix typos | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- uses: crate-ci/typos@v1.27.3 | |
with: | |
write_changes: true | |
- name: Remove local typos binary | |
run: rm ./typos | |
- uses: peter-evans/create-pull-request@v7.0.5 | |
with: | |
# We need custom PAT with workflows permissions to fix typos in .github/workflows/*.yaml` files. | |
token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }} | |
assignees: ${{ github.actor }} | |
commit-message: "[autofix] Typo" | |
title: "[autofix] Typo" | |
body: > | |
<details><summary><code>Workflow metadata</code></summary> | |
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{ | |
github.run_id }}) by `${{ github.job }}` job from [`docs.yaml`](${{ github.event.repository.html_url | |
}}/blob/${{ github.sha }}/.github/workflows/docs.yaml) workflow. | |
</details> | |
labels: "📚 documentation" | |
branch: autofix-typo | |
optimize-images: | |
name: Optimize images | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
# XXX Waiting for a recent release for image-actions so we'll get rid of some warning annotations like | |
# "Unexpected input(s) 'compressOnly'". See: https://github.com/calibreapp/image-actions/issues/128 | |
- uses: calibreapp/image-actions@1.1.0 | |
id: image_actions | |
with: | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
compressOnly: true | |
- uses: peter-evans/create-pull-request@v7.0.5 | |
with: | |
assignees: ${{ github.actor }} | |
commit-message: "[autofix] Optimize images" | |
title: "[autofix] Optimize images" | |
body: > | |
${{ steps.image_actions.outputs.markdown }} | |
<details><summary><code>Workflow metadata</code></summary> | |
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{ | |
github.run_id }}) by `${{ github.job }}` job from [`docs.yaml`](${{ github.event.repository.html_url | |
}}/blob/${{ github.sha }}/.github/workflows/docs.yaml) workflow. | |
</details> | |
labels: "📚 documentation" | |
branch: optimize-images | |
update-mailmap: | |
name: Update .mailmap | |
if: ${{ ! startsWith(github.event.repository.name, 'awesome-') }} | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
with: | |
# Fetch all history to extract all contributors. | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
cache-dependency-path: | | |
**/pyproject.toml | |
*requirements.txt | |
requirements/*.txt | |
- name: Install uv | |
run: | | |
python -m pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/uv.txt | |
- name: Install gha-utils | |
run: > | |
uv tool install --with-requirements | |
https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/gha-utils.txt gha-utils | |
- name: Generate .mailmap | |
run: | | |
gha-utils --verbosity DEBUG mailmap-sync --skip-if-missing ./.mailmap | |
- uses: peter-evans/create-pull-request@v7.0.5 | |
with: | |
assignees: ${{ github.actor }} | |
commit-message: "[autofix] Update .mailmap" | |
title: "[autofix] Update `.mailmap`" | |
body: > | |
<details><summary><code>Workflow metadata</code></summary> | |
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{ | |
github.run_id }}) by `${{ github.job }}` job from [`docs.yaml`](${{ github.event.repository.html_url | |
}}/blob/${{ github.sha }}/.github/workflows/docs.yaml) workflow. | |
</details> | |
labels: "📚 documentation" | |
branch: update-mailmap | |
project-metadata: | |
name: Project metadata | |
runs-on: ubuntu-24.04 | |
outputs: | |
is_python_project: ${{ steps.project-metadata.outputs.is_python_project }} | |
package_name: ${{ steps.project-metadata.outputs.package_name }} | |
is_sphinx: ${{ steps.project-metadata.outputs.is_sphinx }} | |
active_autodoc: ${{ steps.project-metadata.outputs.active_autodoc }} | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
with: | |
# Checkout pull request HEAD commit to ignore actions/checkout's merge commit. Fallback to push SHA. | |
ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
# We're going to browse all new commits. | |
fetch-depth: 0 | |
- name: Hack setup-python cache | |
id: setup_python_hack | |
# XXX Create an empty pyproject.toml if this file (or any *requirements.txt) can't be found in repository. | |
# This hack fix an issue with setup-python, which ends up with this error in non-Python repos: | |
# | |
# Run actions/setup-python@v5.3.0 | |
# with: | |
# python-version: 3.12 | |
# cache: pip | |
# cache-dependency-path: | | |
# **/pyproject.toml | |
# requirements/*.txt | |
# Installed versions | |
# Successfully set up CPython (3.12.1) | |
# Error: No file in /home/runner/work/awesome-iam/awesome-iam matched to | |
# [requirements/*.txt or **/pyproject.toml], make sure you have checked out the target repository | |
# | |
# This has been reported at: https://github.com/actions/setup-python/issues/807 | |
# In the future this might be addressed by: https://github.com/actions/setup-python/pull/762 | |
# or https://github.com/actions/setup-python/issues/751 | |
if: hashFiles('**/pyproject.toml', '*requirements.txt', 'requirements/*.txt') == '' | |
run: | | |
touch ./pyproject.toml | |
echo "tmp_deps_file=true" >> "$GITHUB_OUTPUT" | |
- uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
cache-dependency-path: | | |
**/pyproject.toml | |
*requirements.txt | |
requirements/*.txt | |
- name: Remove setup-python hack | |
if: steps.setup_python_hack.outputs.tmp_deps_file | |
run: | | |
rm ./pyproject.toml | |
- name: Install uv | |
run: | | |
python -m pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/uv.txt | |
- name: Install gha-utils | |
run: > | |
uv tool install --with-requirements | |
https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/gha-utils.txt gha-utils | |
- name: Project metadata | |
id: project-metadata | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: | | |
gha-utils --verbosity DEBUG metadata --overwrite "$GITHUB_OUTPUT" | |
update-deps-graph: | |
name: Update dependency graph | |
needs: | |
- project-metadata | |
if: fromJSON(needs.project-metadata.outputs.is_python_project) | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
cache-dependency-path: | | |
**/pyproject.toml | |
*requirements.txt | |
requirements/*.txt | |
- name: Install uv | |
run: | | |
python -m pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/uv.txt | |
- name: Install pipdeptree | |
run: | | |
uv --no-progress venv --system | |
uv --no-progress pip install \ | |
--requirement https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/pipdeptree.txt | |
- name: Install project | |
run: | | |
uv --no-progress pip install . | |
- name: Run uv for debug | |
# TODO: switch from pipdeptree to uv. | |
# See: https://github.com/astral-sh/uv/issues/4439#issuecomment-2183911185 | |
run: | | |
uv --no-progress pip tree | |
- name: Run pipdeptree for debug | |
run: > | |
uv --no-progress run --frozen -- pipdeptree ${{ needs.project-metadata.outputs.package_name | |
&& format('--packages {0}', needs.project-metadata.outputs.package_name)}} | |
- name: Create dir structure | |
run: | | |
mkdir -p "$(dirname "${{ env.dependency-graph-output }}")" | |
# TODO: generate a graph for each extra requirement sets (like main, dev, docs, tests, ...). | |
# See: https://github.com/tox-dev/pipdeptree/issues/107 | |
- name: Generate graph | |
run: > | |
uv --no-progress run --frozen -- pipdeptree ${{ needs.project-metadata.outputs.package_name | |
&& format('--packages {0}', needs.project-metadata.outputs.package_name)}} | |
--mermaid > ${{ env.dependency-graph-output }} | |
- uses: peter-evans/create-pull-request@v7.0.5 | |
with: | |
assignees: ${{ github.actor }} | |
commit-message: "[autofix] Regenerate dependency graph" | |
title: "[autofix] Regenerate dependency graph" | |
body: > | |
<details><summary><code>Workflow metadata</code></summary> | |
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{ | |
github.run_id }}) by `${{ github.job }}` job from [`docs.yaml`](${{ github.event.repository.html_url | |
}}/blob/${{ github.sha }}/.github/workflows/docs.yaml) workflow. | |
</details> | |
labels: "📚 documentation" | |
branch: update-deps-graph | |
update-autodoc: | |
name: Update autodoc | |
needs: | |
- project-metadata | |
if: > | |
fromJSON(needs.project-metadata.outputs.is_python_project) | |
&& fromJSON(needs.project-metadata.outputs.active_autodoc) | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
cache-dependency-path: | | |
**/pyproject.toml | |
*requirements.txt | |
requirements/*.txt | |
- name: Install uv | |
run: | | |
python -m pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/uv.txt | |
- name: Install project dependencies | |
run: | | |
uv --no-progress venv | |
uv --no-progress pip install --extra docs --requirement ./pyproject.toml | |
- name: Run Sphinx | |
run: | | |
uv --no-progress run --frozen -- sphinx-apidoc --no-toc --module-first --force -o ./docs . | |
- uses: peter-evans/create-pull-request@v7.0.5 | |
with: | |
assignees: ${{ github.actor }} | |
commit-message: "[autofix] Update Sphinx autodoc" | |
title: "[autofix] Update Sphinx autodoc" | |
body: > | |
<details><summary><code>Workflow metadata</code></summary> | |
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{ | |
github.run_id }}) by `${{ github.job }}` job from [`docs.yaml`](${{ github.event.repository.html_url | |
}}/blob/${{ github.sha }}/.github/workflows/docs.yaml) workflow. | |
</details> | |
labels: "📚 documentation" | |
branch: update-autodoc | |
deploy-docs: | |
name: Deploy Sphinx doc | |
needs: | |
- project-metadata | |
if: fromJSON(needs.project-metadata.outputs.is_python_project) && fromJSON(needs.project-metadata.outputs.is_sphinx) | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
cache-dependency-path: | | |
**/pyproject.toml | |
*requirements.txt | |
requirements/*.txt | |
- name: Install uv | |
run: | | |
python -m pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/uv.txt | |
- name: Install project dependencies | |
run: | | |
uv --no-progress venv | |
uv --no-progress sync --all-extras | |
- name: Install Graphviz | |
# So we can use the sphinx.ext.graphviz plugin. | |
# See: https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html | |
run: | | |
sudo apt update | |
sudo apt install --yes graphviz | |
- name: Build documentation | |
run: | | |
uv --no-progress run --frozen -- sphinx-build -b html ./docs ./docs/html | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v4.0.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./docs/html | |
force_orphan: true | |
awesome-template-sync: | |
name: Sync awesome template | |
if: > | |
startsWith(github.event.repository.name, 'awesome-') | |
&& github.event.repository.name != 'awesome-template' | |
runs-on: ubuntu-24.04 | |
# We need custom PAT through the whole job so we get workflow permissions to update all the boilerplate .github | |
# files from awesome-template. | |
steps: | |
- name: Initial checkout | |
uses: actions/checkout@v4.2.2 | |
with: | |
token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Sync from template repo | |
id: template_sync | |
uses: AndreasAugustin/actions-template-sync@v2.4.1 | |
with: | |
github_token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }} | |
source_repo_path: kdeldycke/awesome-template | |
# Action will update PR only if there is file changes. is_force_push_pr also force the PR to be updated | |
# only if metadata changes. | |
is_force_push_pr: true | |
is_allow_hooks: true | |
is_pr_cleanup: true | |
# Replace "/kdeldycke/awesome-template/" in URLs by "/kdeldycke/awesome-<repo_id>/". | |
hooks: > | |
precommit: | |
commands: | |
- find ./.github/ -type f -iregex ".*\.\(md\|yaml\)$" -print -exec sed -i | |
"s/\/kdeldycke\/awesome-template\//\/kdeldycke\/${{ github.event.repository.name }}\//g" "{}" \; | |
pr_title: "[sync] Updates from `awesome-template`" | |
pr_commit_msg: "[sync] Updates from awesome-template" | |
pr_branch_name_prefix: "sync-awesome-template" | |
pr_body: > | |
Files synced from [`${SOURCE_REPO_PATH}@${TEMPLATE_GIT_HASH}` | |
repository](${SOURCE_REPO}/tree/${TEMPLATE_GIT_HASH}). | |
<details><summary><code>Workflow metadata</code></summary> | |
> [Auto-generated on run `#${{ github.run_id }}`](${{ github.event.repository.html_url }}/actions/runs/${{ | |
github.run_id }}) by `${{ github.job }}` job from [`docs.yaml`](${{ github.event.repository.html_url | |
}}/blob/${{ github.sha }}/.github/workflows/docs.yaml) workflow. | |
</details> | |
pr_labels: "📚 documentation" |