mirror of https://github.com/aminya/setup-cpp
Merge pull request #254 from aminya/cache
This commit is contained in:
commit
3774e9b3ac
|
@ -3,6 +3,9 @@ description: "Install all the tools required for building and testing C++/C proj
|
|||
author: "Amin Yahyaabadi"
|
||||
|
||||
inputs:
|
||||
cache-tools:
|
||||
description: "If should cache the installed tools? (Default: false)"
|
||||
required: false
|
||||
compiler:
|
||||
description: "The compiler to use and its optional version separated by - e.g. llvm-13.0.0"
|
||||
required: false
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14
package.json
14
package.json
|
@ -29,14 +29,13 @@
|
|||
"scripts": {
|
||||
"build": "run-s clean build.packages && run-p lint.tsc build.parcel copy.matchers",
|
||||
"build.packages": "pnpm run -r build",
|
||||
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report 10 && run-s build.babel",
|
||||
"build.parcel": "cross-env NODE_ENV=production parcel build && run-s build.babel && shx cp -r ./dist/actions/* ./dist/modern",
|
||||
"build.babel": "babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --plugins @babel/plugin-transform-private-methods --compact --no-babelrc --source-maps true",
|
||||
"bump": "ncu -u -x numerous,execa,prettier,@types/node,eslint,@types/eslint && pnpm update && pnpx typesync",
|
||||
"clean": "shx rm -rf ./dist ./exe ./packages/*/dist/ ./.parcel-cache && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern ",
|
||||
"copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions copy.matchers.modern",
|
||||
"copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions",
|
||||
"copy.matchers.legacy": "shx cp ./src/gcc/gcc_matcher.json ./dist/legacy/ && shx cp ./src/msvc/msvc_matcher.json ./dist/legacy/ && shx cp ./src/python/python_matcher.json ./dist/legacy/ && shx cp ./src/llvm/llvm_matcher.json ./dist/legacy/",
|
||||
"copy.matchers.actions": "shx cp ./src/gcc/gcc_matcher.json ./dist/actions/ && shx cp ./src/msvc/msvc_matcher.json ./dist/actions/ && shx cp ./src/python/python_matcher.json ./dist/actions/ && shx cp ./src/llvm/llvm_matcher.json ./dist/actions/",
|
||||
"copy.matchers.modern": "shx cp ./src/gcc/gcc_matcher.json ./dist/modern/ && shx cp ./src/msvc/msvc_matcher.json ./dist/modern/ && shx cp ./src/python/python_matcher.json ./dist/modern/ && shx cp ./src/llvm/llvm_matcher.json ./dist/modern/",
|
||||
"dev": "cross-env NODE_ENV=development parcel watch",
|
||||
"docs": "shx rm -rf packages/*/README.md && pnpm -r exec readme --path ../../dev/readme/template.md -y && pnpm -r exec ts-readme",
|
||||
"format": "run-s lint.dprint",
|
||||
|
@ -203,15 +202,6 @@
|
|||
"includeNodeModules": true,
|
||||
"optimize": true,
|
||||
"outputFormat": "commonjs"
|
||||
},
|
||||
"modern": {
|
||||
"context": "node",
|
||||
"engines": {
|
||||
"node": ">=20.x"
|
||||
},
|
||||
"includeNodeModules": true,
|
||||
"optimize": true,
|
||||
"outputFormat": "commonjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ describe("setup-cmake", () => {
|
|||
let directory: string
|
||||
beforeAll(async () => {
|
||||
directory = await setupTmpDir("cmake")
|
||||
process.env.CACHE_TOOLS = "true"
|
||||
})
|
||||
|
||||
it("should setup CMake", async () => {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { extractTar } from "@actions/tool-cache"
|
||||
import { addExeExt } from "patha"
|
||||
import semverCoerce from "semver/functions/coerce"
|
||||
import semverLte from "semver/functions/lte"
|
||||
import { extractZip } from "../utils/setup/extract"
|
||||
import { extractTarByExe, extractZip } from "../utils/setup/extract"
|
||||
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||
|
||||
/** Get the platform data for cmake */
|
||||
|
@ -34,7 +33,7 @@ function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: s
|
|||
binRelativeDir: "CMake.app/Contents/bin/",
|
||||
binFileName: addExeExt("cmake"),
|
||||
extractedFolderName: folderName,
|
||||
extractFunction: extractTar,
|
||||
extractFunction: extractTarByExe,
|
||||
url: `https://github.com/Kitware/CMake/releases/download/v${version}/${folderName}.tar.gz`,
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +50,7 @@ function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: s
|
|||
binRelativeDir: "bin/",
|
||||
binFileName: addExeExt("cmake"),
|
||||
extractedFolderName: folderName,
|
||||
extractFunction: extractTar,
|
||||
extractFunction: extractTarByExe,
|
||||
url: `https://github.com/Kitware/CMake/releases/download/v${version}/${folderName}.tar.gz`,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ function getBuildKcovPackageInfo(version: string): PackageInfo {
|
|||
}
|
||||
|
||||
async function buildKcov(file: string, dest: string) {
|
||||
const out = await extractTarByExe(file, dest, ["--strip-components=1"])
|
||||
const out = await extractTarByExe(file, dest, 1)
|
||||
|
||||
// build after extraction using CMake
|
||||
const cmake = await getCmake()
|
||||
|
|
|
@ -332,7 +332,7 @@ export async function getLLVMPackageInfo(
|
|||
extractFunction: platform === "win32"
|
||||
? extractExe
|
||||
: (file: string, dest: string) => {
|
||||
return extractTarByExe(file, dest, ["--strip-components=1"])
|
||||
return extractTarByExe(file, dest, 1)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ describe("setup-ninja", () => {
|
|||
let directory: string
|
||||
beforeEach(async () => {
|
||||
directory = await setupTmpDir("ninja")
|
||||
process.env.CACHE_TOOLS = "true"
|
||||
})
|
||||
|
||||
it("should setup Ninja", async () => {
|
||||
|
|
|
@ -8,6 +8,7 @@ describe("setup-task", () => {
|
|||
let directory: string
|
||||
beforeAll(async () => {
|
||||
directory = await setupTmpDir("task")
|
||||
process.env.CACHE_TOOLS = "true"
|
||||
})
|
||||
|
||||
it("should setup task", async () => {
|
||||
|
|
|
@ -37,7 +37,7 @@ export function extractZip(file: string, dest: string) {
|
|||
return extract7Zip(file, dest)
|
||||
}
|
||||
|
||||
export async function extractTarByExe(file: string, dest: string, flags = ["--strip-components=0"]) {
|
||||
export async function extractTarByExe(file: string, dest: string, stripComponents: number = 0, flags: string[] = []) {
|
||||
try {
|
||||
await mkdirP(dest)
|
||||
} catch {
|
||||
|
@ -48,7 +48,9 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
|
|||
// https://github.com/heroku/heroku-slugs/issues/3
|
||||
|
||||
try {
|
||||
await execa("tar", ["xf", file, "-C", dest, ...flags], { stdio: "inherit" })
|
||||
await execa("tar", ["xf", file, "-C", dest, `--strip-components=${stripComponents}`, ...flags], {
|
||||
stdio: "inherit",
|
||||
})
|
||||
} catch (e) {
|
||||
if (process.platform === "win32" && (e as Error).message.includes("Can't create '\\\\?\\C:")) {
|
||||
warning(`Failed to extract symlink ${file} to ${dest}. Ignoring this symlink.`)
|
||||
|
|
|
@ -7,6 +7,7 @@ import { tmpdir } from "os"
|
|||
import { GITHUB_ACTIONS } from "ci-info"
|
||||
import { pathExists } from "path-exists"
|
||||
import retry from "retry-as-promised"
|
||||
import { maybeGetInput } from "../../cli-options"
|
||||
import { hasDnf } from "../env/hasDnf"
|
||||
import { isArch } from "../env/isArch"
|
||||
import { isUbuntu } from "../env/isUbuntu"
|
||||
|
@ -132,8 +133,10 @@ export async function setupBin(
|
|||
|
||||
// check if inside Github Actions. If so, cache the installation
|
||||
if (GITHUB_ACTIONS && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||
if (maybeGetInput("cache-tools") === "true" || process.env.CACHE_TOOLS === "true") {
|
||||
await cacheDir(setupDir, name, version)
|
||||
}
|
||||
}
|
||||
|
||||
return { installDir, binDir }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue