Skip to content

Commit

Permalink
Support Circle 2.0 CIRCLE_WORKFLOW_WORKSPACE_ID as parallel nonce. (#40)
Browse files Browse the repository at this point in the history
* Support Circle 2.0 CIRCLE_WORKFLOW_ID as parallel nonce.

* Use CIRCLE_WORKFLOW_WORKSPACE_ID instead of CIRCLE_WORKSPACE_ID.
  • Loading branch information
fotinakis authored Oct 19, 2018
1 parent 5801da7 commit 2cf9c31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/percy/client/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def self.parallel_nonce
when :travis
ENV['TRAVIS_BUILD_NUMBER']
when :circle
ENV['CIRCLE_BUILD_NUM']
ENV['CIRCLE_WORKFLOW_WORKSPACE_ID'] || ENV['CIRCLE_BUILD_NUM']
when :jenkins
ENV['BUILD_NUMBER']
when :codeship
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/percy/client/environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def clear_env_vars
ENV['CIRCLE_SHA1'] = nil
ENV['CIRCLE_BRANCH'] = nil
ENV['CIRCLE_BUILD_NUM'] = nil
ENV['CIRCLE_WORKFLOW_WORKSPACE_ID'] = nil
ENV['CI_PULL_REQUESTS'] = nil

# Unset Codeship vars.
Expand Down Expand Up @@ -279,6 +280,16 @@ def clear_env_vars
expect(Percy::Client::Environment.parallel_total_shards).to be_nil
end

context 'in Circle 2.0' do
before(:each) do
ENV['CIRCLE_WORKFLOW_WORKSPACE_ID'] = 'circle-workflow-workspace-id'
end

it 'has the correct properties' do
expect(Percy::Client::Environment.parallel_nonce).to eq('circle-workflow-workspace-id')
end
end

context 'with a parallel build' do
before(:each) do
ENV['CIRCLE_NODE_TOTAL'] = '3'
Expand Down

0 comments on commit 2cf9c31

Please sign in to comment.