Repository navigation
71 lines (68 loc) · 2.3 KB
/
Copy pathlint-python-ruff.yml
File metadata and controls
71 lines (68 loc) · 2.3 KB
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
name: Lint Python with Ruff
on:
workflow_call:
inputs:
python-version:
description: Exact Python version.
required: false
type: string
default: 3.12.8
ruff-version:
description: Exact Ruff version.
required: false
type: string
default: 0.11.13
working-directory:
description: Repository-relative directory containing the Python project.
required: false
type: string
default: .
permissions:
contents: read
jobs:
lint:
name: Ruff
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Check out caller repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Validate working directory
id: target
uses: DevOpsDerek/workflows/.github/actions/validate-repository-directory@7f6c8dbd3156bd67db0d05ee2ab501028b16792f
with:
path: ${{ inputs.working-directory }}
name: working-directory
- name: Validate exact versions
shell: bash
env:
PYTHON_VERSION: ${{ inputs.python-version }}
RUFF_VERSION: ${{ inputs.ruff-version }}
run: |
set -euo pipefail
[[ "$PYTHON_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
echo "::error::python-version must be an exact three-part version."
exit 1
}
[[ "$RUFF_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
echo "::error::ruff-version must be an exact three-part version."
exit 1
}
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
with:
python-version: ${{ inputs.python-version }}
check-latest: false
- name: Install pinned Ruff
shell: bash
env:
RUFF_VERSION: ${{ inputs.ruff-version }}
run: python -m pip install --disable-pip-version-check --no-input "ruff==$RUFF_VERSION"
- name: Check Python sources without fixing
working-directory: ${{ steps.target.outputs.absolute-path }}
run: ruff check --no-fix .
- name: Check Python formatting without fixing
working-directory: ${{ steps.target.outputs.absolute-path }}
run: ruff format --check .