Skip to content

Commit

Permalink
update tests and fix PERCY_PARALLEL_TOTAL on circle
Browse files Browse the repository at this point in the history
  • Loading branch information
esetnik committed Oct 28, 2024
1 parent 8797ce0 commit 3edc4e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/env/src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ export class PercyEnv {
let total = parseInt(this.vars.PERCY_PARALLEL_TOTAL, 10);
if (!Number.isInteger(total)) total = null;

if(total === null) {
switch (this.ci) {
case 'circle':
total = this.vars.CIRCLE_NODE_TOTAL;
}
}

// no nonce if no total
let nonce = total && (() => {
if (this.vars.PERCY_PARALLEL_NONCE) {
Expand Down
9 changes: 7 additions & 2 deletions packages/env/test/circle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand All @@ -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');
});
});

0 comments on commit 3edc4e9

Please sign in to comment.