Commit 7a0a00c5 authored by lauraMon's avatar lauraMon

Rename and update field `previousStageJobsAndNeeds`

* Update a quarantined spec and remove flakiness
* Update field to return job execution requirements
parent c8776ac7
...@@ -50,8 +50,8 @@ module Types ...@@ -50,8 +50,8 @@ module Types
null: true, null: true,
description: 'How long the job was enqueued before starting.' description: 'How long the job was enqueued before starting.'
field :previous_stage_jobs_and_needs, Types::Ci::JobType.connection_type, null: true, field :previous_stage_jobs_or_needs, Types::Ci::JobType.connection_type, null: true,
description: 'All prerequisite jobs.' description: 'Jobs that must complete before the job runs. Returns needed jobs if the job uses the `needs` keyword, and returns previous stage jobs otherwise.'
field :detailed_status, Types::Ci::DetailedStatusType, null: true, field :detailed_status, Types::Ci::DetailedStatusType, null: true,
description: 'Detailed status of the job.' description: 'Detailed status of the job.'
field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true,
...@@ -103,9 +103,13 @@ module Types ...@@ -103,9 +103,13 @@ module Types
end end
end end
def previous_stage_jobs_and_needs def previous_stage_jobs_or_needs
Gitlab::Graphql::Lazy.with_value(previous_stage_jobs) do |jobs| if object.scheduling_type == 'stage'
(jobs + object.needs).uniq(&:name) Gitlab::Graphql::Lazy.with_value(previous_stage_jobs) do |jobs|
jobs
end
else
object.needs
end end
end end
......
...@@ -8687,7 +8687,7 @@ Represents the total number of issues and their weights for a particular day. ...@@ -8687,7 +8687,7 @@ Represents the total number of issues and their weights for a particular day.
| <a id="cijobneeds"></a>`needs` | [`CiBuildNeedConnection`](#cibuildneedconnection) | References to builds that must complete before the jobs run. (see [Connections](#connections)) | | <a id="cijobneeds"></a>`needs` | [`CiBuildNeedConnection`](#cibuildneedconnection) | References to builds that must complete before the jobs run. (see [Connections](#connections)) |
| <a id="cijobpipeline"></a>`pipeline` | [`Pipeline`](#pipeline) | Pipeline the job belongs to. | | <a id="cijobpipeline"></a>`pipeline` | [`Pipeline`](#pipeline) | Pipeline the job belongs to. |
| <a id="cijobplayable"></a>`playable` | [`Boolean!`](#boolean) | Indicates the job can be played. | | <a id="cijobplayable"></a>`playable` | [`Boolean!`](#boolean) | Indicates the job can be played. |
| <a id="cijobpreviousstagejobsandneeds"></a>`previousStageJobsAndNeeds` | [`CiJobConnection`](#cijobconnection) | All prerequisite jobs. (see [Connections](#connections)) | | <a id="cijobpreviousstagejobsorneeds"></a>`previousStageJobsOrNeeds` | [`CiJobConnection`](#cijobconnection) | Jobs that must complete before the job runs. Returns needed jobs if the job uses the `needs` keyword, and returns previous stage jobs otherwise. (see [Connections](#connections)) |
| <a id="cijobqueuedat"></a>`queuedAt` | [`Time`](#time) | When the job was enqueued and marked as pending. | | <a id="cijobqueuedat"></a>`queuedAt` | [`Time`](#time) | When the job was enqueued and marked as pending. |
| <a id="cijobqueuedduration"></a>`queuedDuration` | [`Duration`](#duration) | How long the job was enqueued before starting. | | <a id="cijobqueuedduration"></a>`queuedDuration` | [`Duration`](#duration) | How long the job was enqueued before starting. |
| <a id="cijobrefname"></a>`refName` | [`String`](#string) | Ref name of the job. | | <a id="cijobrefname"></a>`refName` | [`String`](#string) | Ref name of the job. |
...@@ -25,7 +25,7 @@ RSpec.describe Types::Ci::JobType do ...@@ -25,7 +25,7 @@ RSpec.describe Types::Ci::JobType do
needs needs
pipeline pipeline
playable playable
previousStageJobsAndNeeds previousStageJobsOrNeeds
queued_at queued_at
queued_duration queued_duration
refName refName
......
...@@ -15,7 +15,7 @@ RSpec.describe 'Query.project.pipeline' do ...@@ -15,7 +15,7 @@ RSpec.describe 'Query.project.pipeline' do
let(:pipeline) do let(:pipeline) do
pipeline = create(:ci_pipeline, project: project, user: user) pipeline = create(:ci_pipeline, project: project, user: user)
stage = create(:ci_stage_entity, project: project, pipeline: pipeline, name: 'first', position: 1) stage = create(:ci_stage_entity, project: project, pipeline: pipeline, name: 'first', position: 1)
create(:ci_build, stage_id: stage.id, pipeline: pipeline, name: 'my test job') create(:ci_build, stage_id: stage.id, pipeline: pipeline, name: 'my test job', scheduling_type: :stage)
pipeline pipeline
end end
...@@ -48,7 +48,7 @@ RSpec.describe 'Query.project.pipeline' do ...@@ -48,7 +48,7 @@ RSpec.describe 'Query.project.pipeline' do
needs { needs {
nodes { #{all_graphql_fields_for('CiBuildNeed')} } nodes { #{all_graphql_fields_for('CiBuildNeed')} }
} }
previousStageJobsAndNeeds { previousStageJobsOrNeeds {
nodes { nodes {
name name
} }
...@@ -77,68 +77,48 @@ RSpec.describe 'Query.project.pipeline' do ...@@ -77,68 +77,48 @@ RSpec.describe 'Query.project.pipeline' do
before do before do
build_stage = create(:ci_stage_entity, position: 2, name: 'build', project: project, pipeline: pipeline) build_stage = create(:ci_stage_entity, position: 2, name: 'build', project: project, pipeline: pipeline)
test_stage = create(:ci_stage_entity, position: 3, name: 'test', project: project, pipeline: pipeline) test_stage = create(:ci_stage_entity, position: 3, name: 'test', project: project, pipeline: pipeline)
deploy_stage = create(:ci_stage_entity, position: 4, name: 'deploy', project: project, pipeline: pipeline)
create(:ci_build, pipeline: pipeline, stage_idx: build_stage.position, name: 'docker 1 2', stage: build_stage) create(:ci_build, pipeline: pipeline, name: 'docker 1 2', scheduling_type: :stage, stage: build_stage, stage_idx: build_stage.position)
create(:ci_build, pipeline: pipeline, stage_idx: build_stage.position, name: 'docker 2 2', stage: build_stage) create(:ci_build, pipeline: pipeline, name: 'docker 2 2', stage: build_stage, stage_idx: build_stage.position, scheduling_type: :dag)
create(:ci_build, pipeline: pipeline, stage_idx: test_stage.position, name: 'rspec 1 2', stage: test_stage) create(:ci_build, pipeline: pipeline, name: 'rspec 1 2', scheduling_type: :stage, stage: test_stage, stage_idx: test_stage.position)
test_job = create(:ci_bridge, pipeline: pipeline, stage_idx: test_stage.position, name: 'rspec 2 2', stage: test_stage) test_job = create(:ci_build, pipeline: pipeline, name: 'rspec 2 2', scheduling_type: :dag, stage: test_stage, stage_idx: test_stage.position)
create(:ci_build, pipeline: pipeline, stage_idx: deploy_stage.position, name: 'deploy 1 2', stage: deploy_stage)
deploy_job = create(:ci_build, pipeline: pipeline, stage_idx: deploy_stage.position, name: 'deploy 2 2', stage: deploy_stage)
create(:ci_build_need, build: test_job, name: 'my test job') create(:ci_build_need, build: test_job, name: 'my test job')
create(:ci_build_need, build: deploy_job, name: 'rspec 1 2')
end end
it 'reports the build needs and previous stages with no duplicates', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/346433' do it 'reports the build needs and execution requirements' do
post_graphql(query, current_user: user) post_graphql(query, current_user: user)
expect(jobs_graphql_data).to contain_exactly( expect(jobs_graphql_data).to contain_exactly(
a_hash_including( a_hash_including(
'name' => 'my test job', 'name' => 'my test job',
'needs' => { 'nodes' => [] }, 'needs' => { 'nodes' => [] },
'previousStageJobsAndNeeds' => { 'nodes' => [] } 'previousStageJobsOrNeeds' => { 'nodes' => [] }
), ),
a_hash_including( a_hash_including(
'name' => 'docker 1 2', 'name' => 'docker 1 2',
'needs' => { 'nodes' => [] }, 'needs' => { 'nodes' => [] },
'previousStageJobsAndNeeds' => { 'nodes' => [ 'previousStageJobsOrNeeds' => { 'nodes' => [
{ "name" => "my test job" } { 'name' => 'my test job' }
] } ] }
), ),
a_hash_including( a_hash_including(
'name' => 'docker 2 2', 'name' => 'docker 2 2',
'needs' => { 'nodes' => [] }, 'needs' => { 'nodes' => [] },
'previousStageJobsAndNeeds' => { 'nodes' => [ 'previousStageJobsOrNeeds' => { 'nodes' => [] }
{ "name" => "my test job" }
] }
), ),
a_hash_including( a_hash_including(
'name' => 'rspec 1 2', 'name' => 'rspec 1 2',
'needs' => { 'nodes' => [] }, 'needs' => { 'nodes' => [] },
'previousStageJobsAndNeeds' => { 'nodes' => [ 'previousStageJobsOrNeeds' => { 'nodes' => [
{ "name" => "docker 1 2" }, { "name" => "docker 2 2" } { 'name' => 'docker 1 2' }, { 'name' => 'docker 2 2' }
] } ] }
), ),
a_hash_including( a_hash_including(
'name' => 'rspec 2 2', 'name' => 'rspec 2 2',
'needs' => { 'nodes' => [a_hash_including('name' => 'my test job')] }, 'needs' => { 'nodes' => [a_hash_including('name' => 'my test job')] },
'previousStageJobsAndNeeds' => { 'nodes' => [ 'previousStageJobsOrNeeds' => { 'nodes' => [
{ "name" => "docker 1 2" }, { "name" => "docker 2 2" }, { "name" => "my test job" } { 'name' => 'my test job' }
] }
),
a_hash_including(
'name' => 'deploy 1 2',
'needs' => { 'nodes' => [] },
'previousStageJobsAndNeeds' => { 'nodes' => [
{ "name" => "rspec 1 2" }, { "name" => "rspec 2 2" }
] }
),
a_hash_including(
'name' => 'deploy 2 2',
'needs' => { 'nodes' => [a_hash_including('name' => 'rspec 1 2')] },
'previousStageJobsAndNeeds' => { 'nodes' => [
{ "name" => "rspec 1 2" }, { "name" => "rspec 2 2" }
] } ] }
) )
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment