👷 Add pre-commit workflow (#1453)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sebastián Ramírez · committed by GitHub · parent 5a5ffc8 · Browse files · 3 files·+258 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+258 added−1 removed
- other:+258 added−1 removed
Provenance
- Commit
551547c- Tree
e0d1b55- Author
Sebastián Ramírez <tiangolo@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
5a5ffc8
3 files changed+258 added−1 removed
added:.github/workflows/pre-commit.yml+92 added
1+name: pre-commit2+3+on:4+ pull_request:5+ types:6+ - opened7+ - synchronize8+9+env:10+ IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}11+12+jobs:13+ pre-commit:14+ runs-on: ubuntu-latest15+ steps:16+ - name: Dump GitHub context17+ env:18+ GITHUB_CONTEXT: ${{ toJson(github) }}19+ run: echo "$GITHUB_CONTEXT"20+ - uses: actions/checkout@v521+ name: Checkout PR for own repo22+ if: env.IS_FORK == 'false'23+ with:24+ # To be able to commit it needs to fetch the head of the branch, not the25+ # merge commit26+ ref: ${{ github.head_ref }}27+ # And it needs the full history to be able to compute diffs28+ fetch-depth: 029+ # A token other than the default GITHUB_TOKEN is needed to be able to trigger CI30+ token: ${{ secrets.PRE_COMMIT }}31+ # pre-commit lite ci needs the default checkout configs to work32+ - uses: actions/checkout@v533+ name: Checkout PR for fork34+ if: env.IS_FORK == 'true'35+ with:36+ # To be able to commit it needs the head branch of the PR, the remote one37+ ref: ${{ github.event.pull_request.head.sha }}38+ fetch-depth: 039+ - name: Set up Python40+ uses: actions/setup-python@v641+ with:42+ python-version: "3.14"43+ - name: Setup uv44+ uses: astral-sh/setup-uv@v745+ with:46+ cache-dependency-glob: |47+ requirements**.txt48+ pyproject.toml49+ uv.lock50+ - name: Install Dependencies51+ run: |52+ uv venv53+ uv pip install -r requirements.txt54+ - name: Run prek - pre-commit55+ id: precommit56+ run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure57+ continue-on-error: true58+ - name: Commit and push changes59+ if: env.IS_FORK == 'false'60+ run: |61+ git config user.name "github-actions[bot]"62+ git config user.email "github-actions[bot]@users.noreply.github.com"63+ git add -A64+ if git diff --staged --quiet; then65+ echo "No changes to commit"66+ else67+ git commit -m "🎨 Auto format"68+ git push69+ fi70+ - uses: pre-commit-ci/lite-action@v1.1.071+ if: env.IS_FORK == 'true'72+ with:73+ msg: 🎨 Auto format74+ - name: Error out on pre-commit errors75+ if: steps.precommit.outcome == 'failure'76+ run: exit 177+78+ # https://github.com/marketplace/actions/alls-green#why79+ pre-commit-alls-green: # This job does nothing and is only used for the branch protection80+ if: always()81+ needs:82+ - pre-commit83+ runs-on: ubuntu-latest84+ steps:85+ - name: Dump GitHub context86+ env:87+ GITHUB_CONTEXT: ${{ toJson(github) }}88+ run: echo "$GITHUB_CONTEXT"89+ - name: Decide whether the needed jobs succeeded or failed90+ uses: re-actors/alls-green@release/v191+ with:92+ jobs: ${{ toJSON(needs) }}modified:requirements.txt+1 added-1 removed
1 unmodified line2 3 -r requirements-tests.txt4 -r requirements-docs.txt5 6-pre-commit >=2.17.0,<5.0.06+prek==0.2.22added:uv.lock+165 added
1+version = 12+revision = 33+requires-python = ">=3.8"4+resolution-markers = [5+ "python_full_version >= '3.10'",6+ "python_full_version == '3.9.*'",7+ "python_full_version < '3.9'",8+]9+10+[[package]]11+name = "click"12+version = "8.1.8"13+source = { registry = "https://pypi.org/simple" }14+resolution-markers = [15+ "python_full_version == '3.9.*'",16+ "python_full_version < '3.9'",17+]18+dependencies = [19+ { name = "colorama", marker = "python_full_version < '3.10' and sys_platform == 'win32'" },20+]21+sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593, upload-time = "2024-12-21T18:38:44.339Z" }22+wheels = [23+ { url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188, upload-time = "2024-12-21T18:38:41.666Z" },24+]25+26+[[package]]27+name = "click"28+version = "8.3.1"29+source = { registry = "https://pypi.org/simple" }30+resolution-markers = [31+ "python_full_version >= '3.10'",32+]33+dependencies = [34+ { name = "colorama", marker = "python_full_version >= '3.10' and sys_platform == 'win32'" },35+]36+sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" }37+wheels = [38+ { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" },39+]40+41+[[package]]42+name = "colorama"43+version = "0.4.6"44+source = { registry = "https://pypi.org/simple" }45+sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" }46+wheels = [47+ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },48+]49+50+[[package]]51+name = "markdown-it-py"52+version = "3.0.0"53+source = { registry = "https://pypi.org/simple" }54+resolution-markers = [55+ "python_full_version == '3.9.*'",56+ "python_full_version < '3.9'",57+]58+dependencies = [59+ { name = "mdurl", marker = "python_full_version < '3.10'" },60+]61+sdist = { url = "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size = 74596, upload-time = "2023-06-03T06:41:14.443Z" }62+wheels = [63+ { url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528, upload-time = "2023-06-03T06:41:11.019Z" },64+]65+66+[[package]]67+name = "markdown-it-py"68+version = "4.0.0"69+source = { registry = "https://pypi.org/simple" }70+resolution-markers = [71+ "python_full_version >= '3.10'",72+]73+dependencies = [74+ { name = "mdurl", marker = "python_full_version >= '3.10'" },75+]76+sdist = { url = "https://files.pythonhosted.org/packages/5b/f5/4ec618ed16cc4f8fb3b701563655a69816155e79e24a17b651541804721d/markdown_it_py-4.0.0.tar.gz", hash = "sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3", size = 73070, upload-time = "2025-08-11T12:57:52.854Z" }77+wheels = [78+ { url = "https://files.pythonhosted.org/packages/94/54/e7d793b573f298e1c9013b8c4dade17d481164aa517d1d7148619c2cedbf/markdown_it_py-4.0.0-py3-none-any.whl", hash = "sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147", size = 87321, upload-time = "2025-08-11T12:57:51.923Z" },79+]80+81+[[package]]82+name = "mdurl"83+version = "0.1.2"84+source = { registry = "https://pypi.org/simple" }85+sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" }86+wheels = [87+ { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" },88+]89+90+[[package]]91+name = "pygments"92+version = "2.19.2"93+source = { registry = "https://pypi.org/simple" }94+sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" }95+wheels = [96+ { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" },97+]98+99+[[package]]100+name = "rich"101+version = "14.2.0"102+source = { registry = "https://pypi.org/simple" }103+dependencies = [104+ { name = "markdown-it-py", version = "3.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },105+ { name = "markdown-it-py", version = "4.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" },106+ { name = "pygments" },107+]108+sdist = { url = "https://files.pythonhosted.org/packages/fb/d2/8920e102050a0de7bfabeb4c4614a49248cf8d5d7a8d01885fbb24dc767a/rich-14.2.0.tar.gz", hash = "sha256:73ff50c7c0c1c77c8243079283f4edb376f0f6442433aecb8ce7e6d0b92d1fe4", size = 219990, upload-time = "2025-10-09T14:16:53.064Z" }109+wheels = [110+ { url = "https://files.pythonhosted.org/packages/25/7a/b0178788f8dc6cafce37a212c99565fa1fe7872c70c6c9c1e1a372d9d88f/rich-14.2.0-py3-none-any.whl", hash = "sha256:76bc51fe2e57d2b1be1f96c524b890b816e334ab4c1e45888799bfaab0021edd", size = 243393, upload-time = "2025-10-09T14:16:51.245Z" },111+]112+113+[[package]]114+name = "shellingham"115+version = "1.5.4"116+source = { registry = "https://pypi.org/simple" }117+sdist = { url = "https://files.pythonhosted.org/packages/58/15/8b3609fd3830ef7b27b655beb4b4e9c62313a4e8da8c676e142cc210d58e/shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de", size = 10310, upload-time = "2023-10-24T04:13:40.426Z" }118+wheels = [119+ { url = "https://files.pythonhosted.org/packages/e0/f9/0595336914c5619e5f28a1fb793285925a8cd4b432c9da0a987836c7f822/shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686", size = 9755, upload-time = "2023-10-24T04:13:38.866Z" },120+]121+122+[[package]]123+name = "typer"124+source = { editable = "." }125+dependencies = [126+ { name = "click", version = "8.1.8", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },127+ { name = "click", version = "8.3.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" },128+ { name = "rich" },129+ { name = "shellingham" },130+ { name = "typing-extensions", version = "4.13.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.9'" },131+ { name = "typing-extensions", version = "4.15.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.9'" },132+]133+134+[package.metadata]135+requires-dist = [136+ { name = "click", specifier = ">=8.0.0" },137+ { name = "rich", specifier = ">=10.11.0" },138+ { name = "shellingham", specifier = ">=1.3.0" },139+ { name = "typing-extensions", specifier = ">=3.7.4.3" },140+]141+142+[[package]]143+name = "typing-extensions"144+version = "4.13.2"145+source = { registry = "https://pypi.org/simple" }146+resolution-markers = [147+ "python_full_version < '3.9'",148+]149+sdist = { url = "https://files.pythonhosted.org/packages/f6/37/23083fcd6e35492953e8d2aaaa68b860eb422b34627b13f2ce3eb6106061/typing_extensions-4.13.2.tar.gz", hash = "sha256:e6c81219bd689f51865d9e372991c540bda33a0379d5573cddb9a3a23f7caaef", size = 106967, upload-time = "2025-04-10T14:19:05.416Z" }150+wheels = [151+ { url = "https://files.pythonhosted.org/packages/8b/54/b1ae86c0973cc6f0210b53d508ca3641fb6d0c56823f288d108bc7ab3cc8/typing_extensions-4.13.2-py3-none-any.whl", hash = "sha256:a439e7c04b49fec3e5d3e2beaa21755cadbbdc391694e28ccdd36ca4a1408f8c", size = 45806, upload-time = "2025-04-10T14:19:03.967Z" },152+]153+154+[[package]]155+name = "typing-extensions"156+version = "4.15.0"157+source = { registry = "https://pypi.org/simple" }158+resolution-markers = [159+ "python_full_version >= '3.10'",160+ "python_full_version == '3.9.*'",161+]162+sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" }163+wheels = [164+ { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },165+]