Repository navigation
184 lines (156 loc) · 6.86 KB
/
Copy pathlint-check.yml
File metadata and controls
184 lines (156 loc) · 6.86 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Linting Check
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main
permissions:
contents: read
jobs:
python-lint:
name: Python Linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
id: python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: |
requirements.txt
requirements-lint.txt
.pre-commit-config.yaml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-lint.txt
python -m pip install flake8 pylint autopep8
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
- name: Cache pre-commit environments
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-${{ runner.arch }}-pre-commit-${{ steps.python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml', 'requirements-lint.txt') }}
- name: Check Python formatting with Black
run: |
echo "::group::Black Formatting Check"
python -m pre_commit run black-check --all-files --hook-stage pre-push || {
echo "::error::Black formatting issues found. Run 'python -m pre_commit run black --all-files' locally, stage the fixes, and retry."
exit 1
}
echo "::endgroup::"
- name: Lint with Flake8
run: |
echo "::group::Flake8 Linting"
flake8 mssql_python/ tests/ --max-line-length=100 --extend-ignore=E203,W503,E501,E722,F401,F841,W293,W291,F541,F811,E402,E711,E712,E721,F821 --count --statistics || {
echo "::warning::Flake8 found linting issues (informational only, not blocking)"
}
echo "::endgroup::"
continue-on-error: true
- name: Lint with Pylint
run: |
echo "::group::Pylint Analysis"
pylint mssql_python/ --max-line-length=100 \
--disable=fixme,no-member,too-many-arguments,too-many-positional-arguments,invalid-name,useless-parent-delegation \
--exit-zero --output-format=colorized --reports=y || true
echo "::endgroup::"
- name: Check Type Hints (mypy)
run: |
echo "::group::Type Checking"
python -m pip install mypy
mypy mssql_python/ --ignore-missing-imports --no-strict-optional --check-untyped-defs || {
echo "::warning::Type checking found potential issues. Review the output above."
}
echo "::endgroup::"
continue-on-error: true
cpp-lint:
name: C++ Linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python (for cpplint)
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.13'
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
clang-format --version
- name: Install cpplint
run: |
python -m pip install --upgrade pip
python -m pip install cpplint
- name: Check C++ formatting with clang-format
run: |
echo "::group::clang-format Check"
# Check formatting without Werror (informational only)
find mssql_python/pybind -type f \( -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.hpp" \) | while read file; do
echo "Checking $file"
clang-format --dry-run "$file" 2>&1 || true
done
echo "✅ clang-format check completed (informational only)"
echo "::endgroup::"
continue-on-error: true
- name: Lint with cpplint
run: |
echo "::group::cpplint Check"
python -m cpplint \
--filter=-legal/copyright,-build/include_subdir,-build/c++11 \
--linelength=100 \
--recursive \
--quiet \
mssql_python/pybind 2>&1 | tee cpplint_output.txt || true
# Count errors and warnings
ERROR_COUNT=$(grep -c "Total errors found:" cpplint_output.txt || echo "0")
if [ -s cpplint_output.txt ] && grep -q "Total errors found:" cpplint_output.txt; then
TOTAL_ERRORS=$(grep "Total errors found:" cpplint_output.txt | awk '{print $4}')
echo "::warning::cpplint found $TOTAL_ERRORS issues. These are informational and don't block the PR."
# Show summary but don't fail (informational only)
echo "cpplint found $TOTAL_ERRORS style guideline issues (not blocking)"
else
echo "✅ cpplint check passed with minimal issues"
fi
echo "::endgroup::"
continue-on-error: true
lint-summary:
name: Linting Summary
runs-on: ubuntu-latest
needs: [python-lint, cpp-lint]
if: always()
steps:
- name: Check results
run: |
echo "## Linting Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Check Results" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.python-lint.result }}" == "success" ]; then
echo "✅ **Python Formatting (Black):** PASSED" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Python Formatting (Black):** FAILED - Please run Black formatter" >> $GITHUB_STEP_SUMMARY
fi
echo "ℹ️ **Python Linting (Flake8, Pylint):** Informational only" >> $GITHUB_STEP_SUMMARY
echo "ℹ️ **C++ Linting (clang-format, cpplint):** Informational only" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Required Actions" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Black formatting must pass (blocking)" >> $GITHUB_STEP_SUMMARY
echo "- ℹ️ Other linting issues are warnings and won't block PR" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### How to Fix" >> $GITHUB_STEP_SUMMARY
echo "1. Save all files in VS Code (Ctrl+S) - auto-formatting will fix most issues" >> $GITHUB_STEP_SUMMARY
echo "2. Or run manually: \`python -m pre_commit run black --all-files\`, then stage the fixes" >> $GITHUB_STEP_SUMMARY
echo "3. For C++: \`clang-format -i mssql_python/pybind/*.cpp\`" >> $GITHUB_STEP_SUMMARY
- name: Fail if Python formatting failed
if: needs.python-lint.result != 'success'
run: |
echo "::error::Python Black formatting check failed. Please format your Python files."
exit 1