feat: support go task

This commit is contained in:
Amin Yahyaabadi 2022-01-30 15:33:48 -08:00
parent a062ce6962
commit c1478378fa
8 changed files with 75 additions and 2 deletions

View File

@ -24,6 +24,7 @@ The package can be used locally or from CI services like GitHub Actions.
- meson
- conan
- make
- task
- ccache
- cppcheck
- clangtidy

View File

@ -33,6 +33,9 @@ inputs:
make:
description: "The make version to install."
required: false
task:
description: "The task version to install."
required: false
vcpkg:
description: "The vcpkg version to install."
required: false

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

@ -11,6 +11,7 @@ const DefaultVersions: Record<string, string> = {
meson: "0.61.1",
python: "3.8.10",
kcov: "v39",
task: "3.10.0",
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11",
}

View File

@ -2,6 +2,7 @@ import * as core from "@actions/core"
import { setupBrew } from "./brew/brew"
import { setupCcache } from "./ccache/ccache"
import { setupMake } from "./make/make"
import { setupTask } from "./task/task"
import { setupChocolatey } from "./chocolatey/chocolatey"
import { setupCmake } from "./cmake/cmake"
import { setupConan } from "./conan/conan"
@ -52,6 +53,7 @@ const setups = {
vcvarsall: setupVCVarsall,
kcov: setupKcov,
make: setupMake,
task: setupTask,
}
/** The tools that can be installed */
@ -77,6 +79,7 @@ const tools: Array<keyof typeof setups> = [
"vcvarsall",
"kcov",
"make",
"task",
]
/** The possible inputs to the program */

View File

@ -0,0 +1,17 @@
import { setupTask } from "../task"
import { setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin"
jest.setTimeout(300000)
describe("setup-task", () => {
let directory: string
beforeAll(async () => {
directory = await setupTmpDir("task")
})
it("should setup task", async () => {
const installInfo = await setupTask("3.10.0", directory, process.arch)
await testBin("task", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
})
})

48
src/task/task.ts Normal file
View File

@ -0,0 +1,48 @@
import { extractZip } from "@actions/tool-cache"
import { addBinExtension } from "../utils/extension/extension"
import { extractTarByExe } from "../utils/setup/extract"
import { setupBin, PackageInfo, InstallationInfo } from "../utils/setup/setupBin"
/** Get the platform name task uses in their download links */
function getTaskPlatform(platform: NodeJS.Platform) {
switch (platform) {
case "win32":
return "windows"
default:
return platform
}
}
/** Get the arch name task uses in their download links */
function getTaskArch(arch: string) {
switch (arch) {
case "x64":
return "amd64"
case "ia32":
case "x86":
case "i386":
case "x32":
return "386"
default:
return arch
}
}
/** Get the platform data for task */
function getTaskPackageInfo(version: string, platform: NodeJS.Platform, arch: string): PackageInfo {
const taskPlatform = getTaskPlatform(platform)
const taskArch = getTaskArch(arch)
const isZip = platform === "win32"
const extension = isZip ? "zip" : "tar.gz"
return {
binRelativeDir: "",
binFileName: addBinExtension("task"),
extractedFolderName: "",
extractFunction: isZip ? extractZip : extractTarByExe,
url: `https://github.com/go-task/task/releases/download/v${version}/task_${taskPlatform}_${taskArch}.${extension}`,
}
}
export function setupTask(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
return setupBin("task", version, getTaskPackageInfo, setupDir, arch)
}