-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check and auto-install if
llvm-cov
is not available
- Loading branch information
Showing
4 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as core from "@actions/core"; | ||
import * as exec from "@actions/exec"; | ||
import * as io from "@actions/io"; | ||
import * as os from "os"; | ||
|
||
async function isAvailable(tool: string): Promise<boolean> { | ||
try { | ||
await io.which(tool, true); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
async function chocoInstall(pkg: string) { | ||
await exec.exec("choco", ["install", "-y", pkg]); | ||
} | ||
|
||
async function aptInstall(pkg: string) { | ||
await exec.exec("sudo", ["apt-get", "install", "-y", pkg]); | ||
} | ||
|
||
async function brewInstall(pkg: string) { | ||
await exec.exec("brew", ["install", pkg]); | ||
} | ||
|
||
async function smartInstall(pkg: string) { | ||
switch (os.type()) { | ||
case "Windows_NT": | ||
chocoInstall(pkg); | ||
break; | ||
case "Linux": | ||
aptInstall(pkg); | ||
break; | ||
case "Darwin": | ||
brewInstall(pkg); | ||
break; | ||
default: | ||
throw new Error(`unknown OS type: ${os.type()}`); | ||
} | ||
} | ||
|
||
export async function checkLlvm() { | ||
const available = await isAvailable("llvm-cov"); | ||
if (!available) { | ||
await core.group("Install LLVM", async () => { | ||
await smartInstall("llvm"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters