Repository navigation
PERF: Optimize fetchone, fetchmany(1) and fetchval paths #3265
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| id: python | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.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@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.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@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python (for cpplint) | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.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 |