Skip to content

Commit 12b19ce

Browse files
Implement makeLatest input for GitHubRelease task (#21497)
* Implement makeLatest input for GitHubRelease task - Added new input option 'makeLatest' to specify if the release should be marked as the latest release. - Bump dependencies in package.json and package-lock.json: - Updated azure-pipelines-tasks-utility-common to version 3.266.0 - Updated brace-expansion to version 1.1.12 - Increment task version to 1.266 in task.json and task.loc.json * Add test coverage for all makeLatest values in GitHubRelease task (#21498) * Initial plan * Add test coverage for all makeLatest values (true, false, legacy) Co-authored-by: ivanduplenskikh <115665590+ivanduplenskikh@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ivanduplenskikh <115665590+ivanduplenskikh@users.noreply.github.com> * Remove done callbacks * Update unit tests * Update jsdocs --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent ef41802 commit 12b19ce

23 files changed

+366
-593
lines changed

Tasks/GitHubReleaseV1/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
"loc.input.help.isDraft": "Indicate whether the release should be saved as a draft (unpublished). If `false`, the release will be published.",
3535
"loc.input.label.isPreRelease": "Pre-release",
3636
"loc.input.help.isPreRelease": "Indicate whether the release should be marked as a pre-release.",
37+
"loc.input.label.makeLatest": "Make Latest",
38+
"loc.input.help.makeLatest": "Specify whether to designate this release as the 'latest' release for the repository. Set to 'false' to prevent marking this release as latest, or 'legacy' to use GitHub's legacy latest-release determination based on creation date and semantic versioning.",
3739
"loc.input.label.addChangeLog": "Add changelog",
3840
"loc.input.help.addChangeLog": "If set to `true`, a list of changes (commits and issues) between this and the last published release will be generated and appended to the release notes.",
3941
"loc.input.label.changeLogCompareToRelease": "Compare to",

Tasks/GitHubReleaseV1/Tests/ActionL0Tests.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,41 @@ export class ActionL0Tests {
44

55
public static async startTests() {
66
await this.validateCreateReleaseAction();
7+
await this.validateCreateReleaseActionWithMakeLatestTrue();
8+
await this.validateCreateReleaseActionWithMakeLatestLegacy();
79
await this.validateEditReleaseAction();
10+
await this.validateEditReleaseActionWithMakeLatestTrue();
11+
await this.validateEditReleaseActionWithMakeLatestLegacy();
812
await this.validateDeleteReleaseAction();
913
}
1014

1115
public static async validateCreateReleaseAction() {
12-
await new Action().createReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, []);
16+
await new Action().createReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, [], "false");
17+
}
18+
19+
public static async validateCreateReleaseActionWithMakeLatestTrue() {
20+
await new Action().createReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, [], "true");
21+
}
22+
23+
public static async validateCreateReleaseActionWithMakeLatestLegacy() {
24+
await new Action().createReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, [], "legacy");
1325
}
1426

1527
public static async validateEditReleaseAction() {
16-
await new Action().editReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, [], "id");
28+
await new Action().editReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, [], "id", "false");
29+
}
30+
31+
public static async validateEditReleaseActionWithMakeLatestTrue() {
32+
await new Action().editReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, [], "id", "true");
33+
}
34+
35+
public static async validateEditReleaseActionWithMakeLatestLegacy() {
36+
await new Action().editReleaseAction("endpoint", "repo", "target", "tagName", "title", "note", false, false, [], "id", "legacy");
1737
}
1838

1939
public static async validateDeleteReleaseAction() {
2040
await new Action().deleteReleaseAction("endpoint", "repo", "tag");
2141
}
22-
2342
}
2443

2544
ActionL0Tests.startTests();

Tasks/GitHubReleaseV1/Tests/ActionTests.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import tmrm = require('azure-pipelines-task-lib/mock-run');
21
import * as path from 'path';
3-
import * as sinon from 'sinon';
2+
3+
import tmrm = require('azure-pipelines-task-lib/mock-run');
4+
45
import { Inputs } from '../operations/Constants';
56

67
export class ActionTests {
78

89
public static startTest() {
910
let tp = path.join(__dirname, 'ActionL0Tests.js');
1011
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
11-
12+
1213
tr.setInput(Inputs.assetUploadMode, "replace");
1314

1415
this.stub(tr);
15-
16+
1617
tr.run();
1718
}
1819

@@ -46,7 +47,7 @@ export class ActionTests {
4647
}
4748
}
4849
});
49-
50+
5051
tr.registerMock("./Helper", {
5152
Helper: function () {
5253
return {
@@ -57,7 +58,7 @@ export class ActionTests {
5758
}
5859
});
5960
}
60-
61+
6162
}
6263

6364
ActionTests.startTest();

Tasks/GitHubReleaseV1/Tests/ChangeLogL0Tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChangeLog } from "../operations/ChangeLog";
2-
import { TestString } from "./TestStrings";
32
import { ChangeLogStartCommit } from "../operations/Utility";
3+
import { TestString } from "./TestStrings";
44

55
export class ChangeLogL0Tests {
66
public static async startTests() {
@@ -14,7 +14,7 @@ export class ChangeLogL0Tests {
1414

1515
public static async validateGetChangeLog1() {
1616
let changes = await new ChangeLog().getChangeLog("endpoint", "owner/repo", "target", 250, ChangeLogStartCommit.lastFullRelease, "commitBased");
17-
17+
1818
if (changes === this.expectedCommitBasedChanges) {
1919
console.log(TestString.getChangeLogKeyword);
2020
}
@@ -55,7 +55,7 @@ export class ChangeLogL0Tests {
5555
public static readonly expectedCommitBasedChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n* xyz Fixing issue #56. [ #9 ]\n* abc Fixing issue #2 #3. [ #4, #5 ]\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
5656
public static readonly expectedAllIssuesChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n* #1: Incorrect color contrast in control panel\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
5757
public static readonly expectedIssueBasedChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n\n### Closed UX Issues/PRs:\n\n\n* #1: Incorrect color contrast in control panel\n\n### Open Bugs:\n\n\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
58-
58+
5959
}
6060

6161
ChangeLogL0Tests.startTests();

Tasks/GitHubReleaseV1/Tests/ChangeLogTests.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import tmrm = require('azure-pipelines-task-lib/mock-run');
21
import * as path from 'path';
3-
import { Inputs } from '../operations/Constants';
4-
import * as sinon from 'sinon';
2+
3+
import tmrm = require('azure-pipelines-task-lib/mock-run');
54

65
export class ChangeLogTests {
76

87
public static startTest() {
98
let tp = path.join(__dirname, 'ChangeLogL0Tests.js');
109
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
1110

12-
process.env["RELEASE_RELEASEWEBURL"] = "MOCK_RELEASE_URL";
13-
11+
process.env["RELEASE_RELEASEWEBURL"] = "MOCK_RELEASE_URL";
12+
1413
// Stub methods
1514
this.stub(tr);
16-
17-
// Run the main.js
15+
16+
// Run the main.js
1817
tr.run();
1918
}
2019

@@ -63,7 +62,7 @@ export class ChangeLogTests {
6362
getCommitsList: function() {
6463
return {
6564
statusCode: 200,
66-
body: { "commits": [
65+
body: { "commits": [
6766
{"sha": "abc", "commit": { "message": "Fixing issue #2 #3.\n\n desc #4 GH-5" } },
6867
{"sha": "xyz", "commit": { "message": "Fixing issue #56.\n\n desc Gh-9" } }
6968
] }

Tasks/GitHubReleaseV1/Tests/CreateAction2L0Tests.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
1-
import tmrm = require('azure-pipelines-task-lib/mock-run');
21
import * as path from 'path';
3-
import { Inputs } from '../operations/Constants';
2+
3+
import tmrm = require('azure-pipelines-task-lib/mock-run');
44
import * as sinon from 'sinon';
55

6+
import { Inputs } from '../operations/Constants';
7+
68
export class CreateAction2L0Tests {
7-
9+
810
public static startTest() {
911
let tp = path.join(__dirname, '..', 'main.js');
1012
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
11-
13+
1214
tr.setInput(Inputs.gitHubConnection, "connection");
1315
tr.setInput(Inputs.repositoryName, "repo");
1416
tr.setInput(Inputs.action, "create");
1517
tr.setInput(Inputs.tagSource, "gitTag");
1618
tr.setInput(Inputs.target, "master");
1719
tr.setInput(Inputs.releaseNotesSource, "inline");
18-
20+
1921
this.stub(tr);
2022
tr.run();
2123

2224
this.sandbox.restore();
2325
}
24-
26+
2527
public static stub(tr) {
2628
this.sandbox = sinon.sandbox.create();
27-
29+
2830
var Utility = require('../operations/Utility');
2931
this.sandbox.stub(Utility.Utility, "getGithubEndPointToken").callsFake(function() { return { scheme: 'OAuth', parameters: { AccessToken: "**someToken**"}} });
30-
32+
3133
tr.registerMock("./operations/Helper", {
3234
Helper: function () {
3335
return {
@@ -39,9 +41,9 @@ export class CreateAction2L0Tests {
3941
}
4042
}
4143
}
42-
});
44+
});
4345
}
44-
46+
4547
public static sandbox;
4648
}
4749

Tasks/GitHubReleaseV1/Tests/CreateActionL0Tests.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1-
import tmrm = require('azure-pipelines-task-lib/mock-run');
21
import * as path from 'path';
3-
import { Inputs } from '../operations/Constants';
2+
3+
import tmrm = require('azure-pipelines-task-lib/mock-run');
44
import * as sinon from 'sinon';
55

6+
import { Inputs } from '../operations/Constants';
7+
68
export class CreateActionL0Tests {
7-
9+
810
public static startTest() {
911
let tp = path.join(__dirname, '..', 'main.js');
1012
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
11-
13+
1214
tr.setInput(Inputs.gitHubConnection, "connection");
1315
tr.setInput(Inputs.repositoryName, "repo");
1416
tr.setInput(Inputs.action, "create");
1517
tr.setInput(Inputs.tagSource, "userSpecifiedTag");
1618
tr.setInput(Inputs.tag, "tag");
1719
tr.setInput(Inputs.target, "master");
1820
tr.setInput(Inputs.releaseNotesSource, "inline");
19-
21+
2022
this.stub(tr);
2123
tr.run();
2224

2325
this.sandbox.restore();
2426
}
25-
27+
2628
public static stub(tr) {
2729
this.sandbox = sinon.sandbox.create();
28-
30+
2931
var Utility = require('../operations/Utility');
3032
this.sandbox.stub(Utility.Utility, "getGithubEndPointToken").callsFake(function() { return { scheme: 'OAuth', parameters: { AccessToken: "**someToken**"}} });
31-
33+
3234
tr.registerMock("./operations/Helper", {
3335
Helper: function () {
3436
return {
@@ -51,9 +53,9 @@ export class CreateActionL0Tests {
5153
}
5254
}
5355
});
54-
56+
5557
}
56-
58+
5759
public static sandbox;
5860
}
5961

Tasks/GitHubReleaseV1/Tests/DeleteAction2L0Tests.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import tmrm = require('azure-pipelines-task-lib/mock-run');
21
import * as path from 'path';
3-
import { Inputs } from '../operations/Constants';
2+
3+
import tmrm = require('azure-pipelines-task-lib/mock-run');
44
import * as sinon from 'sinon';
5+
6+
import { Inputs } from '../operations/Constants';
57
import { TestString } from './TestStrings';
68

79
export class DeleteAction2L0Tests {
810

911
public static startTest() {
1012
let tp = path.join(__dirname, '..', 'main.js');
1113
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
12-
14+
1315
// Set the input
1416
tr.setInput(Inputs.gitHubConnection, "connection");
1517
tr.setInput(Inputs.repositoryName, "repo");
@@ -18,8 +20,8 @@ export class DeleteAction2L0Tests {
1820

1921
// Stub methods
2022
this.stub();
21-
22-
// Run the main.js
23+
24+
// Run the main.js
2325
tr.run();
2426

2527
// Restore all stubs
@@ -31,11 +33,11 @@ export class DeleteAction2L0Tests {
3133

3234
var Utility = require('../operations/Utility');
3335
this.sandbox.stub(Utility.Utility, "getGithubEndPointToken").callsFake(function() { return { scheme: 'OAuth', parameters: { AccessToken: "**someToken**"}} });
34-
36+
3537
var Action = require('../operations/Action');
3638
this.sandbox.stub(Action.Action.prototype, "deleteReleaseAction").callsFake(() => { console.log(TestString.deleteAction2KeyWord) });
3739
}
38-
40+
3941
public static sandbox;
4042
}
4143

Tasks/GitHubReleaseV1/Tests/DeleteActionL0Tests.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import tmrm = require('azure-pipelines-task-lib/mock-run');
21
import * as path from 'path';
3-
import { Inputs } from '../operations/Constants';
2+
3+
import tmrm = require('azure-pipelines-task-lib/mock-run');
44
import * as sinon from 'sinon';
5+
6+
import { Inputs } from '../operations/Constants';
57
import { TestString } from './TestStrings';
68

79
export class DeleteActionL0Tests {
810

911
public static startTest() {
1012
let tp = path.join(__dirname, '..', 'main.js');
1113
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
12-
14+
1315
// Set the input
1416
tr.setInput(Inputs.gitHubConnection, "connection");
1517
tr.setInput(Inputs.repositoryName, "repo");
@@ -18,8 +20,8 @@ export class DeleteActionL0Tests {
1820

1921
// Stub methods
2022
this.stub();
21-
22-
// Run the main.js
23+
24+
// Run the main.js
2325
tr.run();
2426

2527
// Restore all stubs
@@ -31,11 +33,11 @@ export class DeleteActionL0Tests {
3133

3234
var Utility = require('../operations/Utility');
3335
this.sandbox.stub(Utility.Utility, "getGithubEndPointToken").callsFake(function() { return { scheme: 'OAuth', parameters: { AccessToken: "**someToken**"}} });
34-
36+
3537
var Action = require('../operations/Action');
3638
this.sandbox.stub(Action.Action.prototype, "deleteReleaseAction").callsFake(() => { console.log(TestString.deleteActionKeyWord) });
3739
}
38-
40+
3941
public static sandbox;
4042
}
4143

0 commit comments

Comments
 (0)