Skip to content

Commit e1efb92

Browse files
authored
Use downloadToolWithRetries in place of all downloadTool calls (#133)
* Use downloadToolWithRetries in place of all downloadTool calls * Replace stub uses of downloadTool with downloadToolWithRetries
1 parent 3e4bc63 commit e1efb92

File tree

13 files changed

+20
-20
lines changed

13 files changed

+20
-20
lines changed

tasks/install-matlab/v0/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function installRoot(programName: string) {
9191
// similar to "curl | sh"
9292
async function curlsh(url: string, args: string | string[]) {
9393
// download script
94-
const scriptPath = await toolLib.downloadTool(url);
94+
const scriptPath = await toolLib.downloadToolWithRetries(url);
9595

9696
// execute script
9797
const bashPath = taskLib.which("bash", true);

tasks/install-matlab/v0/test/downloadAndExecuteLinux.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tlClone.assertAgent = (variable: string) => {
3535
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);
3636

3737
tr.registerMock("azure-pipelines-tool-lib/tool", {
38-
downloadTool(url: string) {
38+
downloadToolWithRetries(url: string) {
3939
if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-deps/v0/install.sh") {
4040
return "install.sh";
4141
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {

tasks/install-matlab/v0/test/downloadAndExecutePrivate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tlClone.assertAgent = (variable: string) => {
3535
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);
3636

3737
tr.registerMock("azure-pipelines-tool-lib/tool", {
38-
downloadTool(url: string) {
38+
downloadToolWithRetries(url: string) {
3939
if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-deps/v0/install.sh") {
4040
return "install.sh";
4141
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {

tasks/install-matlab/v0/test/downloadAndExecuteWindows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tlClone.assertAgent = (variable: string) => {
3535
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);
3636

3737
tr.registerMock("azure-pipelines-tool-lib/tool", {
38-
downloadTool(url: string) {
38+
downloadToolWithRetries(url: string) {
3939
if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {
4040
return "ci-install.sh";
4141
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-batch/v0/install.sh") {

tasks/install-matlab/v0/test/failDownload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tlClone.assertAgent = (variable: string) => {
2525
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);
2626

2727
tr.registerMock("azure-pipelines-tool-lib/tool", {
28-
downloadTool() {
28+
downloadToolWithRetries() {
2929
throw new Error("Download failed");
3030
},
3131
});

tasks/install-matlab/v0/test/failExecute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tlClone.assertAgent = (variable: string) => {
2626
tr.registerMock("azure-pipelines-task-lib/mock-task", tlClone);
2727

2828
tr.registerMock("azure-pipelines-tool-lib/tool", {
29-
downloadTool(url: string) {
29+
downloadToolWithRetries(url: string) {
3030
if (url === "https://ssd.mathworks.com/supportfiles/ci/matlab-deps/v0/install.sh") {
3131
return "install.sh";
3232
} else if (url === "https://ssd.mathworks.com/supportfiles/ci/ephemeral-matlab/v0/ci-install.sh") {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as fs from "fs";
66
import * as https from "https";
77
import * as path from "path";
88
import * as script from "./script";
9-
import { downloadTool } from "./utils";
9+
import { downloadToolWithRetries } from "./utils";
1010

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

140-
const tempPath = await downloadTool(matlabBatchUrl, `matlab-batch${matlabBatchExt}`);
140+
const tempPath = await downloadToolWithRetries(matlabBatchUrl, `matlab-batch${matlabBatchExt}`);
141141
const matlabBatchPath = await toolLib.cacheFile(tempPath, `matlab-batch${matlabBatchExt}`, "matlab-batch", "1.0.0");
142142
try {
143143
toolLib.prependPath(matlabBatchPath);
@@ -174,7 +174,7 @@ async function installAppleSiliconRosetta() {
174174
}
175175

176176
async function installAppleSiliconJdk() {
177-
const jdk = await downloadTool(
177+
const jdk = await downloadToolWithRetries(
178178
"https://corretto.aws/downloads/resources/8.402.08.1/amazon-corretto-8.402.08.1-macosx-aarch64.pkg",
179179
"jdk.pkg",
180180
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

77
export async function setup(platform: string, architecture: string): Promise<string> {
88
const mpmRootUrl: string = "https://www.mathworks.com/mpm/";
@@ -15,11 +15,11 @@ export async function setup(platform: string, architecture: string): Promise<str
1515
switch (platform) {
1616
case "win32":
1717
mpmUrl = mpmRootUrl + "win64/mpm";
18-
mpm = await downloadTool(mpmUrl, "mpm.exe");
18+
mpm = await downloadToolWithRetries(mpmUrl, "mpm.exe");
1919
break;
2020
case "linux":
2121
mpmUrl = mpmRootUrl + "glnxa64/mpm";
22-
mpm = await downloadTool(mpmUrl, "mpm");
22+
mpm = await downloadToolWithRetries(mpmUrl, "mpm");
2323
exitCode = await taskLib.exec("chmod", ["+x", mpm]);
2424
if (exitCode !== 0) {
2525
return Promise.reject(Error("Unable to set up mpm."));
@@ -31,7 +31,7 @@ export async function setup(platform: string, architecture: string): Promise<str
3131
} else {
3232
mpmUrl = mpmRootUrl + "maca64/mpm";
3333
}
34-
mpm = await downloadTool(mpmUrl, "mpm");
34+
mpm = await downloadToolWithRetries(mpmUrl, "mpm");
3535
exitCode = await taskLib.exec("chmod", ["+x", mpm]);
3636
if (exitCode !== 0) {
3737
return Promise.reject(Error("Unable to set up mpm."));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as toolLib from "azure-pipelines-tool-lib/tool";
55
import * as path from "path";
66

77
export async function downloadAndRunScript(platform: string, url: string, args: string | string[]) {
8-
const scriptPath = await toolLib.downloadTool(url);
8+
const scriptPath = await toolLib.downloadToolWithRetries(url);
99
const bashPath = await taskLib.which("bash", true);
1010
const sudoPath = await taskLib.which("sudo", false);
1111
let bash;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as taskLib from "azure-pipelines-task-lib/task";
44
import * as toolLib from "azure-pipelines-tool-lib/tool";
55
import * as path from "path";
66

7-
export async function downloadTool(url: string, fileName: string): Promise<string> {
7+
export async function downloadToolWithRetries(url: string, fileName: string): Promise<string> {
88
let destPath: string;
99
if (path.isAbsolute(fileName)) {
1010
destPath = fileName;
@@ -17,6 +17,6 @@ export async function downloadTool(url: string, fileName: string): Promise<strin
1717
}
1818

1919
taskLib.rmRF(destPath);
20-
await toolLib.downloadTool(url, destPath);
20+
await toolLib.downloadToolWithRetries(url, destPath);
2121
return destPath;
2222
}

0 commit comments

Comments
 (0)