Skip to content

STYLE: Adding precommit hook and workflow for checking code quality - #302

Open
Jahnvi Thakkar (jahnvi480) wants to merge 2 commits into
mainfrom
jahnvi/linting_prehook
Open

Jahnvi Thakkar (jahnvi480) wants to merge 2 commits into
mainfrom
jahnvi/linting_prehook

Conversation

@jahnvi480

@jahnvi480 Jahnvi Thakkar (jahnvi480) commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

Work Item / Issue Reference

AB#33454


Summary

Refresh the pre-commit implementation against current main so local formatting
checks match the repository's existing blocking CI rule: Black.

  • Add a pinned Black hook that formats staged Python and type-stub files under
    mssql_python and tests, stopping commits when fixes need review and restaging.
  • Install a pre-push hook that checks both directories in full without modifying
    files. Run that same hook and pinned formatter version in the existing lint
    workflow.
  • Keep Flake8, Pylint, mypy, clang-format, and cpplint informational. Replace the
    earlier draft's separate Pylint/cpplint blocking workflow rather than introduce
    new lint thresholds or change C++ formatting policy.
  • Add isolated lint-tool installation through requirements-lint.txt, install both
    hooks automatically in devcontainers, and document setup for new and existing
    clones.
  • Add repository-wide Copilot guidance to detect missing local hook setup, install it
    in the development environment, and run the shared formatting check before pushes
    and PRs. Pulling alone does not execute setup; Copilot acts during an editing task.
  • Run the lint workflow on every PR, including documentation-only changes, so a
    required lint status check is not skipped by path filters.

Local hooks cannot prevent PR creation and can be bypassed. Maintainers must
require Linting Summary in branch protection/rulesets to block merging
formatting failures; this PR does not modify repository protection settings.

Copilot AI review requested due to automatic review settings October 28, 2025 07:27
@github-actions github-actions Bot added the pr-size: medium Moderate update size label Oct 28, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds automated code quality enforcement by introducing pre-commit hooks and GitHub Actions workflows to check Python and C++ code against linting standards.

Key changes:

  • GitHub Actions workflow for automatic linting checks on pull requests with configurable thresholds
  • Pre-commit hooks for local linting enforcement before commits
  • Configuration files defining linting rules, disabled checks, and error thresholds for both Python (pylint) and C++ (cpplint)

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/code-quality-check.yml Implements CI workflow to run pylint and cpplint on PRs, report status, and post results as comments
.pre-commit-config.yml Configures pre-commit hooks for pylint and cpplint with specified arguments and file exclusions
pyproject.toml Defines pylint configuration including disabled checks, minimum score threshold of 8.5, and max line length
cpplint.cfg Sets C++ linting rules including line length limit and filtered checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .pre-commit-config.yml Outdated
Comment thread .github/workflows/code-quality-check.yml Outdated
Comment thread .github/workflows/code-quality-check.yml Outdated
@github-actions

github-actions Bot commented Oct 28, 2025 •

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

84%


📈 Total Lines Covered: 9402 out of 11085
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 62.6%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 79.3%
mssql_python.pybind.connection.connection_pool.cpp: 82.3%
mssql_python.pybind.connection.connection.cpp: 83.1%
mssql_python.logging.py: 86.2%
mssql_python.pooling.py: 90.1%
mssql_python.pybind.fetch_temporal.hpp: 92.1%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only minor change required. rest all looks good

Copilot AI balanced review requested due to automatic review settings September 30, 2026 13:48
@github-actions github-actions Bot added pr-size: large Substantial code update and removed pr-size: medium Moderate update size labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

PR Performance Report

✅ No regression detected

No consistent slowdowns detected across all 2 environments.

0 IMPROVEMENTS 0 SLOWDOWNS 2/2 ENVIRONMENTS

Coverage: 2 of 2 environments completed. Advisory result; does not block merging.

Performance diagnostics

Phase times are inclusive diagnostics and must not be added together. They identify where measured time changed, not why it changed.

No affected phases or call-count changes were recorded.

All database tasks and timings

Unix / SQL Server 2022

Database task Before After Paired change Result
Connection opening 10.410 ms 10.376 ms -0.3% no signal
SELECT queries 1.075 ms 1.078 ms +0.5% no signal
Row insertion 34.374 ms 34.473 ms +0.7% no signal
Executemany inserts 154.490 ms 154.745 ms -0.7% no signal
Fetch-all queries 119.812 ms 120.203 ms +1.0% no signal
Row-by-row fetching 14.568 ms 14.455 ms +0.3% no signal
Batched row fetching 117.764 ms 117.553 ms -0.1% no signal
Transaction commit and rollback 114.126 ms 113.645 ms -0.3% no signal
Arrow row fetching 93.526 ms 94.645 ms +0.9% no signal
100,000-row insertion 443.929 ms 481.798 ms -0.2% no signal
Row fetching in batches of 100 120.217 ms 122.387 ms +1.8% no signal
Row fetching in batches of 10,000 134.605 ms 130.762 ms -2.1% no signal
Repeated positional queries 34.143 ms 33.608 ms -0.2% no signal
Repeated named-parameter queries 35.709 ms 35.334 ms -1.1% no signal
Legacy 100,000-row insertion 345.718 ms 350.169 ms +0.0% no signal
Insertion with explicit input sizes 492.477 ms 484.633 ms -1.6% no signal
Joined aggregation queries 177.981 ms 180.834 ms +1.5% no signal
Large joined-result fetching 177.452 ms 175.911 ms -1.4% no signal
1.2-million-row fetching 3469.758 ms 3478.916 ms -0.3% no signal
Common table expression queries 5.330 ms 5.310 ms -1.9% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.381 ms 1.330 ms +3.6% no signal

Unix / SQL Server 2025

Database task Before After Paired change Result
Connection opening 97.402 ms 96.436 ms -0.8% no signal
SELECT queries 1.110 ms 1.078 ms -2.1% no signal
Row insertion 34.639 ms 34.344 ms -0.4% no signal
Executemany inserts 149.816 ms 149.270 ms -0.9% no signal
Fetch-all queries 121.154 ms 121.068 ms -0.1% no signal
Row-by-row fetching 14.456 ms 14.875 ms +5.1% no signal
Batched row fetching 118.417 ms 124.854 ms +5.4% no signal
Transaction commit and rollback 115.323 ms 115.005 ms +0.3% no signal
Arrow row fetching 94.872 ms 96.363 ms +2.0% no signal
100,000-row insertion 453.332 ms 445.706 ms -0.2% no signal
Row fetching in batches of 100 123.264 ms 122.013 ms -1.1% no signal
Row fetching in batches of 10,000 144.423 ms 142.558 ms +1.9% no signal
Repeated positional queries 33.896 ms 33.229 ms -0.5% no signal
Repeated named-parameter queries 36.262 ms 36.786 ms +0.6% no signal
Legacy 100,000-row insertion 356.109 ms 346.215 ms -2.8% no signal
Insertion with explicit input sizes 483.293 ms 486.895 ms +1.0% no signal
Joined aggregation queries 159.977 ms 160.515 ms +0.3% no signal
Large joined-result fetching 179.901 ms 178.847 ms -0.4% no signal
1.2-million-row fetching 3549.129 ms 3559.490 ms +1.7% no signal
Common table expression queries 5.219 ms 5.244 ms -1.1% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.489 ms 1.502 ms +2.5% no signal
Build and measurement details

ADO build 179695

PR head: 946d2d9b4b85c62db483e973022058493d9bb0d2
Base: c5831908977f0b8b355fda6f71d86629855d46aa
Measured merge: 95f47ba52daf2acfef9b7856be4905aa604a2f75

  • Unix / SQL Server 2022: Python 3.12.3, x86_64, SQL 16.0.4295.3; 5 paired comparisons and 1 warmup.
  • Unix / SQL Server 2025: Python 3.12.3, x86_64, SQL 17.0.5005.3; 5 paired comparisons and 1 warmup.

A consistent change requires more than 20% median paired movement, at least 1 ms between the median runtimes, and at least 80% of pairs exceeding the relative threshold in the same direction. A slowdown without enough pair agreement is reported as inconsistent.

The displayed change is the median of paired before-and-after ratios. It is not recalculated from the two displayed median runtimes.

Both revisions use profiling-enabled builds on the same agent and database, with alternating order and discarded warmups. Results are diagnostic and do not represent production-wheel latency.

Raw samples and logs are attached to the ADO run as profiler-* artifacts.

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devskim found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions github-actions Bot added pr-size: medium Moderate update size and removed pr-size: large Substantial code update labels Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread .github/workflows/lint-check.yml Outdated
Comment thread .github/workflows/lint-check.yml Outdated
Comment thread .github/workflows/lint-check.yml
Comment thread .devcontainer/post-create.sh
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread CONTRIBUTING.md
Copilot AI balanced review requested due to automatic review settings September 30, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 04:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 10:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The local, devcontainer, documentation, and CI formatting flows are consistently aligned with the pinned Black hook.

Review effort: Balanced
Findings: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: medium Moderate update size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants