Skip to content

Commit 06a505e

Browse files
committed
Merged PR 5874: SYNC: Templates and Github Commit History
#### AI description (iteration 1) #### PR Classification This pull request standardizes repository workflows and templates to enforce consistent PR formatting and improve issue reporting. #### PR Summary The changes introduce new GitHub workflow files for validating PR details and running security scans, alongside standardized templates for pull requests and issues to align with release objectives. - `/.github/workflows/pr-format-check.yml`: Adds a workflow that validates PR titles, descriptions (including ADO work item links and summary content), and applies a size label based on code diff. - `/.github/workflows/devskim.yml`: Introduces a workflow to run the DevSkim scanner and upload static analysis results. - `/.github/PULL_REQUEST_TEMPLATE.MD`: Provides a PR template with guidelines for including work item references and structured summaries. - `/.github/ISSUE_TEMPLATE/*`: Adds multiple issue templates (bug report, feature request, and other) and a configuration file to standardize issue submissions. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> Related work items: #38037
1 parent 0639734 commit 06a505e

File tree

10 files changed

+1015
-1
lines changed

10 files changed

+1015
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ""
5+
labels: [":new: Triage Needed", ":bug: Bug!"]
6+
assignees: []
7+
8+
---
9+
10+
### Describe the bug
11+
A clear and concise description of what the bug is.
12+
13+
If you are seeing an exception, include the full exceptions details (message and stack trace).
14+
15+
```
16+
Exception message:
17+
Stack trace:
18+
```
19+
20+
### To reproduce
21+
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
22+
23+
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
24+
25+
```python
26+
print("Hello World!")
27+
```
28+
29+
### Expected behavior
30+
A clear and concise description of what you expected to happen.
31+
32+
### Further technical details
33+
Python version:
34+
SQL Server version: (e.g. SQL Server 2022)
35+
Operating system: (e.g. Windows Server 2022, Ubuntu 24.04, macOS 14.7.1, Docker container)
36+
37+
**Additional context**
38+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Python Community Support / Discussions
4+
url: https://github.com/microsoft/mssql-python/discussions
5+
about: Please ask and answer questions here.
6+
- name: MSRC Vulnerability Reporting / Bug Bounty
7+
url: https://msrc.microsoft.com/create-report
8+
about: Please report security vulnerabilities here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ""
5+
labels: [":new: Triage Needed", ":bulb: Enhancement"]
6+
assignees: []
7+
8+
---
9+
10+
### Is your feature request related to a problem? Please describe.
11+
A clear and concise description of what the problem is.
12+
13+
### Describe the solution you'd like
14+
A clear and concise description of what you want to happen.
15+
16+
### Describe alternatives you've considered
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
### Additional context
20+
Add any other context about the feature request here.

.github/ISSUE_TEMPLATE/other.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
name: Other
3+
about: Ask a question or file a different type of issue
4+
title: ""
5+
labels: [":new: Triage Needed"]
6+
assignees: []
7+
8+
---

.github/PULL_REQUEST_TEMPLATE.MD

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
### Work Item / Issue Reference
2+
<!--
3+
IMPORTANT: Please follow the PR template guidelines below.
4+
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g. AB#37452)
5+
For external contributors: Insert Github Issue number below (e.g. #149)
6+
Only one reference is required - either GitHub issue OR ADO Work Item.
7+
-->
8+
9+
<!-- mssql-python maintainers: ADO Work Item -->
10+
> AB#<WORK_ITEM_ID>
11+
12+
<!-- External contributors: GitHub Issue -->
13+
> GitHub Issue: #<ISSUE_NUMBER>
14+
15+
-------------------------------------------------------------------
16+
### Summary
17+
<!-- Insert your summary of changes below. Minimum 10 characters required. -->
18+
19+
20+
<!--
21+
### PR Title Guide
22+
23+
> For feature requests
24+
FEAT: (short-description)
25+
26+
> For non-feature requests like test case updates, config updates , dependency updates etc
27+
CHORE: (short-description)
28+
29+
> For Fix requests
30+
FIX: (short-description)
31+
32+
> For doc update requests
33+
DOC: (short-description)
34+
35+
> For Formatting, indentation, or styling update
36+
STYLE: (short-description)
37+
38+
> For Refactor, without any feature changes
39+
REFACTOR: (short-description)
40+
41+
> For release related changes, without any feature changes
42+
RELEASE: #<RELEASE_VERSION> (short-description)
43+
44+
### Contribution Guidelines
45+
46+
External contributors:
47+
- Create a GitHub issue first: https://github.com/microsoft/mssql-python/issues/new
48+
- Link the GitHub issue in the "GitHub Issue" section above
49+
- Follow the PR title format and provide a meaningful summary
50+
51+
mssql-python maintainers:
52+
- Create an ADO Work Item following internal processes
53+
- Link the ADO Work Item in the "ADO Work Item" section above
54+
- Follow the PR title format and provide a meaningful summary
55+
-->

.github/workflows/devskim.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: DevSkim
7+
8+
on:
9+
push:
10+
branches: [ "main" ]
11+
pull_request:
12+
branches: [ "main" ]
13+
schedule:
14+
- cron: '44 7 * * 5'
15+
16+
jobs:
17+
lint:
18+
name: DevSkim
19+
runs-on: ubuntu-latest
20+
permissions:
21+
actions: read
22+
contents: read
23+
security-events: write
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Run DevSkim scanner
29+
uses: microsoft/DevSkim-Action@v1
30+
31+
- name: Upload DevSkim scan results to GitHub Security tab
32+
uses: github/codeql-action/upload-sarif@v3
33+
with:
34+
sarif_file: devskim-results.sarif
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: PR Formatting Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Validate PR title and description content
15+
uses: actions/github-script@v7
16+
with:
17+
script: |
18+
const title = context.payload.pull_request.title;
19+
const body = context.payload.pull_request.body;
20+
const prAuthor = context.payload.pull_request.user.login;
21+
22+
// Validate title prefix for all contributors
23+
const validTitlePrefixes = [
24+
'FEAT:', 'CHORE:', 'FIX:', 'DOC:', 'STYLE:', 'REFACTOR:',
25+
'RELEASE:'
26+
];
27+
28+
const hasValidPrefix = validTitlePrefixes.some(prefix =>
29+
title.startsWith(prefix));
30+
31+
if (!hasValidPrefix) {
32+
core.setFailed(`❌ PR title must start with one of the allowed prefixes:\n${validTitlePrefixes.join(', ')}`);
33+
}
34+
35+
// Validate that either GitHub issue link or ADO Work Item link is present
36+
const azureWorkItemLinkPattern =
37+
/https:\/\/sqlclientdrivers\.visualstudio\.com\/[^\/]+\/_workitems\/edit\/\d+/i;
38+
const githubIssueLinkPattern =
39+
/(https:\/\/github\.com\/microsoft\/mssql-python\/issues\/\d+|#\d+)/i;
40+
41+
const hasWorkItemLink = azureWorkItemLinkPattern.test(body);
42+
const hasGitHubIssueLink = githubIssueLinkPattern.test(body);
43+
44+
if (!hasWorkItemLink && !hasGitHubIssueLink) {
45+
core.setFailed(`❌ PR must contain either a valid GitHub issue link OR a valid ADO Work Item link.\nGitHub issue format: https://github.com/microsoft/mssql-python/issues/XXX or #XXX\nADO Work Item format: https://sqlclientdrivers.visualstudio.com/.../_workitems/edit/<ID>\nPlease include at least one reference in the PR description.\nFor more information, see CONTRIBUTING.md.`);
46+
}
47+
48+
// Check if PR description contains a meaningful summary section
49+
// with actual content (for all contributors)
50+
const summaryPattern =
51+
/###\s*Summary\s*\r?\n([\s\S]*?)(\r?\n###|$)/;
52+
const summaryMatch = body.match(summaryPattern);
53+
54+
let hasValidSummary = false;
55+
56+
if (summaryMatch && summaryMatch[1]) {
57+
// Extract the summary content
58+
const summaryContent = summaryMatch[1];
59+
60+
// Remove all HTML comments including the template placeholder
61+
const contentWithoutComments =
62+
summaryContent.replace(/<!--[\s\S]*?-->/g, '');
63+
64+
// Remove whitespace and check if there's actual text content
65+
const trimmedContent = contentWithoutComments.trim();
66+
67+
// Check if there's at least 10 characters of meaningful content
68+
hasValidSummary = trimmedContent.length >= 10;
69+
}
70+
71+
if (!hasValidSummary) {
72+
core.setFailed(`❌ PR must contain a meaningful summary section with actual text content (minimum 10 characters).\nPlease add a clear description under the '### Summary' heading in your PR description.`);
73+
}
74+
- name: Add size label based on PR diff
75+
if: github.event.pull_request.head.repo.full_name == github.repository
76+
uses: actions/github-script@v7
77+
with:
78+
script: |
79+
const pr = context.payload.pull_request;
80+
const additions = pr.additions;
81+
const deletions = pr.deletions;
82+
const totalChanges = additions + deletions;
83+
84+
// Threshold constants
85+
const SMALL_PR_THRESHOLD = 100;
86+
const MEDIUM_PR_THRESHOLD = 500;
87+
88+
let labelToAdd = '';
89+
if (totalChanges < SMALL_PR_THRESHOLD) {
90+
labelToAdd = 'pr-size: small';
91+
} else if (totalChanges < MEDIUM_PR_THRESHOLD) {
92+
labelToAdd = 'pr-size: medium';
93+
} else {
94+
labelToAdd = 'pr-size: large';
95+
}
96+
97+
// Remove existing size labels if any
98+
const existingLabels = pr.labels.map(l => l.name);
99+
const sizeLabels = ['pr-size: small', 'pr-size: medium', 'pr-size: large'];
100+
for (const label of existingLabels) {
101+
if (sizeLabels.includes(label)) {
102+
await github.rest.issues.removeLabel({
103+
...context.repo,
104+
issue_number: pr.number,
105+
name: label,
106+
});
107+
}
108+
}
109+
110+
// Add new size label
111+
await github.rest.issues.addLabels({
112+
...context.repo,
113+
issue_number: pr.number,
114+
labels: [labelToAdd],
115+
});
116+
117+
console.log(`Added label: ${labelToAdd} (Total changes: ${totalChanges})`);

CONTRIBUTING.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,32 @@ instructions provided by the bot. You will only need to do this once across all
1111

1212
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
1313
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
14-
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
14+
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
15+
16+
## Before Contributing
17+
18+
### For External Contributors
19+
20+
If you are an external contributor (not a Microsoft organization member), please follow these steps:
21+
22+
1. **Create a GitHub Issue First**: Before submitting a pull request, create a GitHub issue describing the bug, feature request, or improvement you want to contribute.
23+
2. **Link the Issue in Your PR**: When you submit your pull request, please use the PR template and include a link to the GitHub issue in the PR description using the format: `https://github.com/microsoft/mssql-python/issues/XXX`
24+
3. **Follow PR Guidelines**: Ensure your PR title follows the required prefix format (FEAT:, FIX:, DOC:, etc.) and includes a meaningful summary.
25+
26+
### For Microsoft Organization Members
27+
28+
If you are a Microsoft organization member (internal contributor):
29+
30+
1. **Create an ADO Work Item**: Follow your internal process to create an Azure DevOps (ADO) work item.
31+
2. **Link the ADO Work Item**: Include the ADO work item link in your PR description using the format: `https://sqlclientdrivers.visualstudio.com/.../workitems/edit/ID`
32+
3. **Follow PR Guidelines**: Ensure your PR title follows the required prefix format and includes a meaningful summary.
33+
34+
## Pull Request Requirements
35+
36+
All pull requests must include:
37+
38+
- **Valid Title Prefix**: Your PR title must start with one of: `FEAT:`, `CHORE:`, `FIX:`, `DOC:`, `STYLE:`, `REFACTOR:`, or `RELEASE:`
39+
- **Meaningful Summary**: Include a clear description of your changes under the "### Summary" section in the PR description (minimum 10 characters)
40+
- **Issue/Work Item Link** (only one required):
41+
- External contributors: Link to a GitHub issue
42+
- Microsoft org members: Link to an ADO work item

benchmarks/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Benchmarks
2+
3+
This directory contains benchmark scripts for testing the performance of various database operations using `pyodbc` and `mssql_python`. The goal is to evaluate and compare the performance of these libraries for common database operations.
4+
5+
## Why Benchmarks?
6+
- To measure the efficiency of `pyodbc` and `mssql_python` in handling database operations.
7+
- To identify performance bottlenecks and optimize database interactions.
8+
- To ensure the reliability and scalability of the libraries under different workloads.
9+
10+
## How to Run Benchmarks
11+
1. **Set Up the Environment Variable**:
12+
- Ensure you have a running SQL Server instance.
13+
- Set the `DB_CONNECTION_STRING` environment variable with the connection string to your database. For example:
14+
```cmd
15+
set DB_CONNECTION_STRING=Server=your_server;Database=your_database;UID=your_user;PWD=your_password;
16+
```
17+
18+
2. **Install Richbench - Benchmarking Tool**:
19+
- Install richbench :
20+
```cmd
21+
pip install richbench
22+
```
23+
24+
3. **Run the Benchmarks**:
25+
- Execute richbench from the parent folder (mssql-python) :
26+
```cmd
27+
richbench benchmarks
28+
```
29+
Results will be displayed in the terminal with detailed performance metrics.
30+
31+
## Key Features of `bench_mssql.py`
32+
- **Comprehensive Benchmarks**: Includes SELECT, INSERT, UPDATE, DELETE, complex queries, stored procedures, and transaction handling.
33+
- **Error Handling**: Each benchmark function is wrapped with error handling to ensure smooth execution.
34+
- **Progress Messages**: Clear progress messages are printed during execution for better visibility.
35+
- **Automated Setup and Cleanup**: The script automatically sets up and cleans up the database environment before and after the benchmarks.
36+
37+
## Notes
38+
- Ensure the database user has the necessary permissions to create and drop tables and stored procedures.
39+
- The script uses permanent tables prefixed with `perfbenchmark_` for benchmarking purposes.
40+
- A stored procedure named `perfbenchmark_stored_procedure` is created and used during the benchmarks.

0 commit comments

Comments
 (0)