Skip to content

Commit 093cf75

Browse files
committed
Import project configuration from python-project-template
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent e9cafe6 commit 093cf75

File tree

13 files changed

+547
-47
lines changed

13 files changed

+547
-47
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
runs:
20+
using: 'composite'
21+
steps:
22+
- uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
23+
with:
24+
version: "0.7.x"
25+
activate-environment: ${{ inputs.activate-environment }}
26+
- if: inputs.sync == 'true' && inputs.dev == 'false'
27+
run: uv sync --frozen --no-dev
28+
shell: bash
29+
env:
30+
FORCE_COLOR: "1"
31+
- if: inputs.sync == 'true' && inputs.dev == 'true'
32+
run: uv sync --frozen
33+
shell: bash
34+
env:
35+
FORCE_COLOR: "1"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Static code checkers
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
9+
permissions: {}
10+
11+
jobs:
12+
mypy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
persist-credentials: false
18+
- uses: ./.github/actions/uv-setup/
19+
- run: mypy --install-types --non-interactive .
20+
21+
pyright:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
- uses: ./.github/actions/uv-setup/
28+
- run: pyright
29+
30+
ruff:
31+
runs-on: ubuntu-latest
32+
env:
33+
FORCE_COLOR: "1"
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
persist-credentials: false
38+
- uses: ./.github/actions/uv-setup/
39+
- run: ruff check
40+
41+
flake8:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
persist-credentials: false
47+
- uses: ./.github/actions/uv-setup/
48+
- run: flake8

.github/workflows/format.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/release.yml

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

.github/workflows/zizmor.yml

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

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11.11

pyproject.toml

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
name = "xcp-ng-dev"
33
description = "A tool to develop and build XCP-ng packages"
44
readme = "README.md"
5-
requires-python = ">=3.11"
5+
requires-python = ">=3.11, <4"
66
license = "MIT"
77
license-files = ["LICENSE"]
88
dynamic = ["version"]
99
dependencies = [
10-
"argcomplete",
10+
"argcomplete",
11+
]
12+
13+
[dependency-groups]
14+
dev = [
15+
"icecream",
16+
"mypy",
17+
"flake8",
18+
"pyright",
19+
"ruff",
20+
"typing-extensions",
21+
"flake8-pyproject",
1122
]
1223

1324
[project.scripts]
@@ -22,3 +33,77 @@ requires = ["setuptools >= 77.0.3", "setuptools-scm>=8"]
2233
build-backend = "setuptools.build_meta"
2334

2435
[tool.setuptools_scm]
36+
37+
[tool.pyright]
38+
typeCheckingMode = "standard"
39+
40+
[tool.ruff]
41+
preview = true
42+
line-length = 120
43+
exclude = [".git"]
44+
45+
[tool.ruff.format]
46+
quote-style = "preserve"
47+
48+
[tool.ruff.lint]
49+
select = [
50+
"D", # pydocstyle
51+
"F", # Pyflakes
52+
"I", # isort
53+
"SLF", # flake8-self
54+
"SIM", # flake8-simplify
55+
]
56+
# don't use some of the default D and SIM rules
57+
ignore = [
58+
"D100", # undocumented-public-module
59+
"D101", # undocumented-public-class
60+
"D102", # undocumented-public-method
61+
"D103", # undocumented-public-function
62+
"D104", # undocumented-public-package
63+
"D105", # undocumented-magic-method
64+
"D106", # undocumented-public-nested-class
65+
"D107", # undocumented-public-init
66+
"D200", # unnecessary-multiline-docstring
67+
"D203", # incorrect-blank-line-before-class
68+
"D204", # incorrect-blank-line-after-class
69+
"D205", # missing-blank-line-after-summary
70+
"D210", # surrounding-whitespace
71+
"D212", # incorrect-blank-line-before-class
72+
"D400", # missing-trailing-period
73+
"D401", # non-imperative-mood
74+
"D403", # first-word-uncapitalized
75+
"SIM105", # suppressible-exception
76+
"SIM108", # if-else-block-instead-of-if-exp
77+
]
78+
79+
# restrict to the PEP 257 rules
80+
pydocstyle.convention = "pep257"
81+
82+
[tool.ruff.lint.isort.sections]
83+
testing = ["pytest*"]
84+
typing = ["typing"]
85+
86+
[tool.ruff.lint.isort]
87+
lines-after-imports = 1
88+
section-order = [
89+
"future",
90+
"testing",
91+
"standard-library",
92+
"third-party",
93+
"first-party",
94+
"local-folder",
95+
"typing",
96+
]
97+
98+
# ruff doesn't provide all the pycodestyle rules, and pycodestyle is not well
99+
# supported by some IDEs, so we use flake8 for that
100+
[tool.flake8]
101+
max-line-length = 120
102+
ignore = [
103+
"E261", # At least two spaces before inline comment
104+
"E302", # Expected 2 blank lines, found 0
105+
"E305", # Expected 2 blank lines after end of function or class
106+
"W503", # Line break occurred before a binary operator
107+
"F", # already done by ruff
108+
]
109+
exclude=[".git", ".venv"]

requirements/base.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# generated with update_requirements.py, do not edit manually
2+
argcomplete

requirements/dev.txt

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+
icecream
3+
mypy
4+
flake8
5+
pyright
6+
ruff
7+
typing-extensions
8+
flake8-pyproject
9+
-r base.txt

0 commit comments

Comments
 (0)