-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (85 loc) · 2.87 KB
/
python-lint.yml
File metadata and controls
95 lines (85 loc) · 2.87 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Python Lint
#
# Reusable workflow that runs lint jobs in parallel:
#
# 1. ruff — runs ruff check (lint) and/or ruff format --check
# both enabled by default, each can be disabled independently
# 2. docker-lint — runs hadolint against the Dockerfile
# skipped cleanly if no Dockerfile is found
#
# Usage in a consuming repository:
#
# jobs:
# lint:
# uses: orangitfi/platform-tooling/.github/workflows/python-lint.yml@<sha>
# with:
# working-directory: .
# dockerfile-path: Dockerfile
name: Python Lint
on:
workflow_call:
inputs:
working-directory:
description: "Directory containing pyproject.toml"
required: false
default: "."
type: string
run-ruff-lint:
description: "Run ruff check (linting)"
required: false
default: true
type: boolean
run-ruff-format:
description: "Run ruff format --check (formatting)"
required: false
default: true
type: boolean
dockerfile-path:
description: "Path to the Dockerfile relative to the repository root"
required: false
default: "Dockerfile"
type: string
permissions:
contents: read
jobs:
ruff:
name: Ruff Lint and Format
if: ${{ inputs.run-ruff-lint || inputs.run-ruff-format }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install uv
uses: orangitfi/platform-tooling/.github/actions/setup-uv@a4ca46b0de8eda2f61573cfbd4164e538a7775a1 # pt-sha
- name: Run ruff check
if: ${{ inputs.run-ruff-lint }}
shell: bash
working-directory: ${{ inputs.working-directory }}
run: uvx ruff check .
- name: Run ruff format check
if: ${{ inputs.run-ruff-format }}
shell: bash
working-directory: ${{ inputs.working-directory }}
run: uvx ruff format --check .
docker-lint:
name: Docker Lint (hadolint)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check for Dockerfile
id: check
shell: bash
run: |
if [ -f "${{ inputs.dockerfile-path }}" ]; then
echo "exists=true" >> "${GITHUB_OUTPUT}"
else
echo "exists=false" >> "${GITHUB_OUTPUT}"
echo "No Dockerfile found at '${{ inputs.dockerfile-path }}', skipping docker lint."
fi
- name: Lint Dockerfile
if: steps.check.outputs.exists == 'true'
uses: orangitfi/platform-tooling/.github/actions/docker-lint@a4ca46b0de8eda2f61573cfbd4164e538a7775a1 # pt-sha
with:
dockerfile: ${{ inputs.dockerfile-path }}
working-directory: ${{ inputs.working-directory }}