Skip to content

Commit

Permalink
[fix] Use correct format for GH run URL (#11246)
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-cordenier authored Nov 9, 2023
1 parent 0128650 commit b811f00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/flakeytests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func getGithubMetadata(repo string, eventName string, sha string, e io.Reader, r
log.Fatalf("Error unmarshaling gh event at path")
}

runURL := fmt.Sprintf("%s/actions/%s", repo, runID)
runURL := fmt.Sprintf("github.com/%s/actions/runs/%s", repo, runID)
basicCtx := &Context{Repository: repo, CommitSHA: sha, Type: eventName, RunURL: runURL}
switch eventName {
case "pull_request":
Expand Down
5 changes: 3 additions & 2 deletions tools/flakeytests/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ var prEventTemplate = `

func TestGetGithubMetadata(t *testing.T) {
repo, eventName, sha, event, runID := "chainlink", "merge_group", "a-sha", `{}`, "1234"
expectedRunURL := fmt.Sprintf("github.com/%s/actions/runs/%s", repo, runID)
ctx := getGithubMetadata(repo, eventName, sha, strings.NewReader(event), runID)
assert.Equal(t, Context{Repository: repo, CommitSHA: sha, Type: eventName, RunURL: fmt.Sprintf("%s/actions/%s", repo, runID)}, ctx)
assert.Equal(t, Context{Repository: repo, CommitSHA: sha, Type: eventName, RunURL: expectedRunURL}, ctx)

anotherSha, eventName, url := "another-sha", "pull_request", "a-url"
event = fmt.Sprintf(prEventTemplate, anotherSha, url)
sha = "302eb05d592132309b264e316f443f1ceb81b6c3"
ctx = getGithubMetadata(repo, eventName, sha, strings.NewReader(event), runID)
assert.Equal(t, Context{Repository: repo, CommitSHA: anotherSha, Type: eventName, PullRequestURL: url, RunURL: fmt.Sprintf("%s/actions/%s", repo, runID)}, ctx)
assert.Equal(t, Context{Repository: repo, CommitSHA: anotherSha, Type: eventName, PullRequestURL: url, RunURL: expectedRunURL}, ctx)
}

0 comments on commit b811f00

Please sign in to comment.