Skip to content

Commit afed1d1

Browse files
authored
Merge pull request #18 from alex-feel/alex-feel-dev
Move to Python scripts
2 parents bc33b1e + 51a92a1 commit afed1d1

File tree

11 files changed

+1594
-2440
lines changed

11 files changed

+1594
-2440
lines changed

.github/workflows/lint.yml

Lines changed: 61 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -9,134 +9,76 @@ permissions:
99
security-events: write
1010

1111
jobs:
12-
powershell:
13-
name: PowerShell Script Analysis
14-
runs-on: windows-latest
15-
16-
steps:
17-
- name: Skip for Release Please
18-
if: ${{ startsWith(github.head_ref, 'release-please--branches--') }}
19-
run: echo "Skipping PowerShell analysis for Release Please PR"
20-
21-
- uses: actions/checkout@v5
22-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
23-
24-
- name: Run PSScriptAnalyzer
25-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
26-
uses: microsoft/psscriptanalyzer-action@v1.1
27-
with:
28-
path: ./scripts/windows
29-
recurse: true
30-
output: results.sarif
31-
ignorePattern: '\.git|\.github'
32-
33-
- name: Upload PSScriptAnalyzer results
34-
uses: github/codeql-action/upload-sarif@v3
35-
if: ${{ always() && ! startsWith(github.head_ref, 'release-please--branches--') }}
36-
with:
37-
sarif_file: results.sarif
38-
39-
shellcheck:
40-
name: Shell Script Analysis
12+
pre-commit:
13+
name: Run Pre-Commit Checks
14+
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
4115
runs-on: ubuntu-latest
4216

4317
steps:
44-
- name: Skip for Release Please
45-
if: ${{ startsWith(github.head_ref, 'release-please--branches--') }}
46-
run: echo "Skipping Shell Script analysis for Release Please PR"
47-
48-
- uses: actions/checkout@v5
49-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
50-
51-
- name: Run ShellCheck
52-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
53-
uses: ludeeus/action-shellcheck@master
54-
with:
55-
scandir: './scripts'
56-
ignore_paths: 'scripts/windows'
57-
severity: warning
58-
59-
markdown:
60-
name: Markdown Lint
61-
runs-on: ubuntu-latest
18+
- name: Checkout code
19+
uses: actions/checkout@v5
6220

63-
steps:
64-
- name: Skip for Release Please
65-
if: ${{ startsWith(github.head_ref, 'release-please--branches--') }}
66-
run: echo "Skipping Markdown lint for Release Please PR"
67-
68-
- uses: actions/checkout@v5
69-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
70-
71-
- name: Run markdownlint
72-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
73-
uses: DavidAnson/markdownlint-cli2-action@v20
74-
with:
75-
globs: |
76-
**/*.md
77-
!node_modules/**
78-
!CHANGELOG.md
79-
80-
json-yaml:
81-
name: JSON/YAML Validation
82-
runs-on: ubuntu-latest
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.12'
25+
26+
- name: Install pre-commit
27+
run: pip install pre-commit
28+
29+
- name: Set up Node.js for markdownlint
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
34+
- name: Install markdownlint-cli2
35+
run: npm install -g markdownlint-cli2
36+
37+
- name: Run pre-commit hooks (except PSScriptAnalyzer)
38+
run: |
39+
# Skip PSScriptAnalyzer as it requires Windows
40+
SKIP=psscriptanalyzer pre-commit run --all-files --show-diff-on-failure
41+
42+
powershell:
43+
name: PowerShell Script Analysis
44+
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
45+
runs-on: windows-latest
8346

8447
steps:
85-
- name: Skip for Release Please
86-
if: ${{ startsWith(github.head_ref, 'release-please--branches--') }}
87-
run: echo "Skipping JSON/YAML validation for Release Please PR"
88-
89-
- uses: actions/checkout@v5
90-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
91-
92-
- name: Validate JSON files
93-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
94-
run: |
95-
find . -name "*.json" -type f -not -path "./node_modules/*" | while read file; do
96-
echo "Validating $file"
97-
python -m json.tool "$file" > /dev/null || exit 1
98-
done
99-
echo "All JSON files are valid"
100-
101-
- name: Setup Python
102-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
103-
uses: actions/setup-python@v5
104-
with:
105-
python-version: '3.x'
106-
107-
- name: Validate YAML files
108-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
109-
run: |
110-
pip install pyyaml
111-
find . -name "*.yml" -o -name "*.yaml" -type f -not -path "./node_modules/*" | while read file; do
112-
echo "Validating $file"
113-
python -c "import yaml; yaml.safe_load(open('$file'))" || exit 1
114-
done
115-
echo "All YAML files are valid"
48+
- uses: actions/checkout@v5
49+
50+
- name: Run PSScriptAnalyzer
51+
uses: microsoft/psscriptanalyzer-action@v1.1
52+
with:
53+
path: ./scripts/windows
54+
recurse: true
55+
output: results.sarif
56+
ignorePattern: '\.git|\.github'
57+
58+
- name: Upload PSScriptAnalyzer results
59+
uses: github/codeql-action/upload-sarif@v3
60+
if: always()
61+
with:
62+
sarif_file: results.sarif
11663

11764
security:
11865
name: Security Scan
66+
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
11967
runs-on: ubuntu-latest
12068

12169
steps:
122-
- name: Skip for Release Please
123-
if: ${{ startsWith(github.head_ref, 'release-please--branches--') }}
124-
run: echo "Skipping Trivy security scan for Release Please PR"
125-
126-
- uses: actions/checkout@v5
127-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
128-
129-
- name: Run Trivy security scanner
130-
if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }}
131-
uses: aquasecurity/trivy-action@master
132-
with:
133-
scan-type: 'fs'
134-
scan-ref: '.'
135-
format: 'sarif'
136-
output: 'trivy-results.sarif'
137-
138-
- name: Upload Trivy results to GitHub Security
139-
uses: github/codeql-action/upload-sarif@v3
140-
if: ${{ always() && ! startsWith(github.head_ref, 'release-please--branches--') }}
141-
with:
142-
sarif_file: 'trivy-results.sarif'
70+
- uses: actions/checkout@v5
71+
72+
- name: Run Trivy security scanner
73+
uses: aquasecurity/trivy-action@master
74+
with:
75+
scan-type: 'fs'
76+
scan-ref: '.'
77+
format: 'sarif'
78+
output: 'trivy-results.sarif'
79+
80+
- name: Upload Trivy results to GitHub Security
81+
uses: github/codeql-action/upload-sarif@v3
82+
if: always()
83+
with:
84+
sarif_file: 'trivy-results.sarif'

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.12.7
4+
hooks:
5+
- id: ruff-check
6+
name: Ruff (lint + autofix)
7+
description: Fast Python linter (Flake8, isort, quotes, etc.) with --fix enabled
8+
args: [--fix]
9+
210
- repo: https://github.com/pre-commit/pre-commit-hooks
311
rev: v5.0.0
412
hooks:
13+
- id: check-json
14+
name: Check JSON
15+
description: Verify JSON syntax
16+
exclude: ^CHANGELOG\.md$
17+
18+
- id: check-yaml
19+
name: Check YAML
20+
description: Verify YAML syntax
21+
522
- id: end-of-file-fixer
623
name: End-of-file fixer (non-Python)
724
description: Ensures every *non-Python* file is empty or ends with a single newline
@@ -12,6 +29,10 @@ repos:
1229
description: Trims trailing whitespace in non-Python text files
1330
exclude: ^.*\.(pyi?|py)$
1431

32+
- id: check-shebang-scripts-are-executable
33+
name: Check shebang scripts
34+
description: Check that text files with a shebang are executable
35+
1536
- repo: local
1637
hooks:
1738
- id: markdownlint

ruff.toml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Enable preview features
2+
preview = true
3+
# General settings
4+
src = ["scripts", "app"]
5+
target-version = "py312"
6+
line-length = 127
7+
extend-include = ["scripts/**/*.py", "tests/**/*.py"]
8+
9+
[lint]
10+
# Enable rule groups
11+
select = [
12+
"FAST", # FastAPI
13+
"YTT", # flake8-2020
14+
"ANN", # flake8-annotations
15+
"ASYNC", # flake8-async
16+
"B", # flake8-bugbear
17+
"COM", # flake8-commas
18+
"C4", # flake8-comprehensions
19+
"DTZ", # flake8-datetimez
20+
"T10", # flake8-debugger
21+
"EXE", # flake8-executable
22+
"FIX", # flake8-fix-me
23+
"FA", # flake8-future-annotations
24+
"INT", # flake8-gettext
25+
"ISC", # flake8-implicit-str-concat
26+
"ICN", # flake8-import-conventions
27+
"LOG", # flake8-logging
28+
"PIE", # flake8-pie
29+
"PYI", # flake8-pyi
30+
"PT", # flake8-pytest-style
31+
"Q", # flake8-quotes
32+
"RSE", # flake8-raise
33+
"RET", # flake8-return
34+
"SIM", # flake8-simplify
35+
"SLOT", # flake8-slots
36+
"TID", # flake8-tidy-imports
37+
# "TC", # flake8-type-checking
38+
"ARG", # flake8-unused-arguments
39+
"FLY", # flynt
40+
"I", # isort
41+
"NPY", # NumPy-specific rules
42+
"PD", # pandas-vet
43+
"N", # pep8-naming
44+
"PERF", # Perflint
45+
"E", "W", # pycodestyle
46+
"DOC", # pydoclint
47+
"F", # Pyflakes
48+
"PGH", # pygrep-hooks
49+
"UP", # pyupgrade
50+
"FURB", # refurb
51+
]
52+
53+
[lint.flake8-annotations]
54+
allow-star-arg-any = true
55+
ignore-fully-untyped = true
56+
57+
[lint.flake8-bugbear]
58+
extend-immutable-calls = [
59+
"fastapi.Depends",
60+
"fastapi.params.Depends",
61+
"fastapi.Query",
62+
"fastapi.params.Query",
63+
"fastapi.params.Body",
64+
]
65+
66+
[lint.flake8-import-conventions.aliases]
67+
streamlit = "st"
68+
69+
[lint.flake8-quotes]
70+
docstring-quotes = "double"
71+
inline-quotes = "single"
72+
multiline-quotes = "single"
73+
74+
[lint.flake8-type-checking]
75+
quote-annotations = true
76+
strict = false
77+
78+
[lint.isort]
79+
known-first-party = ["app"]
80+
force-single-line = true
81+
82+
[lint.pydoclint]
83+
ignore-one-line-docstrings = true

0 commit comments

Comments
 (0)