Skip to content

Commit

Permalink
Merge pull request #1692 from smit-modi/job-event
Browse files Browse the repository at this point in the history
Updated Job event
  • Loading branch information
svanharmelen committed Apr 13, 2023
2 parents 55d7024 + 0598ed8 commit d3711a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
13 changes: 8 additions & 5 deletions event_webhook_types.go
Expand Up @@ -352,9 +352,9 @@ type JobEvent struct {
BuildStartedAt string `json:"build_started_at"`
BuildFinishedAt string `json:"build_finished_at"`
BuildDuration float64 `json:"build_duration"`
BuildQueuedDuration float64 `json:"build_queued_duration"`
BuildAllowFailure bool `json:"build_allow_failure"`
BuildFailureReason string `json:"build_failure_reason"`
BuildQueuedDuration float64 `json:"build_queued_duration"`
RetriesCount int `json:"retries_count"`
PipelineID int `json:"pipeline_id"`
ProjectID int `json:"project_id"`
Expand All @@ -375,11 +375,14 @@ type JobEvent struct {
} `json:"commit"`
Repository *Repository `json:"repository"`
Runner struct {
ID int `json:"id"`
Active bool `json:"active"`
Shared bool `json:"is_shared"`
Description string `json:"description"`
ID int `json:"id"`
Active bool `json:"active"`
RunnerType string `json:"runner_type"`
IsShared bool `json:"is_shared"`
Description string `json:"description"`
Tags []string `json:"tags"`
} `json:"runner"`
Environment string `json:"environment"`
}

// MemberEvent represents a member event.
Expand Down
10 changes: 7 additions & 3 deletions event_webhook_types_test.go
Expand Up @@ -91,9 +91,9 @@ func TestJobEventUnmarshal(t *testing.T) {
BuildStartedAt: "2023-01-10 13:50:05 UTC",
BuildFinishedAt: "2023-01-10 13:50:54 UTC",
BuildDuration: 49.503592,
BuildQueuedDuration: 0.193009,
BuildAllowFailure: false,
BuildFailureReason: "unknown_failure",
BuildQueuedDuration: 0.193009,
RetriesCount: 1,
PipelineID: 743121198,
ProjectID: 31537070,
Expand Down Expand Up @@ -135,9 +135,13 @@ func TestJobEventUnmarshal(t *testing.T) {
expectedEvent.Commit.FinishedAt = "2022-10-12 08:09:29 UTC"

expectedEvent.Runner.ID = 12270837
expectedEvent.Runner.Active = true
expectedEvent.Runner.Shared = true
expectedEvent.Runner.Description = "4-blue.shared.runners-manager.gitlab.com/default"
expectedEvent.Runner.RunnerType = "instance_type"
expectedEvent.Runner.Active = true
expectedEvent.Runner.IsShared = true
expectedEvent.Runner.Tags = []string{"linux", "docker"}

expectedEvent.Environment = "staging"

assert.Equal(t, expectedEvent, *event, "event should be equal to the expected one")
}
Expand Down
13 changes: 2 additions & 11 deletions testdata/webhooks/job.json
Expand Up @@ -26,17 +26,8 @@
"active": true,
"is_shared": true,
"tags": [
"gce",
"east-c",
"linux",
"ruby",
"mysql",
"postgres",
"mongo",
"git-annex",
"shared",
"docker",
"saas-linux-small-amd64"
"docker"
]
},
"user": {
Expand Down Expand Up @@ -68,5 +59,5 @@
"git_ssh_url": "git@gitlab.com:jsmithy2/release-tools-fake.git",
"visibility_level": 20
},
"environment": null
"environment": "staging"
}

0 comments on commit d3711a0

Please sign in to comment.