File tree Expand file tree Collapse file tree 3 files changed +7
-30
lines changed
lib/fastlane/plugin/wpmreleasetoolkit/models Expand file tree Collapse file tree 3 files changed +7
-30
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -25,24 +25,6 @@ module SpecHelper
2525 config . filter_run_when_matching :focus
2626end
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#
4830def allow_fastlane_action_sh
You can’t perform that action at this time.
0 commit comments