Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tasks/install-matlab/v0/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function installRoot(programName: string) {
// similar to "curl | sh"
async function curlsh(url: string, args: string | string[]) {
// download script
const scriptPath = await toolLib.downloadTool(url);
const scriptPath = await toolLib.downloadToolWithRetries(url);

// execute script
const bashPath = taskLib.which("bash", true);
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v0/test/downloadAndExecuteLinux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tlClone.assertAgent = (variable: string) => {
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);

tr.registerMock("azure-pipelines-tool-lib/tool", {
downloadTool(url: string) {
downloadToolWithRetries(url: string) {
if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-deps/v0/install.sh") {
return "install.sh";
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v0/test/downloadAndExecutePrivate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tlClone.assertAgent = (variable: string) => {
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);

tr.registerMock("azure-pipelines-tool-lib/tool", {
downloadTool(url: string) {
downloadToolWithRetries(url: string) {
if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-deps/v0/install.sh") {
return "install.sh";
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v0/test/downloadAndExecuteWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tlClone.assertAgent = (variable: string) => {
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);

tr.registerMock("azure-pipelines-tool-lib/tool", {
downloadTool(url: string) {
downloadToolWithRetries(url: string) {
if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {
return "ci-install.sh";
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-batch/v0/install.sh") {
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v0/test/failDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tlClone.assertAgent = (variable: string) => {
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);

tr.registerMock("azure-pipelines-tool-lib/tool", {
downloadTool() {
downloadToolWithRetries() {
throw new Error("Download failed");
},
});
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v0/test/failExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tlClone.assertAgent = (variable: string) => {
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);

tr.registerMock("azure-pipelines-tool-lib/tool", {
downloadTool(url: string) {
downloadToolWithRetries(url: string) {
if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-deps/v0/install.sh") {
return "install.sh";
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {
Expand Down
6 changes: 3 additions & 3 deletions tasks/install-matlab/v1/src/matlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as fs from "fs";
import * as https from "https";
import * as path from "path";
import * as script from "./script";
import { downloadTool } from "./utils";
import { downloadToolWithRetries } from "./utils";

export interface Release {
name: string;
Expand Down Expand Up @@ -137,7 +137,7 @@ export async function setupBatch(platform: string, architecture: string) {
return Promise.reject(Error(`This task is not supported on ${platform} runners.`));
}

const tempPath = await downloadTool(matlabBatchUrl, `matlab-batch${matlabBatchExt}`);
const tempPath = await downloadToolWithRetries(matlabBatchUrl, `matlab-batch${matlabBatchExt}`);
const matlabBatchPath = await toolLib.cacheFile(tempPath, `matlab-batch${matlabBatchExt}`, "matlab-batch", "1.0.0");
try {
toolLib.prependPath(matlabBatchPath);
Expand Down Expand Up @@ -174,7 +174,7 @@ async function installAppleSiliconRosetta() {
}

async function installAppleSiliconJdk() {
const jdk = await downloadTool(
const jdk = await downloadToolWithRetries(
"https://corretto.aws/downloads/resources/8.402.08.1/amazon-corretto-8.402.08.1-macosx-aarch64.pkg",
"jdk.pkg",
);
Expand Down
8 changes: 4 additions & 4 deletions tasks/install-matlab/v1/src/mpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as taskLib from "azure-pipelines-task-lib/task";
import * as matlab from "./matlab";
import { downloadTool } from "./utils";
import { downloadToolWithRetries } from "./utils";

export async function setup(platform: string, architecture: string): Promise<string> {
const mpmRootUrl: string = "https://www.mathworks.com/mpm/";
Expand All @@ -15,11 +15,11 @@ export async function setup(platform: string, architecture: string): Promise<str
switch (platform) {
case "win32":
mpmUrl = mpmRootUrl + "win64/mpm";
mpm = await downloadTool(mpmUrl, "mpm.exe");
mpm = await downloadToolWithRetries(mpmUrl, "mpm.exe");
break;
case "linux":
mpmUrl = mpmRootUrl + "glnxa64/mpm";
mpm = await downloadTool(mpmUrl, "mpm");
mpm = await downloadToolWithRetries(mpmUrl, "mpm");
exitCode = await taskLib.exec("chmod", ["+x", mpm]);
if (exitCode !== 0) {
return Promise.reject(Error("Unable to set up mpm."));
Expand All @@ -31,7 +31,7 @@ export async function setup(platform: string, architecture: string): Promise<str
} else {
mpmUrl = mpmRootUrl + "maca64/mpm";
}
mpm = await downloadTool(mpmUrl, "mpm");
mpm = await downloadToolWithRetries(mpmUrl, "mpm");
exitCode = await taskLib.exec("chmod", ["+x", mpm]);
if (exitCode !== 0) {
return Promise.reject(Error("Unable to set up mpm."));
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v1/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as toolLib from "azure-pipelines-tool-lib/tool";
import * as path from "path";

export async function downloadAndRunScript(platform: string, url: string, args: string | string[]) {
const scriptPath = await toolLib.downloadTool(url);
const scriptPath = await toolLib.downloadToolWithRetries(url);
const bashPath = await taskLib.which("bash", true);
const sudoPath = await taskLib.which("sudo", false);
let bash;
Expand Down
4 changes: 2 additions & 2 deletions tasks/install-matlab/v1/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as taskLib from "azure-pipelines-task-lib/task";
import * as toolLib from "azure-pipelines-tool-lib/tool";
import * as path from "path";

export async function downloadTool(url: string, fileName: string): Promise<string> {
export async function downloadToolWithRetries(url: string, fileName: string): Promise<string> {
let destPath: string;
if (path.isAbsolute(fileName)) {
destPath = fileName;
Expand All @@ -17,6 +17,6 @@ export async function downloadTool(url: string, fileName: string): Promise<strin
}

taskLib.rmRF(destPath);
await toolLib.downloadTool(url, destPath);
await toolLib.downloadToolWithRetries(url, destPath);
return destPath;
}
4 changes: 2 additions & 2 deletions tasks/install-matlab/v1/test/matlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default function suite() {
stubCacheFile.callsFake((srcFile, desFile, tool, ver) => {
return Promise.resolve(matlabBatchPath);
});
stubDownloadTool = sinon.stub(toolLib, "downloadTool");
stubDownloadTool = sinon.stub(toolLib, "downloadToolWithRetries");
stubDownloadTool.callsFake((url, name) => {
return Promise.resolve(matlabBatchPath);
});
Expand Down Expand Up @@ -359,7 +359,7 @@ export default function suite() {

stubDownloadAndRun = sinon.stub(script, "downloadAndRunScript");
stubDownloadAndRun.resolves(0);
stubDownloadTool = sinon.stub(utils, "downloadTool");
stubDownloadTool = sinon.stub(utils, "downloadToolWithRetries");
stubDownloadTool.resolves("/path/to/jdk.pkg");
stubExec = sinon.stub(taskLib, "exec");
stubExec.resolves(0);
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v1/test/mpm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function suite() {
describe("mpm.ts test suite", () => {
beforeEach(() => {
// setup stubs
stubDownloadTool = sinon.stub(toolLib, "downloadTool");
stubDownloadTool = sinon.stub(toolLib, "downloadToolWithRetries");
stubDownloadTool.callsFake((url, fileName) => {
return Promise.resolve(`${agentTemp}/fileName`);
});
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-matlab/v1/test/script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function suite() {
describe("script.ts test suite", () => {
beforeEach(() => {
// setup stubs
stubDownloadTool = sinon.stub(toolLib, "downloadTool");
stubDownloadTool = sinon.stub(toolLib, "downloadToolWithRetries");
stubDownloadTool.callsFake((url, fileName?, handlers?) => {
return Promise.resolve("/path/to/script");
});
Expand Down