From e4c3bea85f6921ef7d5d4bcd18a90289124bfe9d Mon Sep 17 00:00:00 2001 From: rishigupta1599 Date: Fri, 20 Dec 2024 02:25:25 +0530 Subject: [PATCH 1/2] Adding prodBuild param for scanner alt env --- packages/client/src/client.js | 3 +- packages/client/test/client.test.js | 45 +++++++++++++++++++++++++++++ packages/core/src/config.js | 4 +++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/packages/client/src/client.js b/packages/client/src/client.js index 6e8beca41..9aa087687 100644 --- a/packages/client/src/client.js +++ b/packages/client/src/client.js @@ -172,7 +172,8 @@ export class PercyClient { partial: this.env.partial, tags: tagsArr, 'cli-start-time': cliStartTime, - source: source + source: source, + 'prod-build': this.config.percy?.prodBuild }, relationships: { resources: { diff --git a/packages/client/test/client.test.js b/packages/client/test/client.test.js index c7299cfaa..7e00b4526 100644 --- a/packages/client/test/client.test.js +++ b/packages/client/test/client.test.js @@ -150,6 +150,10 @@ describe('PercyClient', () => { describe('#createBuild()', () => { let cliStartTime = new Date().toISOString(); + beforeEach(() => { + delete process.env.PERCY_AUTO_ENABLED_GROUP_BUILD; + }); + it('creates a new build', async () => { await expectAsync(client.createBuild()).toBeResolvedTo({ data: { @@ -384,6 +388,47 @@ describe('PercyClient', () => { } })); }); + + it('creates a new build with prodBuild config', async () => { + client = new PercyClient({ + token: 'PERCY_TOKEN', + config: { percy: { prodBuild: true } } + }); + await expectAsync(client.createBuild({ projectType: 'web' })).toBeResolvedTo({ + data: { + id: '123', + attributes: { + 'build-number': 1, + 'web-url': 'https://percy.io/test/test/123' + } + } + }); + + expect(api.requests['/builds'][0].body.data) + .toEqual(jasmine.objectContaining({ + attributes: { + branch: client.env.git.branch, + type: 'web', + 'target-branch': client.env.target.branch, + 'target-commit-sha': client.env.target.commit, + 'commit-sha': client.env.git.sha, + 'commit-committed-at': client.env.git.committedAt, + 'commit-author-name': client.env.git.authorName, + 'commit-author-email': client.env.git.authorEmail, + 'commit-committer-name': client.env.git.committerName, + 'commit-committer-email': client.env.git.committerEmail, + 'commit-message': client.env.git.message, + 'pull-request-number': client.env.pullRequest, + 'parallel-nonce': client.env.parallel.nonce, + 'parallel-total-shards': client.env.parallel.total, + 'cli-start-time': null, + source: 'user_created', + partial: client.env.partial, + 'prod-build': true, + tags: [] + } + })); + }); }); describe('#getBuild()', () => { diff --git a/packages/core/src/config.js b/packages/core/src/config.js index e0eae19e5..c56f93511 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -16,6 +16,10 @@ export const configSchema = { }, labels: { type: 'string' + }, + prodBuild: { + type: 'boolean', + default: false } } }, From a06d15e3e7b628a688b4364cb6ad53a40fe8f6e8 Mon Sep 17 00:00:00 2001 From: rishigupta1599 Date: Fri, 20 Dec 2024 11:59:59 +0530 Subject: [PATCH 2/2] renaming config --- packages/client/src/client.js | 2 +- packages/client/test/client.test.js | 6 +++--- packages/core/src/config.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/client/src/client.js b/packages/client/src/client.js index 9aa087687..e3a93fc91 100644 --- a/packages/client/src/client.js +++ b/packages/client/src/client.js @@ -173,7 +173,7 @@ export class PercyClient { tags: tagsArr, 'cli-start-time': cliStartTime, source: source, - 'prod-build': this.config.percy?.prodBuild + 'skip-base-build': this.config.percy?.skipBaseBuild }, relationships: { resources: { diff --git a/packages/client/test/client.test.js b/packages/client/test/client.test.js index 7e00b4526..5fd2564d7 100644 --- a/packages/client/test/client.test.js +++ b/packages/client/test/client.test.js @@ -389,10 +389,10 @@ describe('PercyClient', () => { })); }); - it('creates a new build with prodBuild config', async () => { + it('creates a new build with skipBaseBuild config', async () => { client = new PercyClient({ token: 'PERCY_TOKEN', - config: { percy: { prodBuild: true } } + config: { percy: { skipBaseBuild: true } } }); await expectAsync(client.createBuild({ projectType: 'web' })).toBeResolvedTo({ data: { @@ -424,7 +424,7 @@ describe('PercyClient', () => { 'cli-start-time': null, source: 'user_created', partial: client.env.partial, - 'prod-build': true, + 'skip-base-build': true, tags: [] } })); diff --git a/packages/core/src/config.js b/packages/core/src/config.js index c56f93511..747bce2a0 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -17,7 +17,7 @@ export const configSchema = { labels: { type: 'string' }, - prodBuild: { + skipBaseBuild: { type: 'boolean', default: false }