From ec3e77a4a3236e3e8f85e1133dc96dbe1a72a2ea Mon Sep 17 00:00:00 2001 From: Mike Fotinakis Date: Wed, 26 Sep 2018 20:13:33 -0700 Subject: [PATCH 1/2] Support Circle 2.0 CIRCLE_WORKFLOW_ID as parallel nonce. --- percy/environment.py | 2 +- tests/test_environment.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/percy/environment.py b/percy/environment.py index 90f1882..41c01bc 100644 --- a/percy/environment.py +++ b/percy/environment.py @@ -251,7 +251,7 @@ def commit_sha(self): @property def parallel_nonce(self): - return os.getenv('CIRCLE_BUILD_NUM') + return os.getenv('CIRCLE_WORKFLOW_ID') or os.getenv('CIRCLE_BUILD_NUM') @property def parallel_total_shards(self): diff --git a/tests/test_environment.py b/tests/test_environment.py index 31e9b8e..4b1be81 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -54,6 +54,7 @@ def clear_env_vars(self): 'CIRCLE_SHA1', 'CIRCLE_BRANCH', 'CIRCLE_BUILD_NUM', + 'CIRCLE_WORKFLOW_ID', 'CI_PULL_REQUESTS', 'CIRCLE_NODE_TOTAL', @@ -320,6 +321,7 @@ def setup_method(self, method): os.environ['CIRCLE_BRANCH'] = 'circle-branch' os.environ['CIRCLE_SHA1'] = 'circle-commit-sha' os.environ['CIRCLE_BUILD_NUM'] = 'circle-build-number' + os.environ['CIRCLE_WORKFLOW_ID'] = 'circle-workflow-id' os.environ['CIRCLE_NODE_TOTAL'] = '3' os.environ['CI_PULL_REQUESTS'] = 'https://github.com/owner/repo-name/pull/123' self.environment = percy.Environment() @@ -334,6 +336,8 @@ def test_commit_sha(self): assert self.environment.commit_sha == 'circle-commit-sha' def test_parallel_nonce(self): + assert self.environment.parallel_nonce == 'circle-workflow-id' + del os.environ['CIRCLE_WORKFLOW_ID'] assert self.environment.parallel_nonce == 'circle-build-number' def test_parallel_total(self): From 6f4b9d5cea0a037949a8c31d47c5103b5482c309 Mon Sep 17 00:00:00 2001 From: Mike Fotinakis Date: Fri, 19 Oct 2018 08:37:59 -0700 Subject: [PATCH 2/2] Use CIRCLE_WORKFLOW_WORKSPACE_ID instead of CIRCLE_WORKSPACE_ID. --- percy/environment.py | 2 +- tests/test_environment.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/percy/environment.py b/percy/environment.py index 41c01bc..491b640 100644 --- a/percy/environment.py +++ b/percy/environment.py @@ -251,7 +251,7 @@ def commit_sha(self): @property def parallel_nonce(self): - return os.getenv('CIRCLE_WORKFLOW_ID') or os.getenv('CIRCLE_BUILD_NUM') + return os.getenv('CIRCLE_WORKFLOW_WORKSPACE_ID') or os.getenv('CIRCLE_BUILD_NUM') @property def parallel_total_shards(self): diff --git a/tests/test_environment.py b/tests/test_environment.py index 4b1be81..71f0428 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -54,7 +54,7 @@ def clear_env_vars(self): 'CIRCLE_SHA1', 'CIRCLE_BRANCH', 'CIRCLE_BUILD_NUM', - 'CIRCLE_WORKFLOW_ID', + 'CIRCLE_WORKFLOW_WORKSPACE_ID', 'CI_PULL_REQUESTS', 'CIRCLE_NODE_TOTAL', @@ -321,7 +321,7 @@ def setup_method(self, method): os.environ['CIRCLE_BRANCH'] = 'circle-branch' os.environ['CIRCLE_SHA1'] = 'circle-commit-sha' os.environ['CIRCLE_BUILD_NUM'] = 'circle-build-number' - os.environ['CIRCLE_WORKFLOW_ID'] = 'circle-workflow-id' + os.environ['CIRCLE_WORKFLOW_WORKSPACE_ID'] = 'circle-workflow-workspace-id' os.environ['CIRCLE_NODE_TOTAL'] = '3' os.environ['CI_PULL_REQUESTS'] = 'https://github.com/owner/repo-name/pull/123' self.environment = percy.Environment() @@ -336,8 +336,8 @@ def test_commit_sha(self): assert self.environment.commit_sha == 'circle-commit-sha' def test_parallel_nonce(self): - assert self.environment.parallel_nonce == 'circle-workflow-id' - del os.environ['CIRCLE_WORKFLOW_ID'] + assert self.environment.parallel_nonce == 'circle-workflow-workspace-id' + del os.environ['CIRCLE_WORKFLOW_WORKSPACE_ID'] assert self.environment.parallel_nonce == 'circle-build-number' def test_parallel_total(self):