Skip to content

Commit 70aa5bd

Browse files
author
Sam Eagen
committed
Do not install core deps on self-hosted runners
1 parent 31e2276 commit 70aa5bd

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/install.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ export async function install(platform: string, architecture: string, release: s
2424
return Promise.reject(Error(`Release '${releaseInfo.name}' is not supported. Use 'R2020b' or a later release.`));
2525
}
2626

27-
await core.group("Preparing system for MATLAB", async () =>
28-
matlab.installSystemDependencies(platform, architecture, releaseInfo.name)
29-
);
27+
// Install system dependencies if cloud-hosted
28+
if (process.env["RUNNER_ENVIRONMENT"] === "github-hosted" && process.env["AGENT_ISSELFHOSTED"] !== "1") {
29+
await core.group("Preparing system for MATLAB", async () => {
30+
await matlab.installSystemDependencies(platform, architecture, releaseInfo.name);
31+
});
32+
}
3033

3134
await core.group("Setting up MATLAB", async () => {
3235
let matlabArch = architecture;

src/install.unit.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ describe("install procedure", () => {
2626
let setOutputMock: jest.Mock;
2727
let restoreMATLABMock: jest.Mock;
2828

29+
const runnerEnv = "github-hosted";
30+
const agentIsSelfHosted = "0";
31+
2932
const platform = "linux";
3033
const arch = "x64";
3134
const release = "latest";
@@ -57,6 +60,9 @@ describe("install procedure", () => {
5760
});
5861
matlabGetReleaseInfoMock.mockResolvedValue(releaseInfo);
5962
matlabGetToolcacheDirMock.mockResolvedValue(["/opt/hostedtoolcache/MATLAB/9.13.0/x64", false]);
63+
64+
process.env["RUNNER_ENVIRONMENT"] = runnerEnv;
65+
process.env["AGENT_ISSELFHOSTED"] = agentIsSelfHosted;
6066
});
6167

6268
it("ideally works", async () => {
@@ -91,6 +97,17 @@ describe("install procedure", () => {
9197
await expect(doInstall()).rejects.toBeDefined();
9298
});
9399

100+
it("sets up dependencies for github-hosted runners", async () => {
101+
await doInstall();
102+
expect(matlabInstallSystemDependenciesMock).toHaveBeenCalled();
103+
});
104+
105+
it("does not set up dependencies for self-hosted runners", async () => {
106+
process.env["RUNNER_ENVIRONMENT"] = "self-hosted";
107+
await doInstall();
108+
expect(matlabInstallSystemDependenciesMock).not.toHaveBeenCalled();
109+
});
110+
94111
it("rejects when the setup deps fails", async () => {
95112
matlabInstallSystemDependenciesMock.mockRejectedValueOnce(Error("oof"));
96113
await expect(doInstall()).rejects.toBeDefined();

0 commit comments

Comments
 (0)