Skip to content

Commit e9f17e7

Browse files
committed
ci: add test dependency on format-lint-typecheck job
- Add 'needs' dependency to Test job to ensure quality checks pass before running tests - Update compiled distribution files to reflect source code changes for dynamic sudo prefix
1 parent 261b80d commit e9f17e7

4 files changed

Lines changed: 34 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343

4444
Test:
4545
name: Small Test
46+
needs: [Format-Lint-TypeCheck]
4647
strategy:
4748
fail-fast: false
4849
matrix:

dist/index.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22668,6 +22668,12 @@ function debugLog(message) {
2266822668
}
2266922669
core.debug(message);
2267022670
}
22671+
function hasRootPrivileges() {
22672+
if (process.getuid && typeof process.getuid === "function") {
22673+
return process.getuid() === 0;
22674+
}
22675+
return false;
22676+
}
2267122677

2267222678
// src/const.ts
2267322679
var START_SUPPORTED_CUDA_VERSION = "10.0";
@@ -23077,9 +23083,13 @@ var fs2 = __toESM(require("fs"));
2307723083
var path = __toESM(require("path"));
2307823084
var tc = __toESM(require_tool_cache());
2307923085
var io = __toESM(require_io());
23086+
function getSudoPrefix() {
23087+
return hasRootPrivileges() ? "" : "sudo";
23088+
}
2308023089
async function installCudaLinuxLocal(installerPath) {
2308123090
core2.info("Installing CUDA on Linux...");
23082-
const command = `sudo sh ${installerPath}`;
23091+
const sudoPrefix = getSudoPrefix();
23092+
const command = `${sudoPrefix} sh ${installerPath}`.trim();
2308323093
const installArgs = ["--silent", "--override", "--toolkit"];
2308423094
debugLog(`Executing: ${command} ${installArgs.join(" ")}`);
2308523095
await exec.exec(command, installArgs);
@@ -23144,6 +23154,7 @@ async function installCudaLinuxNetwork(version, arch2, osInfo) {
2314423154
}
2314523155
const repoUrl = cudaRepoAndPackage.repoUrl;
2314623156
const packageName = cudaRepoAndPackage.packageName;
23157+
const sudoPrefix = getSudoPrefix();
2314723158
let cudaPath = void 0;
2314823159
try {
2314923160
if (isDebianBased(osInfo)) {
@@ -23155,21 +23166,25 @@ async function installCudaLinuxNetwork(version, arch2, osInfo) {
2315523166
}
2315623167
repoFilePath = path.resolve(repoFilePath);
2315723168
if (repoUrl.endsWith(".deb")) {
23158-
await exec.exec(`sudo dpkg -i ${repoFilePath}`);
23159-
await exec.exec(`sudo apt-get update`);
23169+
await exec.exec(`${sudoPrefix} dpkg -i ${repoFilePath}`.trim());
23170+
await exec.exec(`${sudoPrefix} apt-get update`.trim());
2316023171
} else if (repoUrl.endsWith(".pin")) {
23161-
await exec.exec(`sudo mv ${repoFilePath} /etc/apt/preferences.d/cuda-repository-pin-600`);
23172+
await exec.exec(
23173+
`${sudoPrefix} mv ${repoFilePath} /etc/apt/preferences.d/cuda-repository-pin-600`.trim()
23174+
);
2316223175
const repoRootUrl = repoUrl.replace(/\/[\w.-]+\.pin$/, "");
23163-
await exec.exec(`sudo add-apt-repository "deb ${repoRootUrl} /"`);
23164-
await exec.exec(`sudo apt-get update`);
23176+
await exec.exec(`${sudoPrefix} add-apt-repository "deb ${repoRootUrl} /"`.trim());
23177+
await exec.exec(`${sudoPrefix} apt-get update`.trim());
2316523178
}
23166-
await exec.exec(`sudo apt-get install -y ${packageName}`);
23179+
await exec.exec(`${sudoPrefix} apt-get install -y ${packageName}`.trim());
2316723180
cudaPath = "/usr/local/cuda";
2316823181
} else if (isFedoraBased(osInfo)) {
2316923182
const packageManagerCommand = await getPackageManagerCommand(osInfo);
23170-
await exec.exec(`sudo ${packageManagerCommand} config-manager --add-repo ${repoUrl}`);
23171-
await exec.exec(`sudo ${packageManagerCommand} clean all`);
23172-
await exec.exec(`sudo ${packageManagerCommand} install -y ${packageName}`);
23183+
await exec.exec(
23184+
`${sudoPrefix} ${packageManagerCommand} config-manager --add-repo ${repoUrl}`.trim()
23185+
);
23186+
await exec.exec(`${sudoPrefix} ${packageManagerCommand} clean all`.trim());
23187+
await exec.exec(`${sudoPrefix} ${packageManagerCommand} install -y ${packageName}`.trim());
2317323188
cudaPath = "/usr/local/cuda";
2317423189
}
2317523190
} catch (error) {

dist/index.js.map

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

src/install.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ async function installCudaLinuxNetwork(
166166
await exec.exec(`${sudoPrefix} dpkg -i ${repoFilePath}`.trim());
167167
await exec.exec(`${sudoPrefix} apt-get update`.trim());
168168
} else if (repoUrl.endsWith('.pin')) {
169-
await exec.exec(`${sudoPrefix} mv ${repoFilePath} /etc/apt/preferences.d/cuda-repository-pin-600`.trim());
169+
await exec.exec(
170+
`${sudoPrefix} mv ${repoFilePath} /etc/apt/preferences.d/cuda-repository-pin-600`.trim()
171+
);
170172
const repoRootUrl = repoUrl.replace(/\/[\w.-]+\.pin$/, '');
171173
await exec.exec(`${sudoPrefix} add-apt-repository "deb ${repoRootUrl} /"`.trim());
172174
await exec.exec(`${sudoPrefix} apt-get update`.trim());
@@ -176,7 +178,9 @@ async function installCudaLinuxNetwork(
176178
cudaPath = '/usr/local/cuda';
177179
} else if (isFedoraBased(osInfo)) {
178180
const packageManagerCommand = await getPackageManagerCommand(osInfo);
179-
await exec.exec(`${sudoPrefix} ${packageManagerCommand} config-manager --add-repo ${repoUrl}`.trim());
181+
await exec.exec(
182+
`${sudoPrefix} ${packageManagerCommand} config-manager --add-repo ${repoUrl}`.trim()
183+
);
180184
await exec.exec(`${sudoPrefix} ${packageManagerCommand} clean all`.trim());
181185
await exec.exec(`${sudoPrefix} ${packageManagerCommand} install -y ${packageName}`.trim());
182186
cudaPath = '/usr/local/cuda';

0 commit comments

Comments
 (0)