Skip to content

Commit 9fe0f98

Browse files
authored
Upgrade Default CLI version (#208)
1 parent 883a85f commit 9fe0f98

File tree

10 files changed

+58
-13
lines changed

10 files changed

+58
-13
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ To read more about the JFrog CLI supported commands, visit the following link:
350350
[JFrog CLI Command Summaries Documentation](https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli/cli-command-summaries).
351351

352352
## Code Scanning Alerts
353+
354+
**Note:** To use code scanning alerts, ensure you are using JFrog CLI version `v2.67.0` or above.
355+
356+
353357
The action also supports the display of code scanning alerts in the GitHub Actions UI.
354358

355359
Code scanning alerts are generated following the execution of the `jf docker scan` and `jf scan` commands.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: "JFrog"
44
inputs:
55
version:
66
description: "JFrog CLI Version"
7-
default: "2.66.0"
7+
default: "2.67.0"
88
required: false
99
download-repository:
1010
description: "Remote repository in Artifactory pointing to 'https://releases.jfrog.io/artifactory/jfrog-cli'. Use this parameter in case you don't have an Internet access."

lib/cleanup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ function collectAndPublishBuildInfoIfNeeded() {
141141
core.startGroup('Publish the build info to JFrog Artifactory');
142142
yield utils_1.Utils.runCli(['rt', 'build-publish'], { cwd: workingDirectory });
143143
}
144+
catch (error) {
145+
core.warning('Failed while attempting to publish the build info to JFrog Artifactory: ' + error);
146+
}
144147
finally {
145148
core.endGroup();
146149
}

lib/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ class Utils {
489489
}
490490
static isJobSummarySupported() {
491491
const version = core.getInput(Utils.CLI_VERSION_ARG);
492-
return version === Utils.LATEST_CLI_VERSION || (0, semver_1.gt)(version, Utils.MIN_CLI_VERSION_JOB_SUMMARY);
492+
return version === Utils.LATEST_CLI_VERSION || (0, semver_1.gte)(version, Utils.MIN_CLI_VERSION_JOB_SUMMARY);
493493
}
494494
/**
495495
* Generates GitHub workflow unified Summary report.
@@ -603,7 +603,7 @@ class Utils {
603603
const finalSarifFile = path.join(Utils.getJobOutputDirectoryPath(), this.SECURITY_DIR_NAME, this.SARIF_REPORTS_DIR_NAME, this.CODE_SCANNING_FINAL_SARIF_FILE);
604604
if (!(0, fs_1.existsSync)(finalSarifFile)) {
605605
console.debug('No code scanning sarif file was found.');
606-
return "";
606+
return '';
607607
}
608608
// Read the SARIF file, compress and encode it to match the code-scanning/sarif API requirements.
609609
const sarif = yield fs_1.promises.readFile(finalSarifFile, 'utf-8');

node_modules/.package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jfrog/setup-jfrog-cli",
3-
"version": "4.4.0",
3+
"version": "4.4.1",
44
"private": true,
55
"description": "Setup JFrog CLI in GitHub Actions",
66
"main": "lib/main.js",

src/cleanup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ async function collectAndPublishBuildInfoIfNeeded() {
107107
try {
108108
core.startGroup('Publish the build info to JFrog Artifactory');
109109
await Utils.runCli(['rt', 'build-publish'], { cwd: workingDirectory });
110+
} catch (error) {
111+
core.warning('Failed while attempting to publish the build info to JFrog Artifactory: ' + error);
110112
} finally {
111113
core.endGroup();
112114
}

src/utils.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { OutgoingHttpHeaders } from 'http';
77
import { arch, platform, tmpdir } from 'os';
88
import * as path from 'path';
99
import { join } from 'path';
10-
import { gt, lt } from 'semver';
10+
import { gte, lt } from 'semver';
1111
import { Octokit } from '@octokit/core';
1212
import { OctokitResponse } from '@octokit/types/dist-types/OctokitResponse';
1313
import * as github from '@actions/github';
@@ -547,7 +547,7 @@ export class Utils {
547547

548548
public static isJobSummarySupported(): boolean {
549549
const version: string = core.getInput(Utils.CLI_VERSION_ARG);
550-
return version === Utils.LATEST_CLI_VERSION || gt(version, Utils.MIN_CLI_VERSION_JOB_SUMMARY);
550+
return version === Utils.LATEST_CLI_VERSION || gte(version, Utils.MIN_CLI_VERSION_JOB_SUMMARY);
551551
}
552552

553553
/**
@@ -654,15 +654,20 @@ export class Utils {
654654
* @returns <string[]> the paths of the code scanning sarif files.
655655
*/
656656
private static async getCodeScanningEncodedSarif(): Promise<string> {
657-
const finalSarifFile: string = path.join(Utils.getJobOutputDirectoryPath(), this.SECURITY_DIR_NAME, this.SARIF_REPORTS_DIR_NAME, this.CODE_SCANNING_FINAL_SARIF_FILE);
657+
const finalSarifFile: string = path.join(
658+
Utils.getJobOutputDirectoryPath(),
659+
this.SECURITY_DIR_NAME,
660+
this.SARIF_REPORTS_DIR_NAME,
661+
this.CODE_SCANNING_FINAL_SARIF_FILE,
662+
);
658663
if (!existsSync(finalSarifFile)) {
659664
console.debug('No code scanning sarif file was found.');
660-
return "";
665+
return '';
661666
}
662667

663668
// Read the SARIF file, compress and encode it to match the code-scanning/sarif API requirements.
664669
const sarif: string = await fs.readFile(finalSarifFile, 'utf-8');
665-
return await this.compressAndEncodeSarif(sarif)
670+
return await this.compressAndEncodeSarif(sarif);
666671
}
667672

668673
private static async readMarkdownContent() {

test/main.spec.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import * as os from 'os';
22
import * as core from '@actions/core';
33

44
import { Utils, DownloadDetails, JfrogCredentials, JWTTokenData } from '../src/utils';
5-
import { tmpdir } from 'os';
5+
import semver = require('semver/preload');
66
jest.mock('os');
77
jest.mock('@actions/core');
8+
jest.mock('semver');
89

910
const DEFAULT_CLI_URL: string = 'https://releases.jfrog.io/artifactory/jfrog-cli/';
1011
const CUSTOM_CLI_URL: string = 'http://127.0.0.1:8081/artifactory/jfrog-cli-remote/';
@@ -365,3 +366,33 @@ describe('Job Summaries', () => {
365366
});
366367
});
367368
});
369+
370+
describe('isJobSummarySupported', () => {
371+
const MIN_CLI_VERSION_JOB_SUMMARY: string = '2.66.0';
372+
const LATEST_CLI_VERSION: string = 'latest';
373+
374+
beforeEach(() => {
375+
jest.resetAllMocks();
376+
});
377+
378+
it('should return true if the version is the latest', () => {
379+
jest.spyOn(core, 'getInput').mockReturnValue(LATEST_CLI_VERSION);
380+
expect(Utils.isJobSummarySupported()).toBe(true);
381+
});
382+
383+
it('should return true if the version is greater than or equal to the minimum supported version', () => {
384+
const version: string = '2.66.0';
385+
jest.spyOn(core, 'getInput').mockReturnValue(version);
386+
(semver.gte as jest.Mock).mockReturnValue(true);
387+
expect(Utils.isJobSummarySupported()).toBe(true);
388+
expect(semver.gte).toHaveBeenCalledWith(version, MIN_CLI_VERSION_JOB_SUMMARY);
389+
});
390+
391+
it('should return false if the version is less than the minimum supported version', () => {
392+
const version: string = '2.65.0';
393+
jest.spyOn(core, 'getInput').mockReturnValue(version);
394+
(semver.gte as jest.Mock).mockReturnValue(false);
395+
expect(Utils.isJobSummarySupported()).toBe(false);
396+
expect(semver.gte).toHaveBeenCalledWith(version, MIN_CLI_VERSION_JOB_SUMMARY);
397+
});
398+
});

0 commit comments

Comments
 (0)