-
-
Notifications
You must be signed in to change notification settings - Fork 7
72 lines (67 loc) · 2.23 KB
/
pre-commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: CC0-1.0
# This file is maintained in https://github.com/WeblateOrg/meta/
name: Pre-commit check
on:
push:
branches-ignore:
- deepsource-fix-**
- renovate/**
- weblate
pull_request:
permissions:
contents: read
jobs:
pre-commit:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- uses: astral-sh/setup-uv@v5
- name: detect method
id: detect
run: |
if test -f requirements-lint.txt ; then
echo "method=requirements" >> $GITHUB_OUTPUT
elif test -f pyproject.toml && grep -q dependency-groups pyproject.toml ; then
echo "method=pep735" >> $GITHUB_OUTPUT
elif test -f pyproject.toml && grep -q dependency-groups pyproject.toml ; then
echo "method=pyproject" >> $GITHUB_OUTPUT
else
echo "method=uvx" >> $GITHUB_OUTPUT
fi
- name: pre-commit (PEP 735)
if: steps.detect.outputs.method == 'pep735'
run: uv run --no-sources --only-group pre-commit pre-commit run --all
env:
RUFF_OUTPUT_FORMAT: github
REUSE_OUTPUT_FORMAT: github
- name: pre-commit (uvx)
if: steps.detect.outputs.method == 'uvx'
run: uvx pre-commit run --all
env:
RUFF_OUTPUT_FORMAT: github
REUSE_OUTPUT_FORMAT: github
- name: Install dependencies
if: steps.detect.outputs.method == 'requirements'
run: uv pip install --system -r requirements-lint.txt
- name: Install dependencies
if: steps.detect.outputs.method == 'pyproject'
run: uv pip install --system $(sed -n 's/.*"\(pre-commit==\([^"]*\)\)".*/\1/p' pyproject.toml)
- name: pre-commit (installed)
if: steps.detect.outputs.method == 'requirements' || steps.detect.outputs.method == 'pyproject'
run: pre-commit run --all
env:
RUFF_OUTPUT_FORMAT: github
REUSE_OUTPUT_FORMAT: github
- name: diff
run: git diff
if: always()