Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Summary - New record functionality #1230

Merged
merged 38 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2ee90d5
Remove the creation of markdown to CLI
EyalDelarea Aug 12, 2024
97bc6db
Change UI
EyalDelarea Aug 13, 2024
d11ebf7
Add new sub dir type
EyalDelarea Aug 14, 2024
e565dee
Handle all subjects file saves
EyalDelarea Aug 14, 2024
8659ac1
revert ui changes
EyalDelarea Aug 14, 2024
94aa2f8
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli-core into co…
EyalDelarea Aug 14, 2024
75bc8e6
revert ui changes
EyalDelarea Aug 14, 2024
4722d1d
Fix markdown tests
EyalDelarea Aug 14, 2024
2b4995c
Fix static analysis
EyalDelarea Aug 14, 2024
9b6ffdf
Fix slashes on windows
EyalDelarea Aug 14, 2024
86bc35b
rename
EyalDelarea Aug 14, 2024
50b5b72
Rename to index
EyalDelarea Aug 14, 2024
ca7ae31
Fix golint
EyalDelarea Aug 14, 2024
0df5f36
Fix windows
EyalDelarea Aug 14, 2024
349410c
Use filepath instead of path for windows support
EyalDelarea Aug 14, 2024
3ddddea
Handle all unsupported file name chars
EyalDelarea Aug 14, 2024
991677d
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli-core into co…
EyalDelarea Aug 15, 2024
7628451
Renames
EyalDelarea Aug 15, 2024
6f189da
Refactor
EyalDelarea Aug 15, 2024
760c583
CR
EyalDelarea Aug 15, 2024
74d2515
CR
EyalDelarea Aug 15, 2024
ecb37bb
Handle index differently, and export get files functions
EyalDelarea Aug 15, 2024
0a614a9
Rename
EyalDelarea Aug 15, 2024
48f9308
Fix publish diff
EyalDelarea Aug 15, 2024
6389a2d
use new function
EyalDelarea Aug 18, 2024
2fad965
use new function
EyalDelarea Aug 18, 2024
4e29f37
Fix golangci linter
EyalDelarea Aug 18, 2024
e7804fa
Format
EyalDelarea Aug 18, 2024
05f136a
If no files found, skip markdown generation
EyalDelarea Aug 18, 2024
ddf89fe
Change files structure
EyalDelarea Aug 19, 2024
d4785be
Fix testdata location
EyalDelarea Aug 19, 2024
20986fb
Move command summary files
EyalDelarea Aug 19, 2024
781802d
Save indexed file names as SHA1 instead of dealing with invalid chars.
EyalDelarea Aug 20, 2024
f7caf13
Pull dev
EyalDelarea Aug 20, 2024
13faa80
supress go lint
EyalDelarea Aug 20, 2024
6b417bc
Fix lint
EyalDelarea Aug 20, 2024
4e39249
Merge branch 'dev' of https://github.com/jfrog/jfrog-cli-core into co…
EyalDelarea Aug 21, 2024
102b69c
Move defer function
EyalDelarea Aug 21, 2024
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
6 changes: 3 additions & 3 deletions artifactory/commands/buildinfo/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (bpc *BuildPublishCommand) Run() error {
return err
}

if err = recordCommandSummary(buildInfo, buildLink, bpc.serverDetails.Url, majorVersion); err != nil {
if err = recordCommandSummary(buildInfo, buildLink); err != nil {
return err
}

Expand Down Expand Up @@ -232,12 +232,12 @@ func (bpc *BuildPublishCommand) getNextBuildNumber(buildName string, servicesMan
return strconv.Itoa(latestBuildNumber), nil
}

func recordCommandSummary(buildInfo *buildinfo.BuildInfo, buildLink, serverUrl string, majorVersion int) (err error) {
func recordCommandSummary(buildInfo *buildinfo.BuildInfo, buildLink string) (err error) {
if !commandsummary.ShouldRecordSummary() {
return
}
buildInfo.BuildUrl = buildLink
buildInfoSummary, err := commandsummary.New(commandssummaries.NewBuildInfo(serverUrl, majorVersion), "build-info")
buildInfoSummary, err := commandsummary.New(commandssummaries.NewBuildInfo(), "build-info")
if err != nil {
return
}
Expand Down
21 changes: 13 additions & 8 deletions artifactory/commands/commandssummaries/buildinfosummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ const (
)

Copy link
Contributor

Choose a reason for hiding this comment

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

The entire commandssummaries package is located directory under the artifactory/commands package. This is wriwrongng, because commandssummaries isn't a command.
I therefore suggest moving the entire commandssummaries directory to be under artifactory/utils.

type BuildInfoSummary struct {
platformUrl string
majorVersion int
platformUrl string
majorVersion int
nestedFilePaths map[commandsummary.Index]map[string]string
}

func NewBuildInfo(platformUrl string, majorVersion int) *BuildInfoSummary {
func NewBuildInfoWithUrl(platformUrl string, majorVersion int) *BuildInfoSummary {
return &BuildInfoSummary{
platformUrl: platformUrl,
majorVersion: majorVersion,
}
}
func NewBuildInfo() *BuildInfoSummary {
return &BuildInfoSummary{}
}

func (bis *BuildInfoSummary) GenerateMarkdownFromFiles(dataFilePaths []string) (finalMarkdown string, err error) {
func (bis *BuildInfoSummary) GenerateMarkdownFromFiles(dataFilePaths []string, nestedFilePaths map[commandsummary.Index]map[string]string) (finalMarkdown string, err error) {
bis.nestedFilePaths = nestedFilePaths
// Aggregate all the build info files into a slice
var builds []*buildInfo.BuildInfo
for _, path := range dataFilePaths {
Expand All @@ -46,8 +51,8 @@ func (bis *BuildInfoSummary) GenerateMarkdownFromFiles(dataFilePaths []string) (
func (bis *BuildInfoSummary) buildInfoTable(builds []*buildInfo.BuildInfo) string {
// Generate a string that represents a Markdown table
var tableBuilder strings.Builder
tableBuilder.WriteString("\n\n ### Published Build Infos \n\n")
tableBuilder.WriteString("\n\n| Build Info | Time Stamp | \n")
tableBuilder.WriteString("\n\n### Published Build Infos\n\n")
tableBuilder.WriteString("\n\n| Build Info | Time Stamp |\n")
tableBuilder.WriteString("|---------|------------| \n")
for _, build := range builds {
buildTime := parseBuildTime(build.Started)
Expand All @@ -59,7 +64,7 @@ func (bis *BuildInfoSummary) buildInfoTable(builds []*buildInfo.BuildInfo) strin

func (bis *BuildInfoSummary) buildInfoModules(builds []*buildInfo.BuildInfo) string {
var markdownBuilder strings.Builder
markdownBuilder.WriteString("\n\n ### Modules Published As Part of This Build \n\n")
markdownBuilder.WriteString("\n\n### Modules Published As Part of This Build\n\n")
var shouldGenerate bool
for _, build := range builds {
for _, module := range build.Modules {
Expand Down Expand Up @@ -97,7 +102,7 @@ func parseBuildTime(timestamp string) string {

func (bis *BuildInfoSummary) generateModuleMarkdown(module buildInfo.Module) string {
var moduleMarkdown strings.Builder
moduleMarkdown.WriteString(fmt.Sprintf("\n #### %s \n", module.Id))
moduleMarkdown.WriteString(fmt.Sprintf("\n#### %s\n", module.Id))
artifactsTree := utils.NewFileTree()
for _, artifact := range module.Artifacts {
artifactUrlInArtifactory := bis.generateArtifactUrl(artifact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestBuildInfoModules(t *testing.T) {
Modules: []buildinfo.Module{
{
Type: buildinfo.Maven,
Id: "maven",
Artifacts: []buildinfo.Artifact{{
Name: "artifact1",
Path: "path/to/artifact1",
Expand All @@ -47,6 +48,7 @@ func TestBuildInfoModules(t *testing.T) {
},
{
Type: buildinfo.Generic,
Id: "generic",
Artifacts: []buildinfo.Artifact{{
Name: "artifact2",
Path: "path/to/artifact2",
Expand Down
6 changes: 3 additions & 3 deletions artifactory/commands/commandssummaries/testdata/modules.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


### Modules Published As Part of This Build
### Modules Published As Part of This Build


####
#### maven


<pre>📦 libs-release
Expand All @@ -12,7 +12,7 @@
└── <a href=https://myplatform.com/ui/repos/tree/General/libs-release/path/to/artifact1?clearFilter=true target="_blank">artifact1</a>

</pre>
####
#### generic


<pre>📦 generic-local
Expand Down
4 changes: 2 additions & 2 deletions artifactory/commands/commandssummaries/testdata/table.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@


### Published Build Infos
### Published Build Infos



| Build Info | Time Stamp |
| Build Info | Time Stamp |
|---------|------------|
| [buildName 123](http://myJFrogPlatform/builds/buildName/123) | May 5, 2024 , 12:47:20 |

Expand Down
6 changes: 3 additions & 3 deletions artifactory/commands/commandssummaries/uploadsummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func NewUploadSummary(platformUrl string, majorVersion int) *UploadSummary {
}
}

func (us *UploadSummary) GenerateMarkdownFromFiles(dataFilePaths []string) (markdown string, err error) {
func (us *UploadSummary) GenerateMarkdownFromFiles(dataFilePaths []string, _ map[commandsummary.Index]map[string]string) (markdown string, err error) {
if err = us.loadResults(dataFilePaths); err != nil {
return
}
// Wrap the markdown in a <pre> tags to preserve spaces
markdown = fmt.Sprintf("\n<pre>\n\n\n" + us.generateFileTreeMarkdown() + "</pre>\n\n")
// Wrap the Markdown in a <pre> tags to preserve spaces
markdown = fmt.Sprintf("\n<pre>\n\n\n%s</pre>\n\n", us.generateFileTreeMarkdown())
return
}

Expand Down
Loading
Loading