Skip to content

Commit 80f78d9

Browse files
authored
Merge pull request #336 from wordpress-mobile/use-fastlane-helper-instead-of-reimplementing
Remove custom check for CI in favor of using Fastlane's one
2 parents 8e535bd + 1f57542 commit 80f78d9

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ def initialize(params = {})
1010
end
1111

1212
def source_contents
13-
# TODO: This works only on CircleCI. I chose this variable because it's the one checked by Fastlane::is_ci.
14-
# Fastlane::is_ci doesn't work here, so reimplementing the code has been necessary.
15-
# (This should be updated if we change CI or if fastlane is updated.)
16-
return File.read(secrets_repository_file_path) unless self.encrypt || ENV.key?('CIRCLECI')
13+
return File.read(secrets_repository_file_path) unless self.encrypt || FastlaneCore::Helper.is_ci?
1714
return nil unless File.file?(encrypted_file_path)
1815

1916
encrypted = File.read(encrypted_file_path)

spec/file_reference_spec.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,17 @@
6969

7070
describe '#source_contents' do
7171
it 'gets the contents from the secrets repo' do
72-
set_circle_env(false) do
73-
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
74-
expect(subject.source_contents).to eq('source contents')
75-
end
72+
allow(FastlaneCore::Helper).to receive(:is_ci?).and_return(false)
73+
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
74+
expect(subject.source_contents).to eq('source contents')
7675
end
7776
end
7877

7978
describe '#source_contents on ci' do
8079
it 'gets the contents from the secrets repo' do
81-
set_circle_env(true) do
82-
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
83-
expect(subject.source_contents).to eq(nil)
84-
end
80+
allow(FastlaneCore::Helper).to receive(:is_ci?).and_return(true)
81+
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
82+
expect(subject.source_contents).to eq(nil)
8583
end
8684
end
8785

spec/spec_helper.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,6 @@ module SpecHelper
2525
config.filter_run_when_matching :focus
2626
end
2727

28-
def set_circle_env(define_ci)
29-
is_ci = ENV.key?('CIRCLECI')
30-
orig_circle_ci = ENV['CIRCLECI']
31-
if define_ci
32-
ENV['CIRCLECI'] = 'true'
33-
else
34-
ENV.delete 'CIRCLECI'
35-
end
36-
37-
yield
38-
ensure
39-
if is_ci
40-
ENV['CIRCLECI'] = orig_circle_ci
41-
else
42-
ENV.delete 'CIRCLECI'
43-
end
44-
end
45-
4628
# Allows Action.sh to be executed even when running in a test environment (where Fastlane's code disables it by default)
4729
#
4830
def allow_fastlane_action_sh

0 commit comments

Comments
 (0)