Skip to content

Commit 87b4e12

Browse files
vaindclaude
andcommitted
feat: improve Danger testing and conventional commit scope handling
- Add comprehensive testing infrastructure with 23 test cases - Fix scope handling for conventional commits (feat(core): -> feat) - Properly classify ref commits as internal changes - Add modular architecture with testable functions - Include CI integration for JavaScript testing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 115b0fb commit 87b4e12

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66

7+
- Danger - Improve testing infrastructure and conventional commit scope handling ([#105](https://github.com/getsentry/github-workflows/pull/105))
78
- Add Proguard artifact endpoint for Android builds in sentry-server ([#100](https://github.com/getsentry/github-workflows/pull/100))
89

910
### Security

danger/dangerfile-utils.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ const FLAVOR_CONFIG = [
77
},
88
{
99
labels: ["fix", "bug", "bugfix"],
10-
changelog: "Bug Fixes" // More standard than "Fixes"
11-
},
12-
{
13-
labels: ["ref"], // Very common in Sentry repos (14 occurrences)
14-
changelog: "Changes"
10+
changelog: "Fixes"
1511
},
1612
{
1713
labels: ["sec", "security"],
@@ -22,17 +18,35 @@ const FLAVOR_CONFIG = [
2218
changelog: "Performance"
2319
},
2420
{
25-
labels: ["docs", "doc", "style", "refactor", "tests", "test", "build", "ci", "chore", "meta", "deps", "dep", "chore(deps)", "build(deps)"],
26-
changelog: undefined // Internal changes - no changelog needed
21+
// Internal changes - no changelog needed
22+
changelog: undefined,
23+
labels: [
24+
"docs",
25+
"doc",
26+
"style",
27+
"ref",
28+
"refactor",
29+
"tests",
30+
"test",
31+
"build",
32+
"ci",
33+
"chore",
34+
"meta",
35+
"deps",
36+
"dep"
37+
]
2738
}
2839
];
2940

3041
/// Get flavor configuration for a given PR flavor
3142
function getFlavorConfig(prFlavor) {
3243
const normalizedFlavor = prFlavor.toLowerCase().trim();
3344

45+
// Strip scope/context from conventional commit format: "type(scope)" -> "type"
46+
const baseType = normalizedFlavor.replace(/\([^)]*\)/, '');
47+
3448
const config = FLAVOR_CONFIG.find(config =>
35-
config.labels.includes(normalizedFlavor)
49+
config.labels.includes(normalizedFlavor) || config.labels.includes(baseType)
3650
);
3751

3852
return config || {

danger/dangerfile-utils.test.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ describe('dangerfile-utils', () => {
1616

1717
it('should return config for fixes without isFeature', () => {
1818
const fixConfig = getFlavorConfig('fix');
19-
assert.strictEqual(fixConfig.changelog, 'Bug Fixes');
19+
assert.strictEqual(fixConfig.changelog, 'Fixes');
2020
assert.strictEqual(fixConfig.isFeature, undefined);
2121

2222
const bugConfig = getFlavorConfig('bug');
23-
assert.strictEqual(bugConfig.changelog, 'Bug Fixes');
23+
assert.strictEqual(bugConfig.changelog, 'Fixes');
2424
assert.strictEqual(bugConfig.isFeature, undefined);
2525

2626
const bugfixConfig = getFlavorConfig('bugfix');
27-
assert.strictEqual(bugfixConfig.changelog, 'Bug Fixes');
27+
assert.strictEqual(bugfixConfig.changelog, 'Fixes');
2828
assert.strictEqual(bugfixConfig.isFeature, undefined);
2929
});
3030

@@ -53,7 +53,7 @@ describe('dangerfile-utils', () => {
5353
assert.strictEqual(config1.changelog, 'Features');
5454

5555
const config2 = getFlavorConfig(' fix ');
56-
assert.strictEqual(config2.changelog, 'Bug Fixes');
56+
assert.strictEqual(config2.changelog, 'Fixes');
5757
});
5858

5959
it('should handle all security-related flavors', () => {
@@ -72,11 +72,24 @@ describe('dangerfile-utils', () => {
7272
assert.strictEqual(performanceConfig.changelog, 'Performance');
7373
});
7474

75-
it('should handle ref flavor (common in Sentry repos)', () => {
75+
it('should handle ref flavor (internal changes - no changelog)', () => {
7676
const refConfig = getFlavorConfig('ref');
77-
assert.strictEqual(refConfig.changelog, 'Changes');
77+
assert.strictEqual(refConfig.changelog, undefined);
7878
assert.strictEqual(refConfig.isFeature, undefined);
7979
});
80+
81+
it('should handle scoped flavors by stripping scope', () => {
82+
const scopedFeat = getFlavorConfig('feat(core)');
83+
assert.strictEqual(scopedFeat.changelog, 'Features');
84+
assert.strictEqual(scopedFeat.isFeature, true);
85+
86+
const scopedFix = getFlavorConfig('fix(browser)');
87+
assert.strictEqual(scopedFix.changelog, 'Fixes');
88+
assert.strictEqual(scopedFix.isFeature, undefined);
89+
90+
const scopedChore = getFlavorConfig('chore(deps)');
91+
assert.strictEqual(scopedChore.changelog, undefined);
92+
});
8093
});
8194

8295
describe('extractPRFlavor', () => {

0 commit comments

Comments
 (0)