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

Pretty up previous TFC runs URLs list via markdown tables instead of just a list of URLs #35

Merged
merged 13 commits into from
Aug 10, 2023

Conversation

ahinh43
Copy link
Collaborator

@ahinh43 ahinh43 commented Aug 2, 2023

Closes #34

Updates the placement of the previous TFC run URLs to use a markdown table instead.

Previously, the list looked like this:

image

Here is the proposed format:

image

Additionally, using tables I added a Created at field to show an exact timestamp of when the run was created (based on the MR creation timestamp) to allow for an easier view of when a TF run was made.

And for compatibility with Github, I replaced the airplane_arriving emoji with 📥 as Github doesn't have the airplane arriving emoji.

Github testing

Unfortunately, I wasn't able to test these changes on Github as it doesn't seem like Github uses the MR run headers that Gitlab does. So while I've tested to make sure Github's functionality wasn't broken by these changes, I wasn't able to verify if the changes I ported from Gitlab also work on Github.

image

@ahinh43 ahinh43 marked this pull request as ready for review August 2, 2023 15:56
runUrlRaw := utils.CaptureSubstring(runUrl, "[", "]")
runUrlSplit := strings.Split(runUrlRaw, "/")
// The run ID is the last part of the run URL, and it looks like run-abcd12345...
runID := runUrlSplit[len(runUrlSplit)-1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should have a check to ensure that runUrlSplit > 0 so it won't panic

runUrlRaw := utils.CaptureSubstring(runUrl, "[", "]")
runUrlSplit := strings.Split(runUrlRaw, "/")
// The run ID is the last part of the run URL, and it looks like run-abcd12345...
runID := runUrlSplit[len(runUrlSplit)-1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should have a check to ensure that runUrlSplit > 0 so it won't panic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for catching that - I also added a else condition in the event the runUrlSplit check fails to just fallback to original URL that was used before just so the has something rather than just an awkward blank table entry

}

// Gitlab default sort is order by created by, so take the last match on this
oldRunBlockTest := utils.CaptureSubstring(note.Body, utils.URL_RUN_GROUP_PREFIX, utils.URL_RUN_GROUP_SUFFIX)
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could be rewritten like this

oldRunBlock = "\n"
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
}

}

// Github orders comments from earliest -> latest via ID, so we check each comment and take the last match on an "old url" block
oldRunBlockTest := utils.CaptureSubstring(comment.GetBody(), utils.URL_RUN_GROUP_PREFIX, utils.URL_RUN_GROUP_SUFFIX)
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could be rewritten like this

oldRunBlock = "\n"
if oldRunBlockTest != "" {
oldRunBlock = oldRunBlockTest
}

@ahinh43 ahinh43 requested a review from davidwin93 August 8, 2023 13:47
@davidwin93 davidwin93 merged commit 780416e into zapier:main Aug 10, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Previous TFC Urls list can get really messy if the URLs are too long in Gitlab
2 participants