Skip to content

Commit fa1ef10

Browse files
committed
git-review-rebase: align on python-project-template (github workflows, uv support).
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@vates.tech>
1 parent 2f1b0ec commit fa1ef10

9 files changed

Lines changed: 237 additions & 1 deletion

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Setup UV and Sync
2+
description: 'Install uv and sync the dependencies'
3+
inputs:
4+
sync:
5+
description: 'Whether to run `uv sync` after setting up.'
6+
required: false
7+
default: 'true'
8+
type: boolean
9+
dev:
10+
description: 'Whether to use `--no-dev` with `uv sync`.'
11+
required: false
12+
default: 'true'
13+
type: boolean
14+
activate-environment:
15+
description: 'Wether to activate the virtual env or not'
16+
required: false
17+
default: true
18+
type: boolean
19+
working-directory:
20+
description: 'Use working-directory to run uv commands'
21+
required: false
22+
default: './'
23+
type: string
24+
runs:
25+
using: 'composite'
26+
steps:
27+
- uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
28+
with:
29+
version: "0.7.x"
30+
activate-environment: ${{ inputs.activate-environment }}
31+
working-directory: ${{ inputs.working-directory }}
32+
- if: inputs.sync == 'true' && inputs.dev == 'false'
33+
run: uv sync --frozen --no-dev
34+
shell: bash
35+
env:
36+
FORCE_COLOR: "1"
37+
working-directory: ${{ inputs.working-directory }}
38+
- if: inputs.sync == 'true' && inputs.dev == 'true'
39+
run: uv sync --frozen
40+
shell: bash
41+
env:
42+
FORCE_COLOR: "1"
43+
working-directory: ${{ inputs.working-directory }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Static code checkers
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
paths:
8+
- 'scripts/git-review-rebase/**'
9+
pull_request:
10+
paths:
11+
- 'scripts/git-review-rebase/**'
12+
13+
permissions: {}
14+
15+
jobs:
16+
git-review-rebase-code-check:
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: ./scripts/git-review-rebase/
21+
env:
22+
FORCE_COLOR: 1
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
- uses: ./.github/actions/uv-setup/
28+
with:
29+
working-directory: ./scripts/git-review-rebase/
30+
- run: mypy --install-types --non-interactive .
31+
- run: pyright
32+
- run: ruff check
33+
- run: flake8

‎.github/workflows/release.yml‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Create a release from tag
2+
3+
permissions: {}
4+
5+
on:
6+
push:
7+
tags:
8+
- '*'
9+
paths:
10+
- 'scripts/git-review-rebase/**'
11+
12+
jobs:
13+
build-git-review-rebase:
14+
name: Build and store python artifacts
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: ./scripts/git-review-rebase/
19+
permissions:
20+
contents: read
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
persist-credentials: false
26+
27+
- uses: ./.github/actions/uv-setup/
28+
with:
29+
working-directory: ./scripts/git-review-rebase/
30+
31+
- name: Build
32+
run: uv build
33+
34+
- name: Store python distribution artifacts
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: artifacts
38+
path: ./scripts/git-review-rebase/dist/
39+
40+
release-git-review-rebase:
41+
permissions:
42+
contents: write # allow creating a release
43+
44+
name: "Create and package a release"
45+
runs-on: ubuntu-latest
46+
needs: [build-git-review-rebase]
47+
steps:
48+
- name: Retrieve distribution artifacts
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: artifacts
52+
path: ./scripts/git-review-rebase/dist/
53+
54+
- name: Create release ${{ github.ref_name }}
55+
shell: bash
56+
run: |
57+
gh release create ${GITHUB_REF_NAME} --repo ${{ github.repository }} --generate-notes ./scripts/git-review-rebase/dist/*
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check requirements file consistency
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
paths:
8+
- 'scripts/git-review-rebase/**'
9+
pull_request:
10+
paths:
11+
- 'scripts/git-review-rebase/**'
12+
13+
permissions: {}
14+
15+
jobs:
16+
requirements-check:
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: ./scripts/git-review-rebase/
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
25+
- uses: ./.github/actions/uv-setup/
26+
with:
27+
dev: false
28+
working-directory: ./scripts/git-review-rebase/
29+
- run: ./requirements/update_requirements.py
30+
- run: git diff --exit-code

‎.github/workflows/zizmor.yml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: GitHub Actions Security Analysis with zizmor 🌈
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
paths:
8+
- 'scripts/git-review-rebase/**'
9+
pull_request:
10+
paths:
11+
- 'scripts/git-review-rebase/**'
12+
13+
permissions: {}
14+
15+
jobs:
16+
zizmor:
17+
name: zizmor latest
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
- uses: ./.github/actions/uv-setup/
24+
with:
25+
sync: false
26+
working-directory: ./scripts/git-review-rebase/
27+
- run: uvx zizmor --color=always .
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎scripts/git-review-rebase/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
"pygments>=2.19.2",
3232
]
3333

34-
[project.optional-dependencies]
34+
[dependency-groups]
3535
dev = [
3636
"pytest>=9.0.2",
3737
"pytest-asyncio>=1.3.0",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# generated with update_requirements.py, do not edit manually
2+
pygit2>=1.13.0
3+
textual>=7.5.0
4+
rich>=14.3.2
5+
pygments>=2.19.2
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# generated with update_requirements.py, do not edit manually
2+
pytest>=9.0.2
3+
pytest-asyncio>=1.3.0
4+
black>=24.10.0
5+
ruff>=0.1.0
6+
flake8>=7.3.0
7+
mypy>=1.19.1
8+
types-Pygments>=2.19.0
9+
-r base.txt
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import tomllib
5+
from pathlib import Path
6+
7+
parser = argparse.ArgumentParser(description="Convert the dependencies from pyproject.toml in requirements.txt files")
8+
args = parser.parse_args()
9+
10+
PROJECT_DIR = Path(__file__).parent.parent
11+
HEADER = "# generated with update_requirements.py, do not edit manually"
12+
13+
with open(f'{PROJECT_DIR}/pyproject.toml', 'rb') as f:
14+
pyproject = tomllib.load(f)
15+
16+
17+
main_deps = pyproject['project']['dependencies']
18+
with open(f'{PROJECT_DIR}/requirements/base.txt', 'w') as f:
19+
print(HEADER, file=f)
20+
for dep in main_deps:
21+
print(dep, file=f)
22+
23+
dev_deps = pyproject['dependency-groups']['dev']
24+
with open(f'{PROJECT_DIR}/requirements/dev.txt', 'w') as f:
25+
print(HEADER, file=f)
26+
for dep in dev_deps:
27+
print(dep, file=f)
28+
print('-r base.txt', file=f)

0 commit comments

Comments
 (0)