mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-02 21:03:34 +03:00
# Description of Changes This PR modernizes the project's Python tooling across GitHub Actions by migrating CI workflows from pip-based dependency management to `uv` and aligning Python execution with the engine project's managed environment. ### What was changed - Replaced `actions/setup-python` and ad-hoc `pip install` steps with `astral-sh/setup-uv` across CI workflows. - Configured shared `uv` dependency caching using `engine/pyproject.toml` and `engine/uv.lock`. - Updated Python script execution to use `uv run --project engine --locked` for a consistent runtime environment. - Replaced package installation steps with `uv sync` for the required dependency groups (e.g. `tools` and `cucumber`). - Added Docker image build validation for both production and development AI engine images. - Updated workflow cache configuration and Docker build context where required. - Removed obsolete Python requirements files that are no longer needed after the migration. - Applied minor Python code modernizations, including import cleanup, modern built-in generic type annotations (`list[...]`, `tuple[...]`, `float | None`), and small style improvements. - Removed unnecessary Python formatter/linter extensions from the development container configuration. ### Why the change was made - Standardize Python dependency management across the repository. - Reduce duplicated dependency installation logic in CI. - Improve workflow performance through shared dependency caching. - Ensure all Python utilities execute against the same locked dependency set managed by the engine project. - Simplify long-term maintenance by eliminating legacy requirements files and pip-specific workflow steps. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have run `task check` to verify linters, typechecks, and tests pass - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details. --------- Signed-off-by: Carsten Drewes <c.drewes@stud.uni-hannover.de> Co-authored-by: albanobattistella <34811668+albanobattistella@users.noreply.github.com> Co-authored-by: kastenherri <116314318+kastenherri@users.noreply.github.com> Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: James Brunton <jbrunton96@gmail.com>
138 lines
4.5 KiB
YAML
138 lines
4.5 KiB
YAML
version: '3'
|
|
|
|
# Repo-wide lint/format/secret checks - the single source of truth that the git
|
|
# pre-commit hook (.pre-commit-config.yaml) and CI (pre_commit.yml) both call.
|
|
|
|
vars:
|
|
# File selections as git pathspecs: git does the include/exclude matching, so
|
|
# there is no grep/xargs and it behaves identically on every platform.
|
|
PY_FILES: >-
|
|
'scripts/*.py'
|
|
'.github/scripts/*.py'
|
|
'app/core/src/main/resources/static/python/*.py'
|
|
':(exclude)*split_photos.py'
|
|
SPELL_FILES: >-
|
|
'*.html'
|
|
'*.css'
|
|
'*.js'
|
|
'*.py'
|
|
'*.md'
|
|
':(exclude).vscode/*'
|
|
':(exclude).devcontainer/*'
|
|
':(exclude)app/core/src/main/resources/*'
|
|
':(exclude)app/proprietary/src/main/resources/*'
|
|
':(exclude)frontend/editor/public/vendor/*'
|
|
':(exclude)*Dockerfile*'
|
|
':(exclude)*pdfjs*'
|
|
':(exclude)*thirdParty*'
|
|
':(exclude)*bootstrap*'
|
|
':(exclude)*.min.*'
|
|
':(exclude)*diff.js'
|
|
WS_FILES: >-
|
|
'*.js'
|
|
'*.java'
|
|
'*.py'
|
|
'*.yml'
|
|
':(exclude)*pdfjs*'
|
|
':(exclude)*thirdParty*'
|
|
':(exclude)*bootstrap*'
|
|
':(exclude)*.min.*'
|
|
':(exclude)*diff.js'
|
|
':(exclude).github/workflows/*'
|
|
LOCALE_TOML: 'frontend/editor/public/locales/*/translation.toml'
|
|
|
|
# gitleaks is pinned + checksum-verified by scripts/pre-commit/install_gitleaks.py,
|
|
# which owns the version and caches the binary here.
|
|
GITLEAKS_BIN: '.task/bin/gitleaks{{if eq OS "windows"}}.exe{{end}}'
|
|
|
|
env:
|
|
# Keep repository-wide checks isolated from the engine runtime environment.
|
|
UV_PROJECT_ENVIRONMENT: '.venv-pre-commit'
|
|
|
|
tasks:
|
|
default:
|
|
desc: "Check formatting, spelling, and secrets across the repo"
|
|
cmds:
|
|
- task: ruff
|
|
- task: ruff-format
|
|
- task: codespell
|
|
- task: gitleaks
|
|
- task: whitespace
|
|
- task: toml-sort
|
|
|
|
fix:
|
|
desc: "Auto-fix formatting, spelling, and secrets issues across the repo"
|
|
cmds:
|
|
# Auto-fixers first, then the report-only tools (codespell, gitleaks) so a
|
|
# finding there does not stop the fixers from running.
|
|
- task: ruff
|
|
vars: { FIX: '1' }
|
|
- task: ruff-format
|
|
vars: { FIX: '1' }
|
|
- task: whitespace
|
|
vars: { FIX: '1' }
|
|
- task: toml-sort
|
|
vars: { FIX: '1' }
|
|
- task: codespell
|
|
- task: gitleaks
|
|
|
|
install:
|
|
desc: "Install the pinned pre-commit Python tools"
|
|
run: once
|
|
cmds:
|
|
- uv sync --project engine --locked --group pre-commit
|
|
sources:
|
|
- engine/uv.lock
|
|
- engine/pyproject.toml
|
|
status:
|
|
- test -d engine/.venv-pre-commit
|
|
|
|
clean:
|
|
desc: "Remove the cached gitleaks binary and the pre-commit virtualenv"
|
|
cmds:
|
|
- cmd: rm -rf engine/.venv-pre-commit .task/bin/gitleaks
|
|
platforms: [linux, darwin]
|
|
- cmd: cmd /c "rmdir /s /q engine\.venv-pre-commit & del /q .task\bin\gitleaks.exe"
|
|
platforms: [windows]
|
|
ignore_error: true
|
|
|
|
# Individual checks (hidden from `task --list`, but callable, e.g.
|
|
# `task pre-commit:toml-sort FIX=1`). Pass FIX=1 to auto-fix where supported.
|
|
ruff:
|
|
deps: [install]
|
|
cmds:
|
|
- uv run --project engine --locked --group pre-commit ruff check --isolated --line-length=120 {{if .FIX}}--fix {{end}}$(git ls-files {{.PY_FILES}})
|
|
|
|
ruff-format:
|
|
deps: [install]
|
|
cmds:
|
|
- uv run --project engine --locked --group pre-commit ruff format --isolated --line-length=120 {{if .FIX}}{{else}}--check {{end}}$(git ls-files {{.PY_FILES}})
|
|
|
|
codespell:
|
|
deps: [install]
|
|
cmds:
|
|
- uv run --project engine --locked --group pre-commit codespell --ignore-words-list=thirdParty,tabEl,tabEls,Sie,ist,fulfilment --quiet-level=2 $(git ls-files {{.SPELL_FILES}})
|
|
|
|
toml-sort:
|
|
deps: [install]
|
|
cmds:
|
|
- uv run --project engine --locked --group pre-commit python scripts/pre-commit/sort_locale_toml.py {{if .FIX}}--fix {{end}}{{.LOCALE_TOML}}
|
|
|
|
whitespace:
|
|
cmds:
|
|
- uv run --project engine --locked --group pre-commit python scripts/pre-commit/whitespace.py {{if .FIX}}--fix {{end}}{{.WS_FILES}}
|
|
|
|
gitleaks:
|
|
deps: [gitleaks-bin]
|
|
# Scan staged changes only, matching the old hook: the git-mode fingerprints
|
|
# in .gitleaksignore (file:rule:line) still apply, and with nothing staged
|
|
# this is a no-op. Secrets are never auto-fixed, so FIX has no effect.
|
|
cmds:
|
|
- "{{.GITLEAKS_BIN}} git --pre-commit --redact --staged --verbose"
|
|
|
|
gitleaks-bin:
|
|
internal: true
|
|
desc: "Ensure the pinned, checksum-verified gitleaks binary is cached in .task/bin"
|
|
cmds:
|
|
- uv run --project engine --locked --group pre-commit python scripts/pre-commit/install_gitleaks.py
|