-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (49 loc) · 1.52 KB
/
pre-commit.yml
File metadata and controls
59 lines (49 loc) · 1.52 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
name: Pre-commit Checks
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
pre-commit:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black ruff mypy types-pyyaml types-requests
- name: Black - Code Formatting
run: |
echo "::group::Black Formatting Check"
black --check --diff --fast stackbox/ tests/
echo "::endgroup::"
- name: Ruff - Linting
run: |
echo "::group::Ruff Linting"
ruff check stackbox/ tests/
echo "::endgroup::"
- name: Mypy - Type Checking
run: |
echo "::group::Mypy Type Checking"
mypy stackbox/
echo "::endgroup::"
- name: Comment on PR if checks fail
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '⚠️ **Code quality checks failed!**\n\nPlease run the following commands locally to fix:\n```bash\nblack stackbox/ tests/\nruff check --fix stackbox/ tests/\nmypy stackbox/core/compose.py\n```'
})