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"
|
author: "Amin Yahyaabadi"
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
|
cache-tools:
|
||||||
|
description: "If should cache the installed tools? (Default: false)"
|
||||||
|
required: false
|
||||||
compiler:
|
compiler:
|
||||||
description: "The compiler to use and its optional version separated by - e.g. llvm-13.0.0"
|
description: "The compiler to use and its optional version separated by - e.g. llvm-13.0.0"
|
||||||
required: false
|
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": {
|
"scripts": {
|
||||||
"build": "run-s clean build.packages && run-p lint.tsc build.parcel copy.matchers",
|
"build": "run-s clean build.packages && run-p lint.tsc build.parcel copy.matchers",
|
||||||
"build.packages": "pnpm run -r build",
|
"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",
|
"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",
|
"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 ",
|
"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.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.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",
|
"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",
|
"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",
|
"format": "run-s lint.dprint",
|
||||||
|
@ -203,15 +202,6 @@
|
||||||
"includeNodeModules": true,
|
"includeNodeModules": true,
|
||||||
"optimize": true,
|
"optimize": true,
|
||||||
"outputFormat": "commonjs"
|
"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
|
let directory: string
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
directory = await setupTmpDir("cmake")
|
directory = await setupTmpDir("cmake")
|
||||||
|
process.env.CACHE_TOOLS = "true"
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup CMake", async () => {
|
it("should setup CMake", async () => {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { extractTar } from "@actions/tool-cache"
|
|
||||||
import { addExeExt } from "patha"
|
import { addExeExt } from "patha"
|
||||||
import semverCoerce from "semver/functions/coerce"
|
import semverCoerce from "semver/functions/coerce"
|
||||||
import semverLte from "semver/functions/lte"
|
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"
|
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
|
||||||
|
|
||||||
/** Get the platform data for cmake */
|
/** Get the platform data for cmake */
|
||||||
|
@ -34,7 +33,7 @@ function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: s
|
||||||
binRelativeDir: "CMake.app/Contents/bin/",
|
binRelativeDir: "CMake.app/Contents/bin/",
|
||||||
binFileName: addExeExt("cmake"),
|
binFileName: addExeExt("cmake"),
|
||||||
extractedFolderName: folderName,
|
extractedFolderName: folderName,
|
||||||
extractFunction: extractTar,
|
extractFunction: extractTarByExe,
|
||||||
url: `https://github.com/Kitware/CMake/releases/download/v${version}/${folderName}.tar.gz`,
|
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/",
|
binRelativeDir: "bin/",
|
||||||
binFileName: addExeExt("cmake"),
|
binFileName: addExeExt("cmake"),
|
||||||
extractedFolderName: folderName,
|
extractedFolderName: folderName,
|
||||||
extractFunction: extractTar,
|
extractFunction: extractTarByExe,
|
||||||
url: `https://github.com/Kitware/CMake/releases/download/v${version}/${folderName}.tar.gz`,
|
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) {
|
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
|
// build after extraction using CMake
|
||||||
const cmake = await getCmake()
|
const cmake = await getCmake()
|
||||||
|
|
|
@ -332,7 +332,7 @@ export async function getLLVMPackageInfo(
|
||||||
extractFunction: platform === "win32"
|
extractFunction: platform === "win32"
|
||||||
? extractExe
|
? extractExe
|
||||||
: (file: string, dest: string) => {
|
: (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
|
let directory: string
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
directory = await setupTmpDir("ninja")
|
directory = await setupTmpDir("ninja")
|
||||||
|
process.env.CACHE_TOOLS = "true"
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup Ninja", async () => {
|
it("should setup Ninja", async () => {
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe("setup-task", () => {
|
||||||
let directory: string
|
let directory: string
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
directory = await setupTmpDir("task")
|
directory = await setupTmpDir("task")
|
||||||
|
process.env.CACHE_TOOLS = "true"
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup task", async () => {
|
it("should setup task", async () => {
|
||||||
|
|
|
@ -37,7 +37,7 @@ export function extractZip(file: string, dest: string) {
|
||||||
return extract7Zip(file, dest)
|
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 {
|
try {
|
||||||
await mkdirP(dest)
|
await mkdirP(dest)
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -48,7 +48,9 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
|
||||||
// https://github.com/heroku/heroku-slugs/issues/3
|
// https://github.com/heroku/heroku-slugs/issues/3
|
||||||
|
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
if (process.platform === "win32" && (e as Error).message.includes("Can't create '\\\\?\\C:")) {
|
if (process.platform === "win32" && (e as Error).message.includes("Can't create '\\\\?\\C:")) {
|
||||||
warning(`Failed to extract symlink ${file} to ${dest}. Ignoring this symlink.`)
|
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 { GITHUB_ACTIONS } from "ci-info"
|
||||||
import { pathExists } from "path-exists"
|
import { pathExists } from "path-exists"
|
||||||
import retry from "retry-as-promised"
|
import retry from "retry-as-promised"
|
||||||
|
import { maybeGetInput } from "../../cli-options"
|
||||||
import { hasDnf } from "../env/hasDnf"
|
import { hasDnf } from "../env/hasDnf"
|
||||||
import { isArch } from "../env/isArch"
|
import { isArch } from "../env/isArch"
|
||||||
import { isUbuntu } from "../env/isUbuntu"
|
import { isUbuntu } from "../env/isUbuntu"
|
||||||
|
@ -132,7 +133,9 @@ export async function setupBin(
|
||||||
|
|
||||||
// check if inside Github Actions. If so, cache the installation
|
// check if inside Github Actions. If so, cache the installation
|
||||||
if (GITHUB_ACTIONS && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
if (GITHUB_ACTIONS && typeof process.env.RUNNER_TOOL_CACHE === "string") {
|
||||||
await cacheDir(setupDir, name, version)
|
if (maybeGetInput("cache-tools") === "true" || process.env.CACHE_TOOLS === "true") {
|
||||||
|
await cacheDir(setupDir, name, version)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { installDir, binDir }
|
return { installDir, binDir }
|
||||||
|
|
Loading…
Reference in New Issue