Skip to content

Commit f6b4edd

Browse files
Add latest-including-prerelease option (#137)
* add latest-including-prerelease option * Update integ-test-promote-template.yml * add release status to prerelease install * fix integ test version * update task description * fix integ test * fix integ test
1 parent d782250 commit f6b4edd

File tree

6 files changed

+85
-11
lines changed

6 files changed

+85
-11
lines changed

integ-test-promote-template.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ jobs:
6060
inputs:
6161
command: assert(strcmp(version('-release'),'2023a'))
6262

63+
- job: test_install_latest_including_prerelease_v${{ version }}
64+
condition: not(eq(${{ version }}, '0'))
65+
strategy:
66+
matrix:
67+
microsoft_hosted_linux:
68+
poolName: Azure Pipelines
69+
vmImage: ubuntu-22.04
70+
pool:
71+
name: $(poolName)
72+
vmImage: $(vmImage)
73+
steps:
74+
- checkout: none
75+
- task: MathWorks.matlab-azure-devops-extension-dev.InstallMATLAB.InstallMATLAB@${{ version }}
76+
displayName: Install MATLAB
77+
inputs:
78+
release: latest-including-prerelease
79+
- task: MathWorks.matlab-azure-devops-extension-dev.RunMATLABCommand.RunMATLABCommand@${{ version }}
80+
displayName: Print MATLAB version
81+
inputs:
82+
command: version
83+
6384
- job: test_run_command_v${{ version }}
6485
strategy:
6586
matrix:

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/install-matlab/v1/src/matlab.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface Release {
1212
name: string;
1313
version: string;
1414
update: string;
15+
isPrerelease: boolean;
1516
}
1617

1718
export async function makeToolcacheDir(release: Release, platform: string): Promise<[string, boolean]> {
@@ -66,8 +67,11 @@ async function windowsHostedToolpath(release: Release): Promise<string> {
6667
export async function getReleaseInfo(release: string): Promise<Release> {
6768
// Get release name from input parameter
6869
let name: string;
70+
let isPrerelease: boolean = false;
6971
if (release.toLowerCase().trim() === "latest") {
70-
name = await resolveLatest();
72+
name = await fetchReleaseInfo("latest");
73+
} else if (release.toLowerCase().trim() === "latest-including-prerelease") {
74+
name = await fetchReleaseInfo("latest-including-prerelease");
7175
} else {
7276
const nameMatch = release.toLowerCase().match(/r[0-9]{4}[a-b]/);
7377
if (!nameMatch) {
@@ -88,18 +92,24 @@ export async function getReleaseInfo(release: string): Promise<Release> {
8892
} else {
8993
update = "Latest";
9094
version += ".999";
95+
if (name.includes("prerelease")) {
96+
name = name.replace("prerelease", "");
97+
version += "-prerelease";
98+
isPrerelease = true;
99+
}
91100
}
92101

93102
return {
94103
name,
95104
version,
96105
update,
106+
isPrerelease,
97107
};
98108
}
99109

100-
async function resolveLatest(): Promise<string> {
110+
async function fetchReleaseInfo(name: string): Promise<string> {
101111
return new Promise((resolve, reject) => {
102-
https.get("https://ssd.mathworks.com/supportfiles/ci/matlab-release/v0/latest", (resp) => {
112+
https.get(`https://ssd.mathworks.com/supportfiles/ci/matlab-release/v0/${name}`, (resp) => {
103113
if (resp.statusCode !== 200) {
104114
reject(Error(`Unable to retrieve latest MATLAB release information. Contact MathWorks at [email protected] if the problem persists.`));
105115
}
@@ -108,6 +118,7 @@ async function resolveLatest(): Promise<string> {
108118
});
109119
});
110120
});
121+
111122
}
112123

113124
export async function setupBatch(platform: string, architecture: string) {

tasks/install-matlab/v1/src/mpm.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ export async function install(
5858
"install",
5959
`--release=${release.name + release.update}`,
6060
`--destination=${destination}`,
61-
"--products",
6261
];
62+
63+
if (release.isPrerelease) {
64+
mpmArguments = mpmArguments.concat("--release-status=Prerelease");
65+
}
66+
mpmArguments = mpmArguments.concat("--products");
6367
mpmArguments = mpmArguments.concat(parsedProducts);
6468

6569
const exitCode = await taskLib.exec(mpmPath, mpmArguments);

tasks/install-matlab/v1/test/matlab.test.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default function suite() {
2626
name: "r2023b",
2727
version: "2023.2.999",
2828
update: "Latest",
29+
isPrerelease: false,
2930
};
3031

3132
beforeEach(() => {
@@ -300,26 +301,43 @@ export default function suite() {
300301
mockResp.statusCode = 200;
301302
stubHttpsGet.callsFake((url, callback) => {
302303
callback(mockResp);
303-
mockResp.emit("data", "r2022b");
304+
mockResp.emit("data", "r2024b");
304305
mockResp.emit("end");
305306
return Promise.resolve(null);
306307
});
307308
const release = await matlab.getReleaseInfo("latest");
308-
assert(release.name === "r2022b");
309+
assert(release.name === "r2024b");
310+
assert(release.isPrerelease === false);
311+
});
312+
313+
it("getReleaseInfo resolves latest-including-prerelease", async () => {
314+
const mockResp = new http.IncomingMessage(new net.Socket());
315+
mockResp.statusCode = 200;
316+
stubHttpsGet.callsFake((url, callback) => {
317+
callback(mockResp);
318+
mockResp.emit("data", "r2025aprerelease");
319+
mockResp.emit("end");
320+
return Promise.resolve(null);
321+
});
322+
const release = await matlab.getReleaseInfo("latest");
323+
assert(release.name === "r2025a");
324+
assert(release.isPrerelease === true);
309325
});
310326

311327
it("getReleaseInfo is case insensitive", async () => {
312328
const release = await matlab.getReleaseInfo("R2022B");
313329
assert(release.name === "r2022b");
314330
assert(release.version === "2022.2.999");
315331
assert(release.update === "Latest");
332+
assert(release.isPrerelease === false);
316333
});
317334

318335
it("getReleaseInfo allows specifying update number", async () => {
319336
const release = await matlab.getReleaseInfo("R2022au2");
320337
assert(release.name === "r2022a");
321338
assert(release.version === "2022.1.2");
322339
assert(release.update === "u2");
340+
assert(release.isPrerelease === false);
323341
});
324342

325343
it("getReleaseInfo rejects for invalid release input", async () => {

tasks/install-matlab/v1/test/mpm.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default function suite() {
116116

117117
it("install ideally works", async () => {
118118
const mpmPath = "mpm";
119-
const releaseInfo = {name: "r2022b", version: "9.13.0", update: "Latest"};
119+
const releaseInfo = {name: "r2022b", version: "9.13.0", update: "Latest", isPrerelease: false};
120120
const destination = "/opt/matlab";
121121
const products = "MATLAB Compiler";
122122
const expectedMpmArgs = [
@@ -133,9 +133,29 @@ export default function suite() {
133133
});
134134
});
135135

136+
it("add --release-status flag for prerelease", async () => {
137+
const mpmPath = "mpm";
138+
const releaseInfo = {name: "r2025a", version: "9.13.0", update: "Latest", isPrerelease: true};
139+
const destination = "/opt/matlab";
140+
const products = "MATLAB Compiler";
141+
const expectedMpmArgs = [
142+
"install",
143+
"--release=r2025aLatest",
144+
`--destination=${destination}`,
145+
"--release-status=Prerelease",
146+
"--products",
147+
"MATLAB",
148+
"Compiler",
149+
];
150+
assert.doesNotReject(async () => { mpm.install(mpmPath, releaseInfo, products, destination); });
151+
mpm.install(mpmPath, releaseInfo, destination, products).then(() => {
152+
assert(stubExec.calledWithMatch(mpmPath, expectedMpmArgs));
153+
});
154+
});
155+
136156
it("install rejects on failed install", async () => {
137157
const mpmPath = "mpm";
138-
const releaseInfo = {name: "r2022b", version: "9.13.0", update: "latest"};
158+
const releaseInfo = {name: "r2022b", version: "9.13.0", update: "latest", isPrerelease: false};
139159
const destination = "/opt/matlab";
140160
const products = "MATLAB Compiler";
141161
stubExec.callsFake((bin, args?) => {

0 commit comments

Comments
 (0)