Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,28 @@ jobs:
with:
version: '9.21.0'
packages: 'Editor X:1.5.0-beta.41+2c6d736c,NATS Server,CSV'

test-install-path:
runs-on: ubuntu-24.04
name: Test Install Path Output
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ./ # Uses an action in the root directory
id: setup
with:
version: '9.32.3'
- name: Verify path output is under RUNNER_TEMP and tap is installed there
run: |
echo "setup path output: '$TAP_PATH'"
if [ -z "$TAP_PATH" ]; then
echo "::error::path output was not set"
exit 1
fi
case "$TAP_PATH" in
"$RUNNER_TEMP"/*) : ;;
*) echo "::error::install path is not under RUNNER_TEMP ($RUNNER_TEMP)"; exit 1 ;;
esac
test -x "$TAP_PATH/tap" || { echo "::error::tap not found at TAP_PATH"; exit 1; }
# tap should also be resolvable via PATH (added by core.addPath)
tap package list --installed
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ There are a few arguments to help you select the right version of OpenTAP to ins
- `architecture` - Defaults to the architecture of the runner
- `os` - Defaults to the OS of the runner
- `packages` - a list of additional packages to install. Format: `<name1>:<version1>,<name2>:<version2>`. This option requires `version` to be 9.17 or greater.

## Outputs

The temporary installation directory is available in the environment variable `TAP_PATH`, and prepended to `PATH`
42 changes: 34 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ const exec = require("@actions/exec");
const tc = require("@actions/tool-cache");
const fs = require("fs");
const os = require("os");
const path = require("path");

main().catch((error) => setFailed(error.message));

const INSTALL_DIRS = {
linux: "/opt/tap",
windows: "C:/Program Files/OpenTAP",
macos: "/Users/runner/Library/OpenTAP",
};
// Resolve a per-worker installation directory.
// This resolves conflicts when the same machine is simultaneously installing different OpenTAP images.
function getInstallDir() {
const base = process.env.RUNNER_TEMP || os.tmpdir();
return path.join(base, "OpenTAP");
}

function getArchitecture() {
// Map Node's os.arch() values to the architecture strings expected by the
Expand Down Expand Up @@ -83,13 +85,34 @@ async function extractZip(file, dest) {
}

try {
// Fall back to powershell if unzip is not available. This is the case on e.g.
// the official dotnet 8 SDK docker image, mcr.microsoft.com/dotnet/sdk:8.0
// Fall back to pwsh if unzip is not available. This is the case on e.g. the official dotnet 8 SDK docker image, mcr.microsoft.com/dotnet/sdk:8.0
await exec.exec("pwsh", ["-c", `Expand-Archive -Path "${file}" -DestinationPath "${dest}"`])
return true;
} catch {
// ignore
}


try {
// Fall back to powershell if pwsh is not available. This is the case on some Windows machines.
let script = `
$filename = "${file}"
$dest = "${dest}"
$ext = [IO.Path]::GetExtension($filename)
if ($ext -ne ".zip")
{
Move-Item "$filename" "$($filename).zip"
$filename = "$($filename).zip"
}
Expand-Archive -Path "$filename" -DestinationPath "$dest"
`;

await exec.exec("powershell.exe", ["-c", script])
return true;
} catch {
// ignore
}

return false
}

Expand Down Expand Up @@ -132,8 +155,9 @@ async function main() {

// Extract OpenTAP package
core.info("Unzipping OpenTAP: " + downloadedFilepath);
const destDir = INSTALL_DIRS[platform];
const destDir = getInstallDir();
const settingsDir = destDir + "/Settings/";
core.info("Installing OpenTAP to: " + destDir);
const extracted = await extractZip(downloadedFilepath, destDir);
if (!extracted) {
core.setFailed("Unable to extract zip archive.")
Expand All @@ -152,6 +176,8 @@ async function main() {

// Add to path env
core.addPath(destDir);
// Some plugins depend on this environment variable being set.
core.exportVariable('TAP_PATH', destDir);

// Install packages
if (core.getInput("packages")) {
Expand Down