Skip to content

FEAT: Adding set_attr in connection class #1295

FEAT: Adding set_attr in connection class

FEAT: Adding set_attr in connection class #1295

name: PR Formatting Check
on:
pull_request:
types: [opened, edited, reopened, synchronize]
permissions:
pull-requests: write
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Validate PR title and description content
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title;
const body = context.payload.pull_request.body;
const prAuthor = context.payload.pull_request.user.login;
// Validate title prefix for all contributors
const validTitlePrefixes = [
'FEAT:', 'CHORE:', 'FIX:', 'DOC:', 'STYLE:', 'REFACTOR:',
'RELEASE:'
];
const hasValidPrefix = validTitlePrefixes.some(prefix =>
title.startsWith(prefix));
if (!hasValidPrefix) {
core.setFailed(`❌ PR title must start with one of the allowed prefixes:\n${validTitlePrefixes.join(', ')}`);
}
// Validate that either GitHub issue link or ADO Work Item link is present
const azureWorkItemLinkPattern =
/https:\/\/sqlclientdrivers\.visualstudio\.com\/[^\/]+\/_workitems\/edit\/\d+/i;
const githubIssueLinkPattern =
/(https:\/\/github\.com\/microsoft\/mssql-python\/issues\/\d+|#\d+)/i;
const hasWorkItemLink = azureWorkItemLinkPattern.test(body);
const hasGitHubIssueLink = githubIssueLinkPattern.test(body);
if (!hasWorkItemLink && !hasGitHubIssueLink) {
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.`);
}
// Check if PR description contains a meaningful summary section
// with actual content (for all contributors)
const summaryPattern =
/###\s*Summary\s*\r?\n([\s\S]*?)(\r?\n###|$)/;
const summaryMatch = body.match(summaryPattern);
let hasValidSummary = false;
if (summaryMatch && summaryMatch[1]) {
// Extract the summary content
const summaryContent = summaryMatch[1];
// Remove all HTML comments including unclosed ones (template placeholders)
const contentWithoutComments =
summaryContent.replace(/<!--[\s\S]*?(?:-->|$)/g, '');
// Remove whitespace and check if there's actual text content
const trimmedContent = contentWithoutComments.trim();
// Check if there's at least 10 characters of meaningful content
hasValidSummary = trimmedContent.length >= 10;
}
if (!hasValidSummary) {
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.`);
}
- name: Add size label based on PR diff
if: github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
const additions = pr.additions;
const deletions = pr.deletions;
const totalChanges = additions + deletions;
// Threshold constants
const SMALL_PR_THRESHOLD = 100;
const MEDIUM_PR_THRESHOLD = 500;
let labelToAdd = '';
if (totalChanges < SMALL_PR_THRESHOLD) {
labelToAdd = 'pr-size: small';
} else if (totalChanges < MEDIUM_PR_THRESHOLD) {
labelToAdd = 'pr-size: medium';
} else {
labelToAdd = 'pr-size: large';
}
// Get existing labels
const existingLabels = pr.labels.map(l => l.name);
const sizeLabels = ['pr-size: small', 'pr-size: medium', 'pr-size: large'];
// Find current size label (if any)
const currentSizeLabel = existingLabels.find(label => sizeLabels.includes(label));
// Only make changes if the label needs to be updated
if (currentSizeLabel !== labelToAdd) {
console.log(`Current size label: ${currentSizeLabel || 'none'}`);
console.log(`Required size label: ${labelToAdd} (Total changes: ${totalChanges})`);
// Remove existing size label if different from required
if (currentSizeLabel) {
console.log(`Removing outdated label: ${currentSizeLabel}`);
await github.rest.issues.removeLabel({
...context.repo,
issue_number: pr.number,
name: currentSizeLabel,
});
}
// Add new size label
console.log(`Adding new label: ${labelToAdd}`);
await github.rest.issues.addLabels({
...context.repo,
issue_number: pr.number,
labels: [labelToAdd],
});
} else {
console.log(`Label already correct: ${labelToAdd} (Total changes: ${totalChanges}) - no changes needed`);
}