fix: test cache hit only on GitHub CI

This commit is contained in:
Amin Yahyaabadi 2022-01-30 16:59:46 -08:00
parent 05211426be
commit 802f1bce3a
7 changed files with 28 additions and 14 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,6 @@
import { setupCmake } from "../cmake"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { isGitHubCI } from "../../utils/env/isci"
jest.setTimeout(300000)
@ -17,7 +18,9 @@ describe("setup-cmake", () => {
it("should find CMake in the cache", async () => {
const { binDir } = await setupCmake("3.20.2", directory, process.arch)
await testBin("cmake", ["--version"], binDir)
expect(binDir.includes("hostedtoolcache")).toBeTruthy()
if (isGitHubCI()) {
expect(binDir).toMatch("hostedtoolcache")
}
})
afterAll(async () => {

View File

@ -2,6 +2,7 @@ import { setupLLVM, VERSIONS, getUrl, setupClangTools } from "../llvm"
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { isValidUrl } from "../../utils/http/validate_url"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { isGitHubCI } from "../../utils/env/isci"
jest.setTimeout(300000)
async function testUrl(version: string) {
@ -53,12 +54,17 @@ describe("setup-llvm", () => {
const { binDir } = await setupLLVM("11.0.0", directory, process.arch)
await testBin("clang++", ["--version"], binDir)
expect(binDir.includes("hostedtoolcache")).toBeTruthy()
if (isGitHubCI()) {
expect(binDir).toMatch("hostedtoolcache")
}
expect(process.env.CC?.includes("clang")).toBeTruthy()
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
expect(process.env.CC?.includes("hostedtoolcache")).toBeTruthy()
expect(process.env.CXX?.includes("hostedtoolcache")).toBeTruthy()
if (isGitHubCI()) {
expect(process.env.CC).toMatch("hostedtoolcache")
expect(process.env.CXX).toMatch("hostedtoolcache")
}
})
it("should setup clang-tidy and clang-format", async () => {

View File

@ -1,5 +1,6 @@
import { setupNinja } from "../ninja"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { isGitHubCI } from "../../utils/env/isci"
jest.setTimeout(300000)
async function testNinja(directory: string) {
@ -20,7 +21,9 @@ describe("setup-ninja", () => {
it("should find Ninja in the cache", async () => {
const binDir = await testNinja(directory)
expect(binDir.includes("hostedtoolcache")).toBeTruthy()
if (isGitHubCI()) {
expect(binDir).toMatch("hostedtoolcache")
}
})
afterEach(async () => {

View File

@ -1,6 +1,6 @@
import { setupTask } from "../task"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin"
import { isGitHubCI } from "../../utils/env/isci"
jest.setTimeout(300000)
describe("setup-task", () => {
@ -10,14 +10,16 @@ describe("setup-task", () => {
})
it("should setup task", async () => {
const installInfo = await setupTask("3.10.0", directory, process.arch)
const { binDir } = await setupTask("3.10.0", directory, process.arch)
await testBin("task", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
await testBin("task", ["--version"], binDir)
})
it("should find task in the cache", async () => {
const installInfo = await setupTask("3.10.0", directory, process.arch)
expect((installInfo as InstallationInfo | undefined)?.binDir.includes("hostedtoolcache")).toBeTruthy()
const { binDir } = await setupTask("3.10.0", directory, process.arch)
if (isGitHubCI()) {
expect(binDir).toMatch("hostedtoolcache")
}
})
afterEach(async () => {

View File

@ -9,6 +9,7 @@ import { error } from "../io/io"
/** An add path function that works locally or inside GitHub Actions */
export function addPath(path: string) {
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
try {
if (isGitHubCI()) {
ghAddPath(path)
@ -45,8 +46,7 @@ function addPathSystem(path: string) {
return
}
default: {
// fall through shell path modification
return
}
}
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
}