Skip to content

Commit bb7bed8

Browse files
committed
Adds support for RWX
1 parent 63c6233 commit bb7bed8

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

spec/coverage_reporter/config_spec.cr

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,5 +613,32 @@ Spectator.describe CoverageReporter::Config do
613613
})
614614
end
615615
end
616+
617+
context "for RWX" do
618+
before_each do
619+
ENV["RWX"] = "true"
620+
ENV["RWX_GIT_REPOSITORY_NAME"] = "rwx/repo"
621+
ENV["RWX_RUN_ID"] = "12345"
622+
ENV["RWX_TASK_ID"] = "6789"
623+
ENV["RWX_GIT_REF_NAME"] = "main"
624+
ENV["RWX_RUN_URL"] = "https://cloud.rwx.com/runs/12345"
625+
ENV["RWX_TASK_URL"] = "https://cloud.rwx.com/tasks/6789"
626+
ENV["RWX_TASK_ATTEMPT_NUMBER"] = "3"
627+
ENV["RWX_GIT_COMMIT_SHA"] = "rwx-commit-sha"
628+
end
629+
630+
it "provides custom options" do
631+
expect(subject).to eq({
632+
:repo_token => repo_token,
633+
:service_name => "rwx",
634+
:service_number => "12345",
635+
:service_job_id => "6789",
636+
:service_branch => "main",
637+
:commit_sha => "rwx-commit-sha",
638+
:service_build_url => "https://cloud.rwx.com/runs/12345",
639+
:service_job_url => "https://cloud.rwx.com/tasks/6789",
640+
})
641+
end
642+
end
616643
end
617644
end

src/coverage_reporter/ci/rwx.cr

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require "./options"
2+
3+
module CoverageReporter
4+
module CI
5+
module Rwx
6+
extend self
7+
8+
def options
9+
return unless ENV["RWX"]?
10+
11+
Options.new(
12+
service_name: "rwx",
13+
repo_name: ENV["RWX_GIT_REPOSITORY_NAME"]?,
14+
service_number: ENV["RWX_RUN_ID"]?,
15+
service_job_id: ENV["RWX_TASK_ID"]?,
16+
service_branch: ENV["RWX_GIT_REF_NAME"]?,
17+
service_build_url: ENV["RWX_RUN_URL"]?,
18+
service_job_url: ENV["RWX_TASK_URL"]?,
19+
service_attempt: ENV["RWX_TASK_ATTEMPT_NUMBER"]?,
20+
commit_sha: ENV["RWX_GIT_COMMIT_SHA"]?,
21+
).to_h
22+
end
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)