Skip to content

Commit

Permalink
fix(download); fix download and execution paths (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malinskiy authored Feb 7, 2024
1 parent b8afc8e commit 33d5fce
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 214 deletions.
38 changes: 1 addition & 37 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,16 @@ on:
- cron: '0 0 * * *' # daily at 00:00 UTC

jobs:
test-latest-versions:
strategy:
matrix:
version:
- latest
- '*'
- ''
- '0.1.1'
skip-cache:
- true
- false
uses: ./.github/workflows/test-marathon-cloud.yaml
with:
version: ${{ matrix.version }}
skip-cache: ${{ matrix.skip-cache }}
with-github-token: 'true'
secrets: inherit

test-specified-versions-no-github-token:
strategy:
matrix:
version:
- '0.1.0'
- '0.1.1'
skip-cache:
- true
- false
uses: ./.github/workflows/test-marathon-cloud.yaml
with:
version: ${{ matrix.version }}
skip-cache: ${{ matrix.skip-cache }}
with-github-token: 'false'
secrets: inherit

test-specified-versions-with-github-token:
strategy:
matrix:
version:
- '0.1.0'
- '0.1.1'
- '1.0.0'
skip-cache:
- true
- false
uses: ./.github/workflows/test-marathon-cloud.yaml
with:
version: ${{ matrix.version }}
skip-cache: ${{ matrix.skip-cache }}
with-github-token: 'true'
secrets: inherit
35 changes: 0 additions & 35 deletions .github/workflows/test-marathon-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,23 @@ on:
version:
description: 'marathon-cloud version to use'
required: true
default: '*'
skip-cache:
description: 'skip cache?'
required: false
default: 'false'
with-github-token:
description: 'with github token?'
required: false
default: 'true'
# for integration testing
workflow_call:
inputs:
version:
type: string
description: 'marathon-cloud version to use'
required: true
default: '*'
skip-cache:
type: string
description: 'skip cache?'
required: false
default: 'false'
with-github-token:
type: string
description: 'with github token?'
required: false
default: 'true'

jobs:
test-with-github-token:
strategy:
matrix:
# TODO(hbc): add ARM64 runners
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
if: ${{ inputs.with-github-token == 'true' }}

steps:
- uses: actions/checkout@v3
name: Checkout code
- uses: ./ # use current branch
name: Setup marathon-cloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTIONS_STEP_DEBUG: true
with:
version: ${{ inputs.version }}
skip-cache: ${{ inputs.skip-cache }}
- run: |
marathon-cloud --help
name: Invoke marathon-cloud
test-without-github-token:
strategy:
matrix:
Expand Down
122 changes: 49 additions & 73 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6587,59 +6587,14 @@ exports["default"] = _default;
/***/ }),

/***/ 1772:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
/***/ ((__unused_webpack_module, exports) => {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.releaseArtifactURL = exports.resolveLatestVersion = exports.isLatestVersion = void 0;
const core = __importStar(__nccwpck_require__(2186));
exports.releaseArtifactURL = void 0;
const REPO_OWNER = 'MarathonLabs';
const REPO = 'marathon-cloud-cli';
function isLatestVersion(version) {
const v = version.toLowerCase();
return v === 'latest' || v === '*' || v === '';
}
exports.isLatestVersion = isLatestVersion;
function resolveLatestVersion() {
return __awaiter(this, void 0, void 0, function* () {
core.warning(`setup-marathon-cloud@v1 supports marathon-cloud cli up to 0.3.X. To use marathon-cloud cli v1+ use setup-marathon-cloud@v2`);
return '0.3.11';
});
}
exports.resolveLatestVersion = resolveLatestVersion;
function releaseArtifactURL(paths) {
return `https://github.com/${REPO_OWNER}/${REPO}/releases/download/${paths.join('/')}`;
}
Expand Down Expand Up @@ -6762,16 +6717,16 @@ function resolvePlatform() {
const platform = process.platform;
const arch = process.arch;
if (platform === 'darwin') {
return 'darwin_all';
return 'universal-apple-darwin';
}
else if (platform === 'linux' && arch === 'x64') {
return 'linux_amd64';
return 'x86_64-unknown-linux-gnu';
}
else if (platform === 'linux' && arch === 'arm64') {
return 'linux_arm64';
return 'aarch64-unknown-linux-gnu';
}
else if (platform === 'win32' && arch === 'x64') {
return 'windows_amd64';
return 'x86_64-pc-windows-msvc';
}
else {
throw new Error(`Unsupported platform: ${platform}_${arch}`);
Expand All @@ -6780,21 +6735,16 @@ function resolvePlatform() {
// getReleaseArtifact retrieves a release artifact with specified version and platform.
// platform is resolved automatically if not specified.
function getReleaseArtifact(version, platform) {
return __awaiter(this, void 0, void 0, function* () {
if ((0, gh_1.isLatestVersion)(version)) {
version = yield (0, gh_1.resolveLatestVersion)();
}
platform = platform || resolvePlatform();
const extension = resolveExtension(platform);
const artifactName = `${TOOL_NAME}_${platform}-${version}.${extension}`;
return {
version,
platform,
artifactName,
artifactUrl: (0, gh_1.releaseArtifactURL)([version, artifactName]),
checksumUrl: (0, gh_1.releaseArtifactURL)([version, `checksums.txt`]),
};
});
platform = platform || resolvePlatform();
const extension = resolveExtension(platform);
const artifactName = `${TOOL_NAME}-v${version}-${platform}.${extension}`;
return {
version,
platform,
artifactName,
artifactUrl: (0, gh_1.releaseArtifactURL)([version, artifactName]),
checksumUrl: (0, gh_1.releaseArtifactURL)([version, `checksums.txt`]),
};
}
exports.getReleaseArtifact = getReleaseArtifact;
function resolveBinaryPath(artifact, dir) {
Expand Down Expand Up @@ -6835,11 +6785,13 @@ function downloadAndCache(artifact) {
core.debug(`Downloaded ${artifact.checksumUrl} to ${artifactChecksum}`);
yield verifyChecksum(artifactZipball, artifact.artifactName, artifactChecksum);
core.debug(`Verified checksum of ${artifactZipball}`);
const artifactFolder = os_1.platform.name.startsWith('win')
const extractedPath = os_1.platform.name.startsWith('win')
? yield tc.extractZip(artifactZipball)
: yield tc.extractTar(artifactZipball);
core.debug(`Extracted ${artifactZipball} to ${artifactFolder}`);
const cachedDir = yield tc.cacheDir(artifactFolder, TOOL_NAME, artifact.version);
core.debug(`Extracted ${artifactZipball} to ${extractedPath}`);
const archiveName = fs.readdirSync(extractedPath)[0];
const archivePath = path_1.default.join(extractedPath, archiveName);
const cachedDir = yield tc.cacheDir(archivePath, TOOL_NAME, artifact.version);
const rv = resolveBinaryPath(artifact, cachedDir);
core.debug(`Cached ${TOOL_NAME} to ${rv}`);
return rv;
Expand Down Expand Up @@ -6868,7 +6820,9 @@ function setupArtifact(artifact, skipCache) {
exports.setupArtifact = setupArtifact;
function resolveExtension(platform) {
switch (platform) {
case 'windows_amd64':
case 'x86_64-pc-windows-gnu':
case 'x86_64-pc-windows-msvc':
case 'i686-pc-windows-msvc':
return 'zip';
default:
return 'tar.gz';
Expand Down Expand Up @@ -6918,16 +6872,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const release_1 = __nccwpck_require__(7776);
const semver_1 = __nccwpck_require__(8593);
const inputNameVersion = 'version';
const inputNameSkipCache = 'skip-cache';
function main() {
return __awaiter(this, void 0, void 0, function* () {
const version = core.getInput(inputNameVersion);
const skipCache = core.getInput(inputNameSkipCache) === 'true';
core.debug(`version: ${version} skip-cache: ${skipCache}`);
const artifact = yield (0, release_1.getReleaseArtifact)(version);
core.debug(`Resolved artifact: ${JSON.stringify(artifact)}`);
yield (0, release_1.setupArtifact)(artifact, skipCache);
if ((0, semver_1.validateMajorVersion)(version, '1')) {
const artifact = yield (0, release_1.getReleaseArtifact)(version);
core.debug(`Resolved artifact: ${JSON.stringify(artifact)}`);
yield (0, release_1.setupArtifact)(artifact, skipCache);
}
else {
core.setFailed(`Unsupported cli version ${version}. This action supports version ${1}`);
}
});
}
try {
Expand All @@ -6938,6 +6898,22 @@ catch (e) {
}


/***/ }),

/***/ 8593:
/***/ ((__unused_webpack_module, exports) => {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.validateMajorVersion = void 0;
function validateMajorVersion(versionString, supported) {
const majorVersion = versionString.split('.')[0];
return majorVersion === supported;
}
exports.validateMajorVersion = validateMajorVersion;


/***/ }),

/***/ 9491:
Expand Down
Loading

0 comments on commit 33d5fce

Please sign in to comment.