Skip to content

Commit

Permalink
Merge branch 'main' into i4k-release-v0.11.5
Browse files Browse the repository at this point in the history
  • Loading branch information
i4ki authored Dec 20, 2024
2 parents 9c638dc + 6c43bed commit cbbe7ba
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cloud/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ type (
GithubCommitCommitterGitDate *time.Time `json:"github_commit_committer_git_date,omitempty"`

GithubActionsDeploymentBranch string `json:"github_actions_deployment_branch,omitempty"`
GithubActionsDeploymentActorID string `json:"github_actions_deployment_actor_id,omitempty"`
GithubActionsDeploymentActor string `json:"github_actions_deployment_actor,omitempty"`
GithubActionsDeploymentTriggeredBy string `json:"github_actions_triggered_by,omitempty"`
GithubActionsRunID string `json:"github_actions_run_id,omitempty"`
Expand Down Expand Up @@ -267,6 +268,7 @@ type (
GitlabCICDJobName string `json:"gitlab_cicd_job_name,omitempty"` // CI_JOB_NAME
GitlabCICDJobStartedAt string `json:"gitlab_cicd_job_started_at,omitempty"` // CI_JOB_STARTED_AT
GitlabCICDUserEmail string `json:"gitlab_cicd_user_email,omitempty"` // GITLAB_USER_EMAIL
GitlabCICDUserID string `json:"gitlab_cicd_user_id,omitempty"` // GITLAB_USER_ID
GitlabCICDUserName string `json:"gitlab_cicd_user_name,omitempty"` // GITLAB_USER_NAME
GitlabCICDUserLogin string `json:"gitlab_cicd_user_login,omitempty"` // GITLAB_USER_LOGIN
GitlabCICDCommitBranch string `json:"gitlab_cicd_commit_branch,omitempty"` // CI_COMMIT_BRANCH
Expand Down
16 changes: 14 additions & 2 deletions cmd/terramate/cli/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ func (c *cli) setGitlabCIMetadata(md *cloud.DeploymentMetadata) {
md.GitlabCICDJobStartedAt = os.Getenv("CI_JOB_STARTED_AT")
md.GitlabCICDUserEmail = os.Getenv("GITLAB_USER_EMAIL")
md.GitlabCICDUserName = os.Getenv("GITLAB_USER_NAME")
md.GitlabCICDUserID = os.Getenv("GITLAB_USER_ID")
md.GitlabCICDUserLogin = os.Getenv("GITLAB_USER_LOGIN")
md.GitlabCICDCommitBranch = os.Getenv("CI_COMMIT_BRANCH")
md.GitlabCICDBranch = md.GitlabCICDCommitBranch
Expand Down Expand Up @@ -1105,8 +1106,8 @@ func (c *cli) newBitbucketReviewRequest(pr *bitbucket.PR) *cloud.ReviewRequest {
UpdatedAt: &updatedAt,
Status: pr.State,
Author: cloud.Author{
Login: pr.Author.DisplayName,
ID: pr.Author.UUID,
Login: pr.Author.DisplayName,
AvatarURL: avatarURL,
},
Branch: c.cloud.run.metadata.BitbucketPipelinesBranch,
Expand Down Expand Up @@ -1300,6 +1301,7 @@ func setDefaultGitMetadata(md *cloud.DeploymentMetadata, commit *git.CommitMetad
}

func setGithubActionsMetadata(md *cloud.DeploymentMetadata) {
md.GithubActionsDeploymentActorID = os.Getenv("GITHUB_ACTOR_ID")
md.GithubActionsDeploymentActor = os.Getenv("GITHUB_ACTOR")
md.GithubActionsDeploymentTriggeredBy = os.Getenv("GITHUB_TRIGGERING_ACTOR")
md.GithubActionsDeploymentBranch = os.Getenv("GITHUB_REF_NAME")
Expand Down Expand Up @@ -1384,6 +1386,7 @@ func (c *cli) newGithubReviewRequest(
) *cloud.ReviewRequest {
author := cloud.Author{}
if user := pull.GetUser(); user != nil {
author.ID = strconv.Itoa64(int64(user.GetID()))
author.Login = user.GetLogin()
author.AvatarURL = user.GetAvatarURL()
}
Expand Down Expand Up @@ -1434,14 +1437,19 @@ func (c *cli) newGithubReviewRequest(
rr.ApprovedCount++
}

login := review.GetUser().GetLogin()
user := review.GetUser()
if user == nil {
continue
}

login := user.GetLogin()
if _, found := uniqueReviewers[login]; found {
continue
}
uniqueReviewers[login] = struct{}{}

rr.Reviewers = append(rr.Reviewers, cloud.Reviewer{
ID: strconv.Itoa64(user.GetID()),
Login: login,
AvatarURL: review.GetUser().GetAvatarURL(),
})
Expand Down Expand Up @@ -1487,6 +1495,7 @@ func (c *cli) newGitlabReviewRequest(mr gitlab.MR) *cloud.ReviewRequest {
UpdatedAt: &mrUpdatedAt,
Status: mr.State,
Author: cloud.Author{
ID: strconv.Itoa64(int64(mr.Author.ID)),
Login: mr.Author.Username,
AvatarURL: mr.Author.AvatarURL,
},
Expand All @@ -1500,6 +1509,9 @@ func (c *cli) newGitlabReviewRequest(mr gitlab.MR) *cloud.ReviewRequest {
Name: l,
})
}

// TODO(i4k): implement reviewers for Gitlab

return rr
}

Expand Down
20 changes: 13 additions & 7 deletions e2etests/cloud/run_cloud_sync_preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down Expand Up @@ -254,6 +255,7 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down Expand Up @@ -316,13 +318,17 @@ func TestCLIRunWithCloudSyncPreview(t *testing.T) {
Description: "Please pull these awesome changes in!",
URL: "https://github.com/octocat/Hello-World/pull/1347",
Labels: []cloud.Label{{Name: "bug", Color: "f29513", Description: "Something isn't working"}},
Author: cloud.Author{Login: "octocat", AvatarURL: "https://github.com/images/error/octocat_happy.gif"},
Status: "open",
CreatedAt: createdAt,
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Branch: "new-topic",
BaseBranch: "master",
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Status: "open",
CreatedAt: createdAt,
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Branch: "new-topic",
BaseBranch: "master",
},
StackPreviews: []*cloudstore.StackPreview{
{
Expand Down
2 changes: 2 additions & 0 deletions e2etests/cloud/run_script_cloud_preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func TestScriptRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down Expand Up @@ -295,6 +296,7 @@ func TestScriptRunWithCloudSyncPreview(t *testing.T) {
UpdatedAt: updatedAt,
PushedAt: &pushedAt,
Author: cloud.Author{
ID: "1",
Login: "octocat",
AvatarURL: "https://github.com/images/error/octocat_happy.gif",
},
Expand Down

0 comments on commit cbbe7ba

Please sign in to comment.