-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stopped state coming from a gitlab canceled job/pipeline (#184)
* Add step stopped state coming from a gitlab canceled job * Add canceled pipeline test and fix stopped state color to info * Bump version to 3.7.0 for new feature release
- Loading branch information
Showing
28 changed files
with
1,956 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
import { GitLabStatus } from 'types/gitlab'; | ||
import { State, StepState } from 'types/status'; | ||
|
||
export const statusToState = (status: string): State => { | ||
const gitlabStatuses = { | ||
type GitLabStatusMapper<ExpectedState> = { | ||
// eslint-disable-next-line no-unused-vars | ||
[K in GitLabStatus]: ExpectedState; | ||
}; | ||
|
||
export const statusToState = (status: GitLabStatus): State => { | ||
const states: GitLabStatusMapper<State> = { | ||
pending: 'warning', | ||
running: 'warning', | ||
created: 'info', | ||
canceled: 'info', | ||
failed: 'error', | ||
success: 'success', | ||
}; | ||
|
||
return gitlabStatuses[status] || 'info'; | ||
return states[status] || 'info'; | ||
}; | ||
|
||
export const statusToStepState = (status: string, allowFailure: boolean): StepState => { | ||
switch (status) { | ||
case 'failed': | ||
return allowFailure ? 'soft-failed' : 'failed'; | ||
case 'success': | ||
return 'success'; | ||
case 'running': | ||
return 'running'; | ||
case 'pending': | ||
return 'pending'; | ||
default: | ||
return 'created'; | ||
} | ||
export const statusToStepState = (status: GitLabStatus, allowFailure: boolean): StepState => { | ||
const states: GitLabStatusMapper<StepState> = { | ||
pending: 'pending', | ||
running: 'running', | ||
created: 'created', | ||
canceled: 'stopped', | ||
failed: allowFailure ? 'soft-failed' : 'failed', | ||
success: 'success', | ||
}; | ||
|
||
return states[status] || 'created'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"headers": { | ||
"content-type": "application/json", | ||
"user-agent": "GitLab/15.6.0-pre", | ||
"x-gitlab-event": "Job Hook", | ||
"x-gitlab-instance": "https://gitlab.com", | ||
"accept-encoding": "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" | ||
}, | ||
"body": { | ||
"object_kind": "build", | ||
"ref": "production", | ||
"tag": false, | ||
"before_sha": "0000000000000000000000000000000000000000", | ||
"sha": "2c55f17d517d720c120cfc0e76873454ada29b52", | ||
"build_id": 3312231241, | ||
"build_name": "frontend ci", | ||
"build_stage": "builder", | ||
"build_status": "created", | ||
"build_created_at": "2022-11-11 20:01:51 UTC", | ||
"build_started_at": null, | ||
"build_finished_at": null, | ||
"build_duration": null, | ||
"build_queued_duration": null, | ||
"build_allow_failure": false, | ||
"build_failure_reason": "unknown_failure", | ||
"pipeline_id": 692601837, | ||
"runner": null, | ||
"project_id": 763808, | ||
"project_name": "FuturePortal / RickvanderStaaij", | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"commit": { | ||
"id": 692601837, | ||
"sha": "2c55f17d517d720c120cfc0e76873454ada29b52", | ||
"message": "Downgrade to node 16 for the current production state\n", | ||
"author_name": "Rick van der Staaij", | ||
"author_email": "[REDACTED]", | ||
"author_url": "https://gitlab.com/rick.nu", | ||
"status": "created", | ||
"duration": null, | ||
"started_at": null, | ||
"finished_at": null | ||
}, | ||
"repository": { | ||
"name": "RickvanderStaaij", | ||
"url": "git@gitlab.com:FuturePortal/RickvanderStaaij.git", | ||
"description": "https://rick.nu source code", | ||
"homepage": "https://gitlab.com/FuturePortal/RickvanderStaaij", | ||
"git_http_url": "https://gitlab.com/FuturePortal/RickvanderStaaij.git", | ||
"git_ssh_url": "git@gitlab.com:FuturePortal/RickvanderStaaij.git", | ||
"visibility_level": 20 | ||
}, | ||
"environment": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,271 @@ | ||
{ | ||
"headers": { | ||
"content-type": "application/json", | ||
"user-agent": "GitLab/15.6.0-pre", | ||
"x-gitlab-event": "Pipeline Hook", | ||
"x-gitlab-instance": "https://gitlab.com", | ||
"accept-encoding": "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" | ||
}, | ||
"body": { | ||
"object_kind": "pipeline", | ||
"object_attributes": { | ||
"id": 692601837, | ||
"iid": 954, | ||
"ref": "production", | ||
"tag": false, | ||
"sha": "2c55f17d517d720c120cfc0e76873454ada29b52", | ||
"before_sha": "0000000000000000000000000000000000000000", | ||
"source": "web", | ||
"status": "running", | ||
"detailed_status": "running", | ||
"stages": ["builder", "cache", "test", "build", "deploy", "merge back"], | ||
"created_at": "2022-11-11 20:01:51 UTC", | ||
"finished_at": null, | ||
"duration": null, | ||
"queued_duration": 1, | ||
"variables": [] | ||
}, | ||
"merge_request": null, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"project": { | ||
"id": 763808, | ||
"name": "RickvanderStaaij", | ||
"description": "https://rick.nu source code", | ||
"web_url": "https://gitlab.com/FuturePortal/RickvanderStaaij", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/project/avatar/763808/avatar-blue.png", | ||
"git_ssh_url": "git@gitlab.com:FuturePortal/RickvanderStaaij.git", | ||
"git_http_url": "https://gitlab.com/FuturePortal/RickvanderStaaij.git", | ||
"namespace": "FuturePortal", | ||
"visibility_level": 20, | ||
"path_with_namespace": "FuturePortal/RickvanderStaaij", | ||
"default_branch": "production", | ||
"ci_config_path": null | ||
}, | ||
"commit": { | ||
"id": "2c55f17d517d720c120cfc0e76873454ada29b52", | ||
"message": "Downgrade to node 16 for the current production state\n", | ||
"title": "Downgrade to node 16 for the current production state", | ||
"timestamp": "2022-11-11T19:05:51+01:00", | ||
"url": "https://gitlab.com/FuturePortal/RickvanderStaaij/-/commit/2c55f17d517d720c120cfc0e76873454ada29b52", | ||
"author": { | ||
"name": "Rick van der Staaij", | ||
"email": "[REDACTED]" | ||
} | ||
}, | ||
"builds": [ | ||
{ | ||
"id": 3312231243, | ||
"stage": "cache", | ||
"name": "frontend cache", | ||
"status": "created", | ||
"created_at": "2022-11-11 20:01:51 UTC", | ||
"started_at": null, | ||
"finished_at": null, | ||
"duration": null, | ||
"queued_duration": null, | ||
"failure_reason": null, | ||
"when": "on_success", | ||
"manual": false, | ||
"allow_failure": false, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"runner": null, | ||
"artifacts_file": { | ||
"filename": null, | ||
"size": null | ||
}, | ||
"environment": null | ||
}, | ||
{ | ||
"id": 3312231245, | ||
"stage": "test", | ||
"name": "codestyle", | ||
"status": "created", | ||
"created_at": "2022-11-11 20:01:51 UTC", | ||
"started_at": null, | ||
"finished_at": null, | ||
"duration": null, | ||
"queued_duration": null, | ||
"failure_reason": null, | ||
"when": "on_success", | ||
"manual": false, | ||
"allow_failure": false, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"runner": null, | ||
"artifacts_file": { | ||
"filename": null, | ||
"size": null | ||
}, | ||
"environment": null | ||
}, | ||
{ | ||
"id": 3312231247, | ||
"stage": "test", | ||
"name": "typescript", | ||
"status": "created", | ||
"created_at": "2022-11-11 20:01:51 UTC", | ||
"started_at": null, | ||
"finished_at": null, | ||
"duration": null, | ||
"queued_duration": null, | ||
"failure_reason": null, | ||
"when": "on_success", | ||
"manual": false, | ||
"allow_failure": false, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"runner": null, | ||
"artifacts_file": { | ||
"filename": null, | ||
"size": null | ||
}, | ||
"environment": null | ||
}, | ||
{ | ||
"id": 3312231250, | ||
"stage": "build", | ||
"name": "frontend image", | ||
"status": "created", | ||
"created_at": "2022-11-11 20:01:51 UTC", | ||
"started_at": null, | ||
"finished_at": null, | ||
"duration": null, | ||
"queued_duration": null, | ||
"failure_reason": null, | ||
"when": "on_success", | ||
"manual": false, | ||
"allow_failure": false, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"runner": null, | ||
"artifacts_file": { | ||
"filename": null, | ||
"size": null | ||
}, | ||
"environment": null | ||
}, | ||
{ | ||
"id": 3312231254, | ||
"stage": "deploy", | ||
"name": "deploy to production", | ||
"status": "created", | ||
"created_at": "2022-11-11 20:01:52 UTC", | ||
"started_at": null, | ||
"finished_at": null, | ||
"duration": null, | ||
"queued_duration": null, | ||
"failure_reason": null, | ||
"when": "on_success", | ||
"manual": false, | ||
"allow_failure": false, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"runner": null, | ||
"artifacts_file": { | ||
"filename": null, | ||
"size": null | ||
}, | ||
"environment": { | ||
"name": "production", | ||
"action": "start", | ||
"deployment_tier": "production" | ||
} | ||
}, | ||
{ | ||
"id": 3312231255, | ||
"stage": "merge back", | ||
"name": "update branches", | ||
"status": "created", | ||
"created_at": "2022-11-11 20:01:52 UTC", | ||
"started_at": null, | ||
"finished_at": null, | ||
"duration": null, | ||
"queued_duration": null, | ||
"failure_reason": null, | ||
"when": "on_success", | ||
"manual": false, | ||
"allow_failure": false, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"runner": null, | ||
"artifacts_file": { | ||
"filename": null, | ||
"size": null | ||
}, | ||
"environment": null | ||
}, | ||
{ | ||
"id": 3312231241, | ||
"stage": "builder", | ||
"name": "frontend ci", | ||
"status": "running", | ||
"created_at": "2022-11-11 20:01:51 UTC", | ||
"started_at": "2022-11-11 20:01:53 UTC", | ||
"finished_at": null, | ||
"duration": 0.442969078, | ||
"queued_duration": 0.958811, | ||
"failure_reason": null, | ||
"when": "on_success", | ||
"manual": false, | ||
"allow_failure": false, | ||
"user": { | ||
"id": 203336, | ||
"name": "Rick van der Staaij", | ||
"username": "rick.nu", | ||
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/203336/avatar.png", | ||
"email": "[REDACTED]" | ||
}, | ||
"runner": { | ||
"id": 15232634, | ||
"description": "xps-9720.rick.nu", | ||
"runner_type": "group_type", | ||
"active": true, | ||
"is_shared": false, | ||
"tags": [] | ||
}, | ||
"artifacts_file": { | ||
"filename": null, | ||
"size": null | ||
}, | ||
"environment": null | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.