Skip to content

Commit

Permalink
fix: options for Gitlab CI (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Apr 7, 2023
1 parent 5614cb3 commit 7dc981a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
21 changes: 12 additions & 9 deletions spec/coverage_reporter/config_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -207,22 +207,25 @@ Spectator.describe CoverageReporter::Config do
before_each do
ENV["GITLAB_CI"] = "1"
ENV["CI_JOB_NAME"] = "gitlab-job-id"
ENV["CI_JOB_ID"] = "gitlab-job-number"
ENV["CI_PIPELINE_IID"] = "123"
ENV["CI_COMMIT_REF_NAME"] = "gitlab-branch"
ENV["CI_COMMIT_SHA"] = "gitlab-commit-sha"
ENV["CI_JOB_URL"] = "https://gitlab.com/job-url"
ENV["CI_PIPELINE_URL"] = "https://gitlab.com/pipeline-url"
ENV["CI_MERGE_REQUEST_IID"] = "3"
end

it "gets info from ENV" do
expect(subject).to eq({
:repo_token => repo_token,
:service_name => "gitlab-ci",
:service_job_number => "gitlab-job-number",
:service_job_id => "gitlab-job-id",
:service_branch => "gitlab-branch",
:service_build_url => "https://gitlab.com/job-url",
:service_job_url => "https://gitlab.com/job-url",
:commit_sha => "gitlab-commit-sha",
:repo_token => repo_token,
:service_name => "gitlab-ci",
:service_number => "123",
:service_build_url => "https://gitlab.com/pipeline-url",
:service_job_id => "gitlab-job-id",
:service_job_url => "https://gitlab.com/job-url",
:service_pull_request => "3",
:service_branch => "gitlab-branch",
:commit_sha => "gitlab-commit-sha",
})
end
end
Expand Down
7 changes: 4 additions & 3 deletions src/coverage_reporter/ci/gitlab.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ module CoverageReporter

Options.new(
service_name: "gitlab-ci",
service_number: ENV["CI_PIPELINE_IID"]?,
service_build_url: ENV["CI_PIPELINE_URL"]? || ENV["CI_JOB_URL"]?,
service_job_id: ENV["CI_JOB_NAME"]?,
service_job_number: ENV["CI_JOB_ID"]?,
service_branch: ENV["CI_COMMIT_REF_NAME"]?,
service_build_url: ENV["CI_JOB_URL"]?,
service_job_url: ENV["CI_JOB_URL"]?,
service_pull_request: ENV["CI_MERGE_REQUEST_IID"]?,
service_branch: ENV["CI_COMMIT_REF_NAME"]?,
commit_sha: ENV["CI_COMMIT_SHA"]?,
).to_h
end
Expand Down

0 comments on commit 7dc981a

Please sign in to comment.