Skip to content

Commit 050e0b6

Browse files
Merge upstream main
2 parents d266e22 + afe72e3 commit 050e0b6

24 files changed

+6731
-429
lines changed

.github/codeql/codeql-config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: "CodeQL Config"
2+
3+
# Exclude example files from CodeQL analysis
4+
# Examples contain fake credentials for demonstration purposes
5+
paths-ignore:
6+
- "examples/**"
7+
- "**/test_*.py"
8+
- "tests/**"

.github/labeler.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Configuration for labeler action
2+
# https://github.com/actions/labeler
3+
4+
# SDK code
5+
sdk:
6+
- changed-files:
7+
- any-glob-to-any-file: 'src/msgtrace/sdk/**'
8+
9+
# Core/Parser code
10+
core:
11+
- changed-files:
12+
- any-glob-to-any-file: 'src/msgtrace/core/**'
13+
14+
# Tests
15+
tests:
16+
- changed-files:
17+
- any-glob-to-any-file: 'tests/**'
18+
19+
# Documentation
20+
documentation:
21+
- changed-files:
22+
- any-glob-to-any-file:
23+
- '**/*.md'
24+
- 'docs/**'
25+
26+
# CI/CD
27+
ci:
28+
- changed-files:
29+
- any-glob-to-any-file:
30+
- '.github/workflows/**'
31+
- '.github/dependabot.yml'
32+
- '.github/labeler.yml'
33+
34+
# Dependencies
35+
dependencies:
36+
- changed-files:
37+
- any-glob-to-any-file:
38+
- 'pyproject.toml'
39+
- 'uv.lock'
40+
- '.pre-commit-config.yaml'
41+
42+
# Examples
43+
examples:
44+
- changed-files:
45+
- any-glob-to-any-file: 'examples/**'

.github/workflows/codeql.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CodeQL Security Scan
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
# Run every Monday at 3am UTC
10+
- cron: "0 3 * * 1"
11+
12+
permissions:
13+
actions: read
14+
contents: read
15+
security-events: write
16+
17+
jobs:
18+
analyze:
19+
name: Analyze Python Code
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Initialize CodeQL
27+
uses: github/codeql-action/init@v3
28+
with:
29+
languages: python
30+
# Queries: security-extended includes more security checks
31+
queries: security-extended
32+
# Use custom config to exclude example files
33+
config-file: ./.github/codeql/codeql-config.yml
34+
35+
- name: Perform CodeQL Analysis
36+
uses: github/codeql-action/analyze@v3
37+
with:
38+
category: "/language:python"

.github/workflows/labeler.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Label PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
label:
13+
# Disabled: fails on fork PRs due to token permissions
14+
if: false
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Label PR based on files
21+
uses: actions/labeler@v6
22+
with:
23+
repo-token: ${{ secrets.GITHUB_TOKEN }}
24+
configuration-path: .github/labeler.yml
25+
26+
- name: Label PR based on size
27+
uses: actions/github-script@v8
28+
with:
29+
script: |
30+
const pr = context.payload.pull_request;
31+
const additions = pr.additions;
32+
const deletions = pr.deletions;
33+
const totalChanges = additions + deletions;
34+
35+
// Remove existing size labels
36+
const existingLabels = pr.labels.map(label => label.name);
37+
const sizeLabels = ['size/XS', 'size/S', 'size/M', 'size/L', 'size/XL'];
38+
const labelsToRemove = existingLabels.filter(label => sizeLabels.includes(label));
39+
40+
for (const label of labelsToRemove) {
41+
await github.rest.issues.removeLabel({
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
issue_number: pr.number,
45+
name: label
46+
});
47+
}
48+
49+
// Determine size label
50+
let sizeLabel;
51+
if (totalChanges < 10) {
52+
sizeLabel = 'size/XS';
53+
} else if (totalChanges < 50) {
54+
sizeLabel = 'size/S';
55+
} else if (totalChanges < 200) {
56+
sizeLabel = 'size/M';
57+
} else if (totalChanges < 500) {
58+
sizeLabel = 'size/L';
59+
} else {
60+
sizeLabel = 'size/XL';
61+
}
62+
63+
// Add new size label
64+
await github.rest.issues.addLabels({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
issue_number: pr.number,
68+
labels: [sizeLabel]
69+
});
70+
71+
core.info(`Added label: ${sizeLabel} (${totalChanges} changes)`);
72+
73+
- name: Label PR based on title
74+
uses: actions/github-script@v8
75+
with:
76+
script: |
77+
const pr = context.payload.pull_request;
78+
const title = pr.title.toLowerCase();
79+
80+
const labels = [];
81+
82+
// Conventional commit prefixes (case-insensitive with [] or () brackets)
83+
const patterns = {
84+
feat: /^(feat|FEAT)[\[:(]/,
85+
fix: /^(fix|FIX)[\[:(]/,
86+
docs: /^(docs|DOCS)[\[:(]/,
87+
test: /^(test|TEST|tests|TESTS)[\[:(]/,
88+
chore: /^(chore|CHORE)[\[:(]/,
89+
refactor: /^(refactor|REFACTOR)[\[:(]/,
90+
perf: /^(perf|PERF)[\[:(]/,
91+
style: /^(style|STYLE)[\[:(]/,
92+
ci: /^(ci|CI)[\[:(]/,
93+
};
94+
95+
if (patterns.feat.test(pr.title)) {
96+
labels.push('enhancement');
97+
} else if (patterns.fix.test(pr.title)) {
98+
labels.push('bug');
99+
} else if (patterns.docs.test(pr.title)) {
100+
labels.push('documentation');
101+
} else if (patterns.test.test(pr.title)) {
102+
labels.push('tests');
103+
} else if (patterns.chore.test(pr.title)) {
104+
labels.push('maintenance');
105+
} else if (patterns.refactor.test(pr.title)) {
106+
labels.push('refactor');
107+
} else if (patterns.perf.test(pr.title)) {
108+
labels.push('performance');
109+
} else if (patterns.ci.test(pr.title)) {
110+
labels.push('ci');
111+
}
112+
113+
// Keywords
114+
if (title.includes('breaking') || title.includes('breaking change')) {
115+
labels.push('breaking-change');
116+
}
117+
118+
if (title.includes('security')) {
119+
labels.push('security');
120+
}
121+
122+
// Add labels
123+
if (labels.length > 0) {
124+
await github.rest.issues.addLabels({
125+
owner: context.repo.owner,
126+
repo: context.repo.repo,
127+
issue_number: pr.number,
128+
labels: labels
129+
});
130+
131+
core.info(`Added labels: ${labels.join(', ')}`);
132+
}

0 commit comments

Comments
 (0)