Skip to content

Commit

Permalink
Adding prodBuild param for scanner alt env
Browse files Browse the repository at this point in the history
  • Loading branch information
rishigupta1599 committed Dec 19, 2024
1 parent 1c7711f commit e4c3bea
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
45 changes: 45 additions & 0 deletions packages/client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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()', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const configSchema = {
},
labels: {
type: 'string'
},
prodBuild: {
type: 'boolean',
default: false
}
}
},
Expand Down

0 comments on commit e4c3bea

Please sign in to comment.