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

Don't override a running job to pending #204

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion backend/parser/gitlab/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { statusToStepState } from './helper';

class GitLabBuildParser {
parse(id: string, build: GitLabBuild): Status | null {
// Created status is not relevant, we start displaying when a job is pending
if (build.build_status === 'created') {
return null;
}
Expand All @@ -18,6 +19,7 @@ class GitLabBuildParser {

const processId = build.pipeline_id;

// If the pushed build (step) is not part of the status its processes yet, add it
if (!processes.find((process) => process.id === processId)) {
if (isOldProcess(status, processId)) {
return null;
Expand Down Expand Up @@ -80,6 +82,7 @@ class GitLabBuildParser {

const stageId = Slugify(build.build_stage);

// If the pushed build (step) is not part of the process its stages yet, add it
if (!stages.find((stage) => stage.id === stageId)) {
stages.push({
id: stageId,
Expand Down Expand Up @@ -109,6 +112,7 @@ class GitLabBuildParser {

const stepId = Slugify(build.build_name);

// If the pushed build (step) is not part of the stage its steps yet, add it
if (!steps.find((step) => step.id === stepId)) {
steps.push({
id: stepId,
Expand All @@ -120,7 +124,15 @@ class GitLabBuildParser {

steps = steps.map((step) => {
if (step.id === stepId) {
step.state = statusToStepState(build.build_status, build.build_allow_failure);
const previousState = step.state;
const newState = statusToStepState(build.build_status, build.build_allow_failure);

// Don't set job to pending when it's running already
if (previousState === 'running' && newState === 'pending') {
return step;
}

step.state = newState;
step.time = new Date().toUTCString();
}

Expand Down
112 changes: 56 additions & 56 deletions cypress/fixtures/gitlab/branch-with-mr/16.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
{
"headers": {
"content-type": "application/json",
"user-agent": "GitLab/14.10.0-pre",
"x-gitlab-event": "Job Hook"
},
"body": {
"object_kind": "build",
"ref": "74",
"tag": false,
"before_sha": "057ffcf3b58f839c17fff0e022b8011eca4cf303",
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"build_id": 2314349282,
"build_name": "api tests",
"build_stage": "test",
"build_status": "pending",
"build_created_at": "2022-04-09 19:26:31 UTC",
"build_started_at": null,
"build_finished_at": null,
"build_duration": null,
"build_queued_duration": 0.075305112,
"build_allow_failure": false,
"build_failure_reason": "unknown_failure",
"pipeline_id": 513076930,
"runner": null,
"project_id": 33715538,
"project_name": "FuturePortal / Nawcast",
"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": 513076930,
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"message": "[#74] Add web frame slide type in the dashboard\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": "Nawcast",
"url": "[email protected]:FuturePortal/Nawcast.git",
"description": "https://nawcast.com",
"homepage": "https://gitlab.com/FuturePortal/Nawcast",
"git_http_url": "https://gitlab.com/FuturePortal/Nawcast.git",
"git_ssh_url": "[email protected]:FuturePortal/Nawcast.git",
"visibility_level": 0
},
"environment": null
}
"headers": {
"content-type": "application/json",
"user-agent": "GitLab/14.10.0-pre",
"x-gitlab-event": "Job Hook"
},
"body": {
"object_kind": "build",
"ref": "74",
"tag": false,
"before_sha": "057ffcf3b58f839c17fff0e022b8011eca4cf303",
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"build_id": 2314349282,
"build_name": "api tests",
"build_stage": "test",
"build_status": "running",
"build_created_at": "2022-04-09 19:26:31 UTC",
"build_started_at": null,
"build_finished_at": null,
"build_duration": null,
"build_queued_duration": 0.075305112,
"build_allow_failure": false,
"build_failure_reason": "unknown_failure",
"pipeline_id": 513076930,
"runner": null,
"project_id": 33715538,
"project_name": "FuturePortal / Nawcast",
"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": 513076930,
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"message": "[#74] Add web frame slide type in the dashboard\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": "Nawcast",
"url": "[email protected]:FuturePortal/Nawcast.git",
"description": "https://nawcast.com",
"homepage": "https://gitlab.com/FuturePortal/Nawcast",
"git_http_url": "https://gitlab.com/FuturePortal/Nawcast.git",
"git_ssh_url": "[email protected]:FuturePortal/Nawcast.git",
"visibility_level": 0
},
"environment": null
}
}
126 changes: 63 additions & 63 deletions cypress/fixtures/gitlab/branch-with-mr/30.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
{
"headers": {
"content-type": "application/json",
"user-agent": "GitLab/14.10.0-pre",
"x-gitlab-event": "Job Hook"
},
"body": {
"object_kind": "build",
"ref": "74",
"tag": false,
"before_sha": "057ffcf3b58f839c17fff0e022b8011eca4cf303",
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"build_id": 2314349282,
"build_name": "api tests",
"build_stage": "test",
"build_status": "running",
"build_created_at": "2022-04-09 19:26:31 UTC",
"build_started_at": "2022-04-09 19:26:33 UTC",
"build_finished_at": null,
"build_duration": 0.134215871,
"build_queued_duration": 2.140293,
"build_allow_failure": false,
"build_failure_reason": "unknown_failure",
"pipeline_id": 513076930,
"runner": {
"id": 13775607,
"description": "local.rick.nu",
"runner_type": "group_type",
"active": true,
"is_shared": false,
"tags": []
},
"project_id": 33715538,
"project_name": "FuturePortal / Nawcast",
"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": 513076930,
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"message": "[#74] Add web frame slide type in the dashboard\n",
"author_name": "Rick van der Staaij",
"author_email": "[REDACTED]",
"author_url": "https://gitlab.com/rick.nu",
"status": "running",
"duration": null,
"started_at": "2022-04-09 19:26:32 UTC",
"finished_at": null
},
"repository": {
"name": "Nawcast",
"url": "[email protected]:FuturePortal/Nawcast.git",
"description": "https://nawcast.com",
"homepage": "https://gitlab.com/FuturePortal/Nawcast",
"git_http_url": "https://gitlab.com/FuturePortal/Nawcast.git",
"git_ssh_url": "[email protected]:FuturePortal/Nawcast.git",
"visibility_level": 0
},
"environment": null
}
"headers": {
"content-type": "application/json",
"user-agent": "GitLab/14.10.0-pre",
"x-gitlab-event": "Job Hook"
},
"body": {
"object_kind": "build",
"ref": "74",
"tag": false,
"before_sha": "057ffcf3b58f839c17fff0e022b8011eca4cf303",
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"build_id": 2314349282,
"build_name": "api tests",
"build_stage": "test",
"build_status": "pending",
"build_created_at": "2022-04-09 19:26:31 UTC",
"build_started_at": "2022-04-09 19:26:33 UTC",
"build_finished_at": null,
"build_duration": 0.134215871,
"build_queued_duration": 2.140293,
"build_allow_failure": false,
"build_failure_reason": "unknown_failure",
"pipeline_id": 513076930,
"runner": {
"id": 13775607,
"description": "local.rick.nu",
"runner_type": "group_type",
"active": true,
"is_shared": false,
"tags": []
},
"project_id": 33715538,
"project_name": "FuturePortal / Nawcast",
"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": 513076930,
"sha": "70b15b53ded5151bb15efa80279f4cc732996717",
"message": "[#74] Add web frame slide type in the dashboard\n",
"author_name": "Rick van der Staaij",
"author_email": "[REDACTED]",
"author_url": "https://gitlab.com/rick.nu",
"status": "running",
"duration": null,
"started_at": "2022-04-09 19:26:32 UTC",
"finished_at": null
},
"repository": {
"name": "Nawcast",
"url": "[email protected]:FuturePortal/Nawcast.git",
"description": "https://nawcast.com",
"homepage": "https://gitlab.com/FuturePortal/Nawcast",
"git_http_url": "https://gitlab.com/FuturePortal/Nawcast.git",
"git_ssh_url": "[email protected]:FuturePortal/Nawcast.git",
"visibility_level": 0
},
"environment": null
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cimonitor",
"version": "4.11.1",
"version": "4.11.2",
"description": "Monitors all your projects CI automatically",
"repository": "[email protected]:FuturePortal/CIMonitor.git",
"license": "MIT",
Expand Down