Skip to content

Commit

Permalink
Merge pull request #29 from aminya/7zip [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Feb 6, 2022
2 parents 6aef987 + c65b6f6 commit 974628d
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ The package can be used locally or from CI services like GitHub Actions.
- gcovr
- opencppcoverage
- kcov

`setup-cpp` can also install the following. These are automatically installed if needed for the above Cpp tools (e.g., python is required for conan).

- python
- choco
- brew
- sevenzip

# Usage

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ inputs:
kcov:
description: "The kcov version to install."
required: false
sevenzip:
description: "The 7z version to install."
required: false

runs:
using: "node12"
Expand Down
2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { join } from "path"
import { setupVCVarsall } from "./vcvarsall/vcvarsall"
import { setupKcov } from "./kcov/kcov"
import { addEnv } from "./utils/env/addEnv"
import { setupSevenZip } from "./sevenzip/sevenzip"

/** The setup functions */
const setups = {
Expand All @@ -54,6 +55,7 @@ const setups = {
kcov: setupKcov,
make: setupMake,
task: setupTask,
sevenzip: setupSevenZip,
}

/** The tools that can be installed */
Expand All @@ -80,6 +82,7 @@ const tools: Array<keyof typeof setups> = [
"kcov",
"make",
"task",
"sevenzip",
]

/** The possible inputs to the program */
Expand Down Expand Up @@ -290,9 +293,11 @@ All the available tools:
--gcovr
--opencppcoverage
--kcov
--python
--choco
--brew
--sevenzip
`)
}

Expand Down
12 changes: 12 additions & 0 deletions src/sevenzip/__tests__/sevenzip.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { setupSevenZip } from "../sevenzip"
import { testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin"

jest.setTimeout(300000)
describe("setup-7z", () => {
it("should setup 7z", async () => {
const installInfo = await setupSevenZip("", "", process.arch)

await testBin("7z", ["--help"], (installInfo as InstallationInfo | undefined)?.binDir)
})
})
21 changes: 21 additions & 0 deletions src/sevenzip/sevenzip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupSevenZip(version: string, _setupDir: string, _arch: string) {
switch (process.platform) {
case "win32": {
return setupChocoPack("7zip", version)
}
case "darwin": {
return setupBrewPack("p7zip", version)
}
case "linux": {
return setupAptPack("p7zip-full", version)
}
default: {
throw new Error(`Unsupported platform`)
}
}
}
12 changes: 12 additions & 0 deletions src/utils/setup/extract.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import execa from "execa"
import { mkdirP } from "@actions/io"
import which from "which"
import { setupSevenZip } from "../../sevenzip/sevenzip"
export { extractTar, extractXar, extract7z, extractZip } from "@actions/tool-cache"

let sevenZip: string | undefined

export async function extractExe(file: string, dest: string) {
// install 7z if needed
if (sevenZip === undefined) {
if (which.sync("7z", { nothrow: true }) !== null) {
sevenZip = "7z"
}
await setupSevenZip("", "", process.arch)
}

await execa("7z", ["x", file, `-o${dest}`])
return dest
}
Expand Down

0 comments on commit 974628d

Please sign in to comment.