Skip to content

Commit

Permalink
add log level and publish logs
Browse files Browse the repository at this point in the history
Signed-off-by: MarkAckert <[email protected]>
  • Loading branch information
MarkAckert committed Feb 1, 2024
1 parent cdf8276 commit 97dfeb9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/license-generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ on:
options:
- 'true'
- 'false'
ort_log_level:
description: Set ORT's Log Level. Defaults to 'warn'
required: false
type: choice
default: 'warn'
options:
- 'warn'
- 'info'
- 'error'
- 'debug'

env:
PUBLISH_RELEASE: ${{ github.event.inputs.publish_release }}
Expand Down Expand Up @@ -96,8 +106,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: '20'

- name: 'Install Ansible'
uses: zowe-actions/shared-actions/prepare-workflow@main

- name: '[Zowe Actions] Prepare workflow'
uses: zowe-actions/shared-actions/prepare-workflow@main

Expand Down Expand Up @@ -167,6 +179,8 @@ jobs:
cp build/sbom_reports/${{ env.CLI_SBOM_ARTIFACT_NAME }} ${{ env.CLI_SBOM_ARTIFACT_NAME }}
cp build/sbom_reports/${{ env.ZOS_SBOM_ARTIFACT_NAME }} ${{ env.ZOS_SBOM_ARTIFACT_NAME }}
zip -rj logs.zip build/logs/*
- name: Remove existing artifacts
id: cleanup
if: ${{ github.event.inputs.publish_release }} && ${{ github.event.inputs.overwrite_release }}
Expand Down Expand Up @@ -229,6 +243,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
path: |
${{ env.DEPENDENCY_SCAN_HOME }}/logs.zip
${{ env.DEPENDENCY_SCAN_HOME }}/${{ env.AGG_ARTIFACT_NAME }}
${{ env.DEPENDENCY_SCAN_HOME }}/${{ env.AGG_ARTIFACT_NAME }}.bundle
${{ env.DEPENDENCY_SCAN_HOME }}/${{ env.CLI_ARTIFACT_NAME }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export class OrtReportAction implements IAction {
console.log("Running ORT License and Notice report on " + resolvedDir);
const reportProcess = spawn("ort", ["report", "-i", resolvedDir + "/analyzer-result.json",
"-o", Constants.LICENSE_REPORTS_DIR + path.sep + path.basename(projectPath),
Constants.ORT_DEBUG_LEVEL,
"-f", "PlainTextTemplate",
"-O", "PlainTextTemplate=template.id=NOTICE_DEFAULT", // generates notices
"-O", `PlainTextTemplate=template.path=${Constants.SOURCE_RESOURCES_DIR}/../resources/tpsr-full-template.md.ftl` //generates tpsr section
Expand Down
1 change: 1 addition & 0 deletions licenses/dependency-scan/src/actions/ort/OrtSbomAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class OrtSbomAction implements IAction {
console.log("Running ORT SBOM generation for " + resolvedDir);
const reportProcess = spawn("ort", ["report", "-i", resolvedDir + "/analyzer-result.json",
"-o", Constants.SBOM_REPORTS_DIR + path.sep + path.basename(projectPath),
Constants.ORT_DEBUG_LEVEL,
"-O", `SpdxDocument=document.name=${path.basename(projectPath)}`,
"-f", "SpdxDocument"
], {
Expand Down
1 change: 1 addition & 0 deletions licenses/dependency-scan/src/actions/ort/OrtScanAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class OrtScanAction implements IAction {
projectDir,
"-o",
projectDir,
Constants.ORT_DEBUG_LEVEL,
"-f",
"JSON"], {
cwd: process.env.cwd,
Expand Down
2 changes: 2 additions & 0 deletions licenses/dependency-scan/src/constants/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ export class Constants {
public static readonly SCAN_AGGREGATE: boolean = Utilities.getEnv("ZOWE_SCAN_AGGREGATE", true);

public static readonly SKIP_INSTALL_SPECIFIC: string = Utilities.getEnvStr("SKIP_INSTALL_SPECIFIC", "")

public static readonly ORT_DEBUG_LEVEL: string = Utilities.getOrtDebug("ORT_DEBUG_LEVEL", "--warn");
}
17 changes: 17 additions & 0 deletions licenses/dependency-scan/src/utils/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,27 @@

import * as fs from "fs";
import * as path from "path";
import { env } from "process";
import { isNullOrUndefined } from "util";

export class Utilities {

public static getOrtDebug(envVar: string, defaultLevel: string): string {
const envValue = Utilities.getEnvStr(envVar, defaultLevel);
switch(envValue.toLowerCase()) {
case "info":
return "--info";
case "warn":
return "--warn";
case "debug":
return "--debug";
case "error":
return "--error";
default:
throw new Error(`Ort debug level set by ${envVar} must be one of 'info', 'debug', 'error', or 'warn'. Defaults to 'warn'` );
}
}

public static getEnvStr(envVar: string, defaultValue: string = ""): string {
if (!isNullOrUndefined(process.argv) && process.argv.includes(envVar)) {
const argIndex = process.argv.indexOf(envVar);
Expand Down

0 comments on commit 97dfeb9

Please sign in to comment.