diff --git a/spec/coverage_reporter/config_spec.cr b/spec/coverage_reporter/config_spec.cr index be911995..e22df02e 100644 --- a/spec/coverage_reporter/config_spec.cr +++ b/spec/coverage_reporter/config_spec.cr @@ -268,16 +268,25 @@ Spectator.describe CoverageReporter::Config do context "for Semaphore CI" do before_each do ENV["SEMAPHORE"] = "1" - ENV["SEMAPHORE_BUILD_NUMBER"] = "semaphore-build-number" - ENV["PULL_REQUEST_NUMBER"] = "semaphore-pr" + ENV["SEMAPHORE_WORKFLOW_ID"] = "semaphore-workflow-id" + ENV["SEMAPHORE_GIT_WORKING_BRANCH"] = "semaphore-branch" + ENV["SEMAPHORE_GIT_PR_NUMBER"] = "semaphore-pr" + ENV["SEMAPHORE_GIT_SHA"] = "semaphore-commit-sha" + ENV["SEMAPHORE_ORGANIZATION_URL"] = "https://myorg.semaphoreci.com" + ENV["SEMAPHORE_JOB_ID"] = "semaphore-job-id" end it "provides custom options" do expect(subject).to eq({ :repo_token => repo_token, :service_name => "semaphore", - :service_job_id => "semaphore-build-number", + :service_number => "semaphore-workflow-id", + :service_job_id => "semaphore-job-id", :service_pull_request => "semaphore-pr", + :service_branch => "semaphore-branch", + :commit_sha => "semaphore-commit-sha", + :service_build_url => "https://myorg.semaphoreci.com/workflows/semaphore-workflow-id", + :service_job_url => "https://myorg.semaphoreci.com/jobs/semaphore-job-id", }) end end diff --git a/src/coverage_reporter/ci/semaphore.cr b/src/coverage_reporter/ci/semaphore.cr index 54619dae..38a84ebf 100644 --- a/src/coverage_reporter/ci/semaphore.cr +++ b/src/coverage_reporter/ci/semaphore.cr @@ -10,8 +10,13 @@ module CoverageReporter Options.new( service_name: "semaphore", - service_job_id: ENV["SEMAPHORE_BUILD_NUMBER"]?, - service_pull_request: ENV["PULL_REQUEST_NUMBER"]?, + service_number: ENV["SEMAPHORE_WORKFLOW_ID"]?, + service_job_id: ENV["SEMAPHORE_JOB_ID"]?, + service_branch: ENV["SEMAPHORE_GIT_WORKING_BRANCH"]?, + service_pull_request: ENV["SEMAPHORE_GIT_PR_NUMBER"]?, + commit_sha: ENV["SEMAPHORE_GIT_SHA"]?, + service_build_url: "#{ENV["SEMAPHORE_ORGANIZATION_URL"]?}/workflows/#{ENV["SEMAPHORE_WORKFLOW_ID"]?}", + service_job_url: "#{ENV["SEMAPHORE_ORGANIZATION_URL"]?}/jobs/#{ENV["SEMAPHORE_JOB_ID"]?}" ).to_h end end