diff --git a/packages/env/src/environment.js b/packages/env/src/environment.js index e8c059eb3..325a4d17c 100644 --- a/packages/env/src/environment.js +++ b/packages/env/src/environment.js @@ -178,7 +178,7 @@ export class PercyEnv { case 'jenkins': return this.vars.CHANGE_ID; case 'circle': - return this.vars.CI_PULL_REQUESTS?.split('/').slice(-1)[0]; + return this.vars.CIRCLE_PULL_REQUESTS?.split('/').slice(-1)[0]; case 'drone': return this.vars.CI_PULL_REQUEST; case 'semaphore': @@ -212,6 +212,11 @@ export class PercyEnv { // parallel total & nonce get parallel() { let total = parseInt(this.vars.PERCY_PARALLEL_TOTAL, 10); + + if (this.ci === 'circle') { + total = parseInt(this.vars.CIRCLE_NODE_TOTAL, 10); + } + if (!Number.isInteger(total)) total = null; // no nonce if no total diff --git a/packages/env/test/circle.test.js b/packages/env/test/circle.test.js index 6770e1d49..ef84f3753 100644 --- a/packages/env/test/circle.test.js +++ b/packages/env/test/circle.test.js @@ -5,10 +5,10 @@ describe('CircleCI', () => { beforeEach(() => { env = new PercyEnv({ - PERCY_PARALLEL_TOTAL: '-1', + CIRCLE_NODE_TOTAL: '-1', CIRCLE_BRANCH: 'circle-branch', CIRCLE_SHA1: 'circle-commit-sha', - CI_PULL_REQUESTS: 'https://github.com/owner/repo-name/pull/123', + CIRCLE_PULL_REQUESTS: 'https://github.com/owner/repo-name/pull/123', CIRCLE_BUILD_NUM: 'build-number', CIRCLECI: 'true' }); @@ -29,4 +29,9 @@ describe('CircleCI', () => { env = new PercyEnv({ ...env.vars, CIRCLE_WORKFLOW_ID: 'workflow-id' }); expect(env).toHaveProperty('parallel.nonce', 'workflow-id'); }); + + it('has the correct parallel total', () => { + env = new PercyEnv({ ...env.vars, CIRCLE_NODE_TOTAL: '2' }); + expect(env).toHaveProperty('parallel.total', 2); + }); });