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

Fix mr pipeline detection for child pipelines #610

Merged
merged 1 commit 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
8 changes: 1 addition & 7 deletions lib/allure_report_publisher/lib/providers/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Gitlab < Provider

def_delegators :"Publisher::Providers::Info::Gitlab.instance",
:allure_project,
:mr_iid,
:allure_mr_iid,
:server_url,
:build_name
Expand Down Expand Up @@ -68,13 +69,6 @@ def project
@project ||= allure_project || env("CI_MERGE_REQUEST_PROJECT_PATH") || env("CI_PROJECT_PATH")
end

# Merge request iid
#
# @return [Integer]
def mr_iid
@mr_iid ||= allure_mr_iid || env("CI_MERGE_REQUEST_IID")
end

# Commit sha url
#
# @return [String]
Expand Down
9 changes: 8 additions & 1 deletion lib/allure_report_publisher/lib/providers/info/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def executor(report_url)
#
# @return [Boolean]
def pr?
!!(allure_project && allure_mr_iid) || ENV["CI_PIPELINE_SOURCE"] == "merge_request_event"
!!((allure_project && allure_mr_iid) || mr_iid)
end

# Get ci run ID without creating instance of ci provider
Expand Down Expand Up @@ -58,6 +58,13 @@ def allure_project
@allure_project ||= env("ALLURE_PROJECT_PATH")
end

# Merge request iid
#
# @return [Integer]
def mr_iid
@mr_iid ||= allure_mr_iid || env("CI_MERGE_REQUEST_IID")
end

# Custom mr iid name
#
# @return [String]
Expand Down
10 changes: 5 additions & 5 deletions spec/allure_report_publisher/lib/providers/info/gitlab_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
RSpec.describe Publisher::Providers::Info::Gitlab, epic: "providers" do
subject(:pr) { described_class.instance.pr? }

let(:mr_iid) { nil }
let(:allure_project) { nil }
let(:allure_mr_iid) { nil }
let(:pipeline_source) { "push" }

let(:env) do
{
ALLURE_PROJECT_PATH: allure_project,
ALLURE_MERGE_REQUEST_IID: allure_mr_iid,
CI_PIPELINE_SOURCE: pipeline_source
CI_MERGE_REQUEST_IID: mr_iid
}
end

Expand All @@ -18,12 +18,12 @@
end

describe "#pr?" do
context "with push event" do
context "with non merge request pipeline" do
it { is_expected.to be(false) }
end

context "with merge request event" do
let(:pipeline_source) { "merge_request_event" }
context "with merge request pipeline" do
let(:mr_iid) { "1" }

it { is_expected.to be(true) }
end
Expand Down