mirror of https://github.com/aminya/setup-cpp
fix: set runner temp for local runs
This commit is contained in:
parent
0c6682f3af
commit
40336c3c67
|
@ -3,6 +3,7 @@ import { addPath, group, startGroup, endGroup } from "@actions/core"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import * as hasha from "hasha"
|
import * as hasha from "hasha"
|
||||||
|
import { tmpdir } from "os"
|
||||||
|
|
||||||
/** A type that describes a package */
|
/** A type that describes a package */
|
||||||
export type PackageInfo = {
|
export type PackageInfo = {
|
||||||
|
@ -24,6 +25,10 @@ export async function setupBin(
|
||||||
version: string,
|
version: string,
|
||||||
getPackageInfo: (version: string, platform: NodeJS.Platform) => PackageInfo
|
getPackageInfo: (version: string, platform: NodeJS.Platform) => PackageInfo
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
const setupCppDir = process.env.SETUP_CPP_DIR ?? "~/setup_cpp"
|
||||||
|
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
|
||||||
|
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACH ?? join(setupCppDir, "ToolCache")
|
||||||
|
|
||||||
// Build artifact name
|
// Build artifact name
|
||||||
const binName = process.platform === "win32" ? `${name}.exe` : name
|
const binName = process.platform === "win32" ? `${name}.exe` : name
|
||||||
|
|
||||||
|
@ -38,7 +43,7 @@ export async function setupBin(
|
||||||
|
|
||||||
// Get an unique output directory name from the URL.
|
// Get an unique output directory name from the URL.
|
||||||
const key: string = await hasha.async(url)
|
const key: string = await hasha.async(url)
|
||||||
const workDir = join(process.env.SETUP_CPP_DIR ?? "~/setup_cpp", key)
|
const workDir = join(setupCppDir, key)
|
||||||
|
|
||||||
/** The directory which the tool is installed to */
|
/** The directory which the tool is installed to */
|
||||||
const binDir = join(workDir, extractedFolderName, binRelativeDir)
|
const binDir = join(workDir, extractedFolderName, binRelativeDir)
|
||||||
|
|
|
@ -7,16 +7,12 @@ export async function setupTmpDir(testName: string) {
|
||||||
|
|
||||||
await io.rmRF(tempDirectory)
|
await io.rmRF(tempDirectory)
|
||||||
await io.mkdirP(tempDirectory)
|
await io.mkdirP(tempDirectory)
|
||||||
process.env.INPUT_DESTINATION = tempDirectory
|
process.env.SETUP_CPP_DIR = tempDirectory
|
||||||
process.env.GITHUB_WORKSPACE = tempDirectory
|
|
||||||
process.env.SETUP_CPP_DIR = path.join(tempDirectory, "temp", "setup-cpp")
|
|
||||||
process.env.RUNNER_TOOL_CACHE = path.join(tempDirectory, "tempToolCache")
|
|
||||||
|
|
||||||
return tempDirectory
|
return tempDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function cleanupTmpDir(testName: string) {
|
export async function cleanupTmpDir(testName: string) {
|
||||||
if (process.env.SETUP_CPP_DIR != undefined) {
|
if (process.env.SETUP_CPP_DIR !== undefined) {
|
||||||
const tempDirectory = path.join(process.env.SETUP_CPP_DIR, testName)
|
const tempDirectory = path.join(process.env.SETUP_CPP_DIR, testName)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue