Skip to content

Commit b33df59

Browse files
Fix version calculation based on PR labels (#1258)
* Fix version calulation based on PR labels * Update .github/scripts/release.test.js Co-authored-by: Michael Paul <michael.paul@adyen.com> --------- Co-authored-by: Michael Paul <michael.paul@adyen.com>
1 parent e9e798f commit b33df59

File tree

2 files changed

+210
-3
lines changed

2 files changed

+210
-3
lines changed

.github/scripts/release.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ exports.detectChanges = (changeset) => {
113113
break;
114114
case 'breaking-change':
115115
increment = 'major';
116-
break;
116+
return increment;
117117
}
118118
}
119119
}

.github/scripts/release.test.js

Lines changed: 209 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,195 @@ const comparisonFixture = {
112112
}
113113
};
114114

115+
const associatedPullRequestsMajor = {
116+
"repository": {
117+
"name": "adyen-node-api-library",
118+
"ref": {
119+
"compare": {
120+
"aheadBy": 8,
121+
"commits": {
122+
"edges": [
123+
{
124+
"node": {
125+
"message": "Another commit in the same PR non squashed",
126+
"associatedPullRequests": {
127+
"edges": [
128+
{
129+
"node": {
130+
"number": 20,
131+
"labels": {
132+
"nodes": [
133+
{
134+
"name": "Breaking change"
135+
}
136+
]
137+
}
138+
}
139+
}
140+
]
141+
}
142+
}
143+
},
144+
{
145+
"node": {
146+
"message": "Fixing the constructor",
147+
"associatedPullRequests": {
148+
"edges": [
149+
{
150+
"node": {
151+
"number": 10,
152+
"labels": {
153+
"nodes": [
154+
{
155+
"name": "Fix"
156+
}
157+
]
158+
}
159+
}
160+
}
161+
]
162+
}
163+
}
164+
},
165+
{
166+
"node": {
167+
"message": "Upgrade some service",
168+
"associatedPullRequests": {
169+
"edges": [
170+
{
171+
"node": {
172+
"number": 20,
173+
"labels": {
174+
"nodes": [
175+
{
176+
"name": "Feature"
177+
}
178+
]
179+
}
180+
}
181+
}
182+
]
183+
}
184+
}
185+
},
186+
{
187+
"node": {
188+
"message": "Update CODEOWNERS (#965)",
189+
"associatedPullRequests": {
190+
"edges": [
191+
{
192+
"node": {
193+
"number": 30,
194+
"labels": {
195+
"nodes": []
196+
}
197+
}
198+
}
199+
]
200+
}
201+
}
202+
}
203+
]
204+
}
205+
}
206+
}
207+
}
208+
};
209+
210+
const associatedPullRequestsMinor = {
211+
"repository": {
212+
"name": "adyen-node-api-library",
213+
"ref": {
214+
"compare": {
215+
"aheadBy": 8,
216+
"commits": {
217+
"edges": [
218+
{
219+
"node": {
220+
"message": "Another commit in the same PR non squashed",
221+
"associatedPullRequests": {
222+
"edges": [
223+
{
224+
"node": {
225+
"number": 20,
226+
"labels": {
227+
"nodes": [
228+
{
229+
"name": ""
230+
}
231+
]
232+
}
233+
}
234+
}
235+
]
236+
}
237+
}
238+
},
239+
{
240+
"node": {
241+
"message": "Fixing the constructor",
242+
"associatedPullRequests": {
243+
"edges": [
244+
{
245+
"node": {
246+
"number": 10,
247+
"labels": {
248+
"nodes": [
249+
{
250+
"name": "Feature"
251+
}
252+
]
253+
}
254+
}
255+
}
256+
]
257+
}
258+
}
259+
},
260+
{
261+
"node": {
262+
"message": "Upgrade some service",
263+
"associatedPullRequests": {
264+
"edges": [
265+
{
266+
"node": {
267+
"number": 20,
268+
"labels": {
269+
"nodes": [
270+
{
271+
"name": "Fix"
272+
}
273+
]
274+
}
275+
}
276+
}
277+
]
278+
}
279+
}
280+
},
281+
{
282+
"node": {
283+
"message": "Update CODEOWNERS (#965)",
284+
"associatedPullRequests": {
285+
"edges": [
286+
{
287+
"node": {
288+
"number": 30,
289+
"labels": {
290+
"nodes": []
291+
}
292+
}
293+
}
294+
]
295+
}
296+
}
297+
}
298+
]
299+
}
300+
}
301+
}
302+
}
303+
};
115304
beforeEach(() => {
116305
// Reset env variables
117306
delete process.env.CURRENT_VERSION;
@@ -134,7 +323,7 @@ test('Detect changes', async t => {
134323

135324
assert.strictEqual(ver, 'major');
136325
});
137-
326+
138327
await t.test('Zero changes', t => {
139328
let sync = structuredClone(comparisonFixture);
140329
sync.repository.ref.compare.aheadBy = 0;
@@ -158,6 +347,7 @@ test('Detect changes', async t => {
158347
});
159348
});
160349

350+
161351
test('Get next version', async t => {
162352
await t.test('Major', async t => {
163353
const ver = release.nextVersion('13.1.2', 'major');
@@ -229,4 +419,21 @@ test('Bump', async t => {
229419
await release.bump(options);
230420

231421
assert.strictEqual(core.setOutput.mock.calls.length, 3);
232-
});
422+
});
423+
424+
425+
test('Calculate version major', async t => {
426+
await t.test('Major', t => {
427+
const ver = release.detectChanges(associatedPullRequestsMajor);
428+
429+
assert.strictEqual(ver, 'major');
430+
})
431+
});
432+
433+
test('Calculate version minor', async t => {
434+
await t.test('Minor', t => {
435+
const ver = release.detectChanges(associatedPullRequestsMinor);
436+
437+
assert.strictEqual(ver, 'minor');
438+
});
439+
});

0 commit comments

Comments
 (0)