Skip to content

Commit 96919a0

Browse files
authored
Merge pull request #17 from bug-ops/feature/improve-test-coverage
test: improve coverage to 83.78%
2 parents fd5db4f + b499086 commit 96919a0

File tree

4 files changed

+710
-0
lines changed

4 files changed

+710
-0
lines changed

.github/labeler.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# Auto-labeler configuration for feedparser-rs
2+
# Automatically adds labels to PRs based on changed files
3+
# https://github.com/actions/labeler
4+
5+
# Component labels - what part of the codebase is affected
6+
7+
'component: core':
8+
- changed-files:
9+
- any-glob-to-any-file:
10+
- 'crates/feedparser-rs-core/**/*'
11+
- '!crates/feedparser-rs-core/tests/**'
12+
- '!crates/feedparser-rs-core/benches/**'
13+
14+
'component: python':
15+
- changed-files:
16+
- any-glob-to-any-file:
17+
- 'crates/feedparser-rs-py/**/*'
18+
- '!crates/feedparser-rs-py/tests/**'
19+
20+
'component: node':
21+
- changed-files:
22+
- any-glob-to-any-file:
23+
- 'crates/feedparser-rs-node/**/*'
24+
- '!crates/feedparser-rs-node/__test__/**'
25+
26+
'component: tests':
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- 'crates/*/tests/**/*'
30+
- 'crates/**/benches/**/*'
31+
- 'tests/**/*'
32+
- '**/*_test.rs'
33+
- '**/*.test.{js,ts,py}'
34+
- '**/test_*.py'
35+
36+
'component: benchmarks':
37+
- changed-files:
38+
- any-glob-to-any-file:
39+
- 'crates/**/benches/**/*'
40+
- 'benches/**/*'
41+
42+
'component: ci':
43+
- changed-files:
44+
- any-glob-to-any-file:
45+
- '.github/workflows/**/*'
46+
- '.github/actions/**/*'
47+
- 'Makefile.toml'
48+
- 'deny.toml'
49+
- 'codecov.yml'
50+
- '.codecov.yml'
51+
52+
'component: dependencies':
53+
- changed-files:
54+
- any-glob-to-any-file:
55+
- '**/Cargo.toml'
56+
- '**/Cargo.lock'
57+
- '**/package.json'
58+
- '**/package-lock.json'
59+
- '**/pnpm-lock.yaml'
60+
- '**/pyproject.toml'
61+
- '**/requirements*.txt'
62+
- '**/poetry.lock'
63+
64+
# Type labels - what kind of change is this
65+
66+
'type: documentation':
67+
- changed-files:
68+
- any-glob-to-any-file:
69+
- '**/*.md'
70+
- 'docs/**/*'
71+
- '**/README*'
72+
- '**/CHANGELOG*'
73+
- '**/LICENSE*'
74+
- '**/CONTRIBUTING*'
75+
- '.github/ISSUE_TEMPLATE/**/*'
76+
- '.github/PULL_REQUEST_TEMPLATE*'
77+
78+
'type: build':
79+
- changed-files:
80+
- any-glob-to-any-file:
81+
- '**/Cargo.toml'
82+
- '**/build.rs'
83+
- '**/package.json'
84+
- '**/pyproject.toml'
85+
- 'Makefile*'
86+
- '**/Dockerfile'
87+
- '**/.dockerignore'
88+
89+
'type: tooling':
90+
- changed-files:
91+
- any-glob-to-any-file:
92+
- '.github/**/*'
93+
- '!.github/ISSUE_TEMPLATE/**/*'
94+
- '!.github/PULL_REQUEST_TEMPLATE*'
95+
- 'rustfmt.toml'
96+
- '.rustfmt.toml'
97+
- 'clippy.toml'
98+
- '.clippy.toml'
99+
- '.editorconfig'
100+
- '.gitignore'
101+
- '.gitattributes'
102+
- 'deny.toml'
103+
104+
# Area labels - which part of the functionality
105+
106+
'area: parser':
107+
- changed-files:
108+
- any-glob-to-any-file:
109+
- 'crates/feedparser-rs-core/src/parser/**/*'
110+
- 'crates/feedparser-rs-core/src/**/parse*.rs'
111+
112+
'area: rss':
113+
- changed-files:
114+
- any-glob-to-any-file:
115+
- '**/*rss*.rs'
116+
- 'tests/fixtures/rss/**/*'
117+
118+
'area: atom':
119+
- changed-files:
120+
- any-glob-to-any-file:
121+
- '**/*atom*.rs'
122+
- 'tests/fixtures/atom/**/*'
123+
124+
'area: json-feed':
125+
- changed-files:
126+
- any-glob-to-any-file:
127+
- '**/*json*.rs'
128+
- 'tests/fixtures/json/**/*'
129+
130+
'area: error-handling':
131+
- changed-files:
132+
- any-glob-to-any-file:
133+
- '**/error*.rs'
134+
- '**/*error.rs'
135+
136+
'area: date-parsing':
137+
- changed-files:
138+
- any-glob-to-any-file:
139+
- '**/date*.rs'
140+
- '**/*date*.rs'
141+
142+
'area: sanitization':
143+
- changed-files:
144+
- any-glob-to-any-file:
145+
- '**/sanitize*.rs'
146+
- '**/*sanitize*.rs'
147+
148+
'area: encoding':
149+
- changed-files:
150+
- any-glob-to-any-file:
151+
- '**/encoding*.rs'
152+
- '**/*encoding*.rs'
153+
154+
'area: performance':
155+
- changed-files:
156+
- any-glob-to-any-file:
157+
- 'crates/**/benches/**/*'
158+
- '**/bench*.rs'
159+
- '**/perf*.rs'
160+
161+
'area: security':
162+
- changed-files:
163+
- any-glob-to-any-file:
164+
- 'deny.toml'
165+
- 'SECURITY.md'
166+
- '**/sanitize*.rs'
167+
168+
# Language-specific
169+
170+
'lang: rust':
171+
- changed-files:
172+
- any-glob-to-any-file:
173+
- '**/*.rs'
174+
- '**/Cargo.toml'
175+
- 'rustfmt.toml'
176+
- 'clippy.toml'
177+
178+
'lang: python':
179+
- changed-files:
180+
- any-glob-to-any-file:
181+
- '**/*.py'
182+
- '**/pyproject.toml'
183+
- '**/requirements*.txt'
184+
- '**/.python-version'
185+
186+
'lang: javascript':
187+
- changed-files:
188+
- any-glob-to-any-file:
189+
- '**/*.{js,ts,mjs,cjs}'
190+
- '**/package.json'
191+
- '**/tsconfig.json'
192+
- '**/.npmrc'

.github/workflows/labeler.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Auto Label PR
2+
3+
# Automatically add labels to pull requests based on changed files
4+
# Uses the labeler.yml configuration file
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
on:
11+
pull_request_target:
12+
types: [opened, synchronize, reopened]
13+
14+
jobs:
15+
label:
16+
name: Label PR
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 5
19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
23+
steps:
24+
- name: Auto-label based on changed files
25+
uses: actions/labeler@v5
26+
with:
27+
repo-token: ${{ secrets.GITHUB_TOKEN }}
28+
configuration-path: .github/labeler.yml
29+
sync-labels: false # Don't remove labels
30+
31+
- name: Add size label
32+
uses: actions/github-script@v7
33+
with:
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
35+
script: |
36+
const pr = context.payload.pull_request;
37+
const additions = pr.additions;
38+
const deletions = pr.deletions;
39+
const totalChanges = additions + deletions;
40+
41+
// Calculate size category
42+
let sizeLabel = '';
43+
if (totalChanges < 10) {
44+
sizeLabel = 'size: XS';
45+
} else if (totalChanges < 50) {
46+
sizeLabel = 'size: S';
47+
} else if (totalChanges < 200) {
48+
sizeLabel = 'size: M';
49+
} else if (totalChanges < 500) {
50+
sizeLabel = 'size: L';
51+
} else if (totalChanges < 1000) {
52+
sizeLabel = 'size: XL';
53+
} else {
54+
sizeLabel = 'size: XXL';
55+
}
56+
57+
// Remove old size labels
58+
const currentLabels = await github.rest.issues.listLabelsOnIssue({
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
issue_number: pr.number
62+
});
63+
64+
const sizeLabels = currentLabels.data
65+
.map(label => label.name)
66+
.filter(name => name.startsWith('size: '));
67+
68+
for (const label of sizeLabels) {
69+
if (label !== sizeLabel) {
70+
await github.rest.issues.removeLabel({
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
issue_number: pr.number,
74+
name: label
75+
});
76+
}
77+
}
78+
79+
// Add new size label
80+
if (!sizeLabels.includes(sizeLabel)) {
81+
await github.rest.issues.addLabels({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
issue_number: pr.number,
85+
labels: [sizeLabel]
86+
});
87+
}
88+
89+
// Log the changes
90+
console.log(`PR #${pr.number}: +${additions} -${deletions} = ${totalChanges} changes → ${sizeLabel}`);

0 commit comments

Comments
 (0)