Skip to content

Commit

Permalink
adding support for source attribute variable internal use only (#1698)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
prklm10 authored Aug 23, 2024
1 parent d6d6b3e commit 81cb7df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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: {
Expand Down
6 changes: 6 additions & 0 deletions packages/client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
}
Expand Down Expand Up @@ -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: []
}
Expand Down Expand Up @@ -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: []
}
Expand Down Expand Up @@ -322,13 +325,15 @@ 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' }]
}
}));
});

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'
Expand Down Expand Up @@ -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' }]
}
Expand Down

0 comments on commit 81cb7df

Please sign in to comment.