Skip to content

Command Summary - Invoke summary generation from the CLI#2653

Merged
EyalDelarea merged 26 commits intojfrog:devfrom
EyalDelarea:command_summary_to_cli
Aug 28, 2024
Merged

Command Summary - Invoke summary generation from the CLI#2653
EyalDelarea merged 26 commits intojfrog:devfrom
EyalDelarea:command_summary_to_cli

Conversation

@EyalDelarea
Copy link
Copy Markdown
Contributor

@EyalDelarea EyalDelarea commented Aug 14, 2024

  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....

Command Summary Generation Shifted to CLI

Previous Approach

The setup-jfrog-cli GitHub action was responsible for collecting markdown data and generating a single summary.

New Approach

The CLI now directly invokes each summary implementation’s markdown generation function, combining all outputs into a unified markdown summary.

Benefits:

  1. The complex logic is moved from the GitHub action to the CLI.
  2. The CLI handles the nested views of security results and artifacts, accommodating dependency chains more effectively.
  3. Enables control over generating either extended or basic summaries.
  4. Improves efficiency by avoiding markdown generation during every record function.

New Command jf generate-summary-markdown

Depends on:
jfrog/jfrog-cli-core#1238
jfrog/setup-jfrog-cli#186

@EyalDelarea EyalDelarea marked this pull request as ready for review August 18, 2024 13:06
@EyalDelarea EyalDelarea added the improvement Automatically generated release notes label Aug 18, 2024
@EyalDelarea EyalDelarea changed the title New command to generate summary markdown Command Summary - Invoke summary generation from the CLI Aug 21, 2024
@EyalDelarea EyalDelarea added the safe to test Approve running integration tests on a pull request label Aug 25, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 25, 2024
@EyalDelarea EyalDelarea requested a review from eyalbe4 August 25, 2024 08:20
}

// Creates a final summary of recorded CLI commands that were executed on the current machine.
// The summary is generated in Markdown format and saved in the root directory of JFROG_CLI_COMMAND_SUMMARY_OUTPUT_DIR.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...saved in the root directory of JFROG_CLI_COMMAND_SUMMARY_OUTPUT_DIR.
-->
...saved in the directory stored in the JFROG_CLI_COMMAND_SUMMARY_OUTPUT_DIR environment variabke.

Comment on lines +44 to +45
return fmt.Errorf("cannot generate command summary: the output directory for command recording is not defined. "+
"Please set the environment variable %s before executing your commands to view their summary", coreutils.OutputDirPathEnv)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's improve this message to be more user friendly.
How about -

return fmt.Errorf("unable to generate the command summary because the output directory is not specified. Please ensure that the environment variable '%s' is set before running your commands to enable summary generation.", coreutils.OutputDirPathEnv)

Also note that coreutils.OutputDirPathEnv is too generic of a description this variable.
Let's use coreutils.SummaryOutputDirPathEnv.

// Get URL and Version to generate summary links
serverUrl, majorVersion, err := extractServerUrlAndVersion(c)
if err != nil {
log.Warn("Failed to get server URL or major version: %v. This means markdown URLs will be invalid!", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not returning the error, and just adding a warning message?
We need a very good reason to ignore error messages. Let's discuss this.

return platformDetails, nil
}

func extractServerUrlAndVersion(c *cli.Context) (string, int, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's used named return values, to make the code easier to read.

@EyalDelarea EyalDelarea added the safe to test Approve running integration tests on a pull request label Aug 26, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 26, 2024
@EyalDelarea EyalDelarea added the safe to test Approve running integration tests on a pull request label Aug 28, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 28, 2024
@EyalDelarea EyalDelarea added the safe to test Approve running integration tests on a pull request label Aug 28, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Aug 28, 2024
@github-actions
Copy link
Copy Markdown
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@EyalDelarea EyalDelarea merged commit b7ff741 into jfrog:dev Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants