@@ -2,171 +2,69 @@ name: Code Quality
22
33on :
44 push :
5- branches : [ main, dev/jmlr, feature/gpu_fix ]
5+ branches : [main]
66 pull_request :
7- branches : [ main, dev/jmlr, feature/gpu_fix ]
7+ branches : [main]
88
99jobs :
10- code-quality :
10+ lint :
1111 runs-on : ubuntu-latest
1212 steps :
13- - uses : actions/checkout@v4
14-
15- - name : Set up Python 3.9
16- uses : actions/setup-python@v4
17- with :
18- python-version : " 3.9"
19-
20- - name : Cache pip dependencies
21- uses : actions/cache@v3
22- with :
23- path : ~/.cache/pip
24- key : ${{ runner.os }}-pip-quality-${{ hashFiles('pyproject.toml') }}
25- restore-keys : |
26- ${{ runner.os }}-pip-quality-
27- ${{ runner.os }}-pip-
28-
29- - name : Install dependencies
30- run : |
31- python -m pip install --upgrade pip
32- pip install -e ".[dev, security, linting]"
33- # pip install ruff mypy bandit safety
34-
35- - name : Check code formatting with Black
36- run : |
37- black --check --diff torchsom/ tests/
38-
39- - name : Check import sorting with isort
40- run : |
41- isort --check-only --diff torchsom/ tests/
42-
43- - name : Lint with Ruff
44- run : |
45- ruff check torchsom/ tests/ --output-format=github
46-
47- - name : Type checking with MyPy
48- run : |
49- mypy torchsom/ --ignore-missing-imports --strict
50- # mypy torchsom/
51- continue-on-error : true
52-
53- - name : Check for security issues with Bandit (library code)
54- run : |
55- bandit -r torchsom/ -f json -o bandit-report-library.json --skip B101,B311,B601
56- continue-on-error : true
57-
58- - name : Check for security issues with Bandit (tests)
59- run : |
60- bandit -r tests/ -f json -o bandit-report-tests.json --skip B101,B311,B601
61- continue-on-error : true
62-
63- # - name: Check for known security vulnerabilities
64- # run: |
65- # safety check --json --output safety-report.json
66- # continue-on-error: true
67-
68- - name : Upload security reports
69- uses : actions/upload-artifact@v4
70- if : always()
71- with :
72- name : security-reports
73- path : |
74- bandit-report-library.json
75- bandit-report-tests.json
76- # safety-report.json
13+ - uses : actions/checkout@v4
14+
15+ - name : Install uv
16+ uses : astral-sh/setup-uv@v5
17+
18+ - name : Set up Python
19+ run : uv python install 3.12
20+
21+ - name : Sync dependencies
22+ run : uv sync --extra linting
23+
24+ - name : Ruff format check
25+ run : uv run ruff format --check torchsom/ tests/
26+
27+ - name : Ruff lint
28+ run : uv run ruff check torchsom/ tests/ --output-format=github
29+
30+ - name : Type checking with mypy
31+ run : uv run mypy torchsom/ --ignore-missing-imports
32+ continue-on-error : true
7733
7834 docstring-quality :
7935 runs-on : ubuntu-latest
8036 steps :
81- - uses : actions/checkout@v4
82-
83- - name : Set up Python 3.9
84- uses : actions/setup-python@v4
85- with :
86- python-version : " 3.9"
87-
88- - name : Cache pip dependencies
89- uses : actions/cache@v3
90- with :
91- path : ~/.cache/pip
92- key : ${{ runner.os }}-pip-quality-${{ hashFiles('pyproject.toml') }}
93- restore-keys : |
94- ${{ runner.os }}-pip-quality-
95- ${{ runner.os }}-pip-
96-
97- - name : Install dependencies
98- run : |
99- python -m pip install --upgrade pip
100- pip install -e ".[dev, docs]"
101- # pip install pydocstyle interrogate
102-
103- - name : Check docstring style
104- run : |
105- pydocstyle torchsom/ --convention=google
106- continue-on-error : true
107-
108- - name : Check docstring coverage
109- run : |
110- interrogate torchsom/ --verbose --ignore-init-method --ignore-magic --ignore-module --fail-under=80
111- continue-on-error : true
112-
113- complexity-analysis :
114- runs-on : ubuntu-latest
115- steps :
116- - uses : actions/checkout@v4
117-
118- - name : Set up Python 3.9
119- uses : actions/setup-python@v4
120- with :
121- python-version : " 3.9"
122-
123- - name : Cache pip dependencies
124- uses : actions/cache@v3
125- with :
126- path : ~/.cache/pip
127- key : ${{ runner.os }}-pip-quality-${{ hashFiles('pyproject.toml') }}
128- restore-keys : |
129- ${{ runner.os }}-pip-quality-
130- ${{ runner.os }}-pip-
131-
132- - name : Install dependencies
133- run : |
134- python -m pip install --upgrade pip
135- pip install -e ".[dev, linting]"
136- # pip install radon
137-
138- - name : Analyze code complexity
139- run : |
140- radon cc torchsom/ --show-complexity --min B
141- radon mi torchsom/ --show --min B
142- continue-on-error : true
143-
144- check-dependencies :
37+ - uses : actions/checkout@v4
38+
39+ - name : Install uv
40+ uses : astral-sh/setup-uv@v5
41+
42+ - name : Set up Python
43+ run : uv python install 3.12
44+
45+ - name : Sync dependencies
46+ run : uv sync --extra docs
47+
48+ - name : Docstring coverage
49+ run : uv run interrogate torchsom/ --verbose --ignore-init-method --ignore-magic --ignore-module --fail-under=80
50+ continue-on-error : true
51+
52+ complexity :
14553 runs-on : ubuntu-latest
14654 steps :
147- - uses : actions/checkout@v4
148-
149- - name : Set up Python 3.9
150- uses : actions/setup-python@v4
151- with :
152- python-version : " 3.9"
153-
154- - name : Cache pip dependencies
155- uses : actions/cache@v3
156- with :
157- path : ~/.cache/pip
158- key : ${{ runner.os }}-pip-quality-${{ hashFiles('pyproject.toml') }}
159- restore-keys : |
160- ${{ runner.os }}-pip-quality-
161- ${{ runner.os }}-pip-
162-
163- - name : Install pip-tools
164- run : |
165- python -m pip install --upgrade pip
166- pip install -e ".[security]"
167- # pip install pip-tools
168-
169- - name : Check for dependency conflicts
170- run : |
171- pip-compile pyproject.toml --dry-run --verbose
172- continue-on-error : true
55+ - uses : actions/checkout@v4
56+
57+ - name : Install uv
58+ uses : astral-sh/setup-uv@v5
59+
60+ - name : Set up Python
61+ run : uv python install 3.12
62+
63+ - name : Sync dependencies
64+ run : uv sync --extra linting
65+
66+ - name : Complexity analysis
67+ run : |
68+ uv run radon cc torchsom/ --show-complexity --min B
69+ uv run radon mi torchsom/ --show --min B
70+ continue-on-error : true
0 commit comments