From 81cb7df0cc4d3d8ebad7d58039d1605d65302a64 Mon Sep 17 00:00:00 2001 From: Pradum Kumar Date: Fri, 23 Aug 2024 17:02:57 +0530 Subject: [PATCH] adding support for source attribute variable internal use only (#1698) * adding support for PERCY_AUTO_ENABLED_GROUP_BUILD env variable and adding new param in build post request body * addressing comments: changing param to source and setting it to user_created or auto_enabled_group --- packages/client/src/client.js | 7 ++++++- packages/client/test/client.test.js | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/client/src/client.js b/packages/client/src/client.js index 8b0e6661b..b8cdac1e3 100644 --- a/packages/client/src/client.js +++ b/packages/client/src/client.js @@ -136,6 +136,10 @@ export class PercyClient { // done more seemlessly without manually tracking build ids async createBuild({ resources = [], projectType, cliStartTime = null } = {}) { this.log.debug('Creating a new build...'); + let source = 'user_created'; + if (process.env.PERCY_AUTO_ENABLED_GROUP_BUILD === 'true') { + source = 'auto_enabled_group'; + } let tagsArr = tagsList(this.labels); @@ -159,7 +163,8 @@ export class PercyClient { 'parallel-total-shards': this.env.parallel.total, partial: this.env.partial, tags: tagsArr, - 'cli-start-time': cliStartTime + 'cli-start-time': cliStartTime, + source: source }, relationships: { resources: { diff --git a/packages/client/test/client.test.js b/packages/client/test/client.test.js index e73e2871b..d039b690e 100644 --- a/packages/client/test/client.test.js +++ b/packages/client/test/client.test.js @@ -166,6 +166,7 @@ describe('PercyClient', () => { 'parallel-nonce': client.env.parallel.nonce, 'parallel-total-shards': client.env.parallel.total, 'cli-start-time': null, + source: 'user_created', partial: client.env.partial, tags: [] } @@ -201,6 +202,7 @@ describe('PercyClient', () => { 'parallel-nonce': client.env.parallel.nonce, 'parallel-total-shards': client.env.parallel.total, 'cli-start-time': null, + source: 'user_created', partial: client.env.partial, tags: [] } @@ -283,6 +285,7 @@ describe('PercyClient', () => { 'parallel-nonce': client.env.parallel.nonce, 'parallel-total-shards': client.env.parallel.total, 'cli-start-time': null, + source: 'user_created', partial: client.env.partial, tags: [] } @@ -322,6 +325,7 @@ describe('PercyClient', () => { 'parallel-nonce': client.env.parallel.nonce, 'parallel-total-shards': client.env.parallel.total, 'cli-start-time': null, + source: 'user_created', partial: client.env.partial, tags: [{ id: null, name: 'tag1' }, { id: null, name: 'tag2' }] } @@ -329,6 +333,7 @@ describe('PercyClient', () => { }); it('creates a new build with cliStartTime', async () => { + process.env.PERCY_AUTO_ENABLED_GROUP_BUILD = 'true'; client = new PercyClient({ token: 'PERCY_TOKEN', labels: 'tag1,tag2' @@ -361,6 +366,7 @@ describe('PercyClient', () => { 'parallel-nonce': client.env.parallel.nonce, 'parallel-total-shards': client.env.parallel.total, 'cli-start-time': cliStartTime, + source: 'auto_enabled_group', partial: client.env.partial, tags: [{ id: null, name: 'tag1' }, { id: null, name: 'tag2' }] }