Skip to content

Commit 96090dc

Browse files
feat(PER-9724): send priority on build create via PERCY_PRIORITY (internal) (#2329)
Internal product orchestration (e.g. Scanner / LCA) can set PERCY_PRIORITY=true to request the priority lane; the client forwards it as the build-create `priority` attribute. Mirrors the existing PERCY_ORIGINATED_SOURCE internal signal in createBuild. percy-api only honors `priority` for eligible internal build types (visual_scanner / responsive_scanner / lca), so this is a no-op for customer builds and is not customer-controllable. Attribute is omitted entirely when PERCY_PRIORITY is unset (no payload change for existing flows). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3cc4718 commit 96090dc

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

packages/client/src/client.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ export class PercyClient {
326326

327327
let tagsArr = tagsList(this.labels);
328328

329+
// PER-9724: internal-only priority request. Set by internal product
330+
// orchestration (e.g. Scanner / LCA) via PERCY_PRIORITY; mirrors the
331+
// PERCY_ORIGINATED_SOURCE internal signal above. percy-api only honors this
332+
// for eligible internal build types, so it is a no-op for customer builds.
333+
let priority = process.env.PERCY_PRIORITY === 'true';
334+
329335
return this.post('builds', {
330336
data: {
331337
type: 'builds',
@@ -351,7 +357,8 @@ export class PercyClient {
351357
'skip-base-build': this.config.percy?.skipBaseBuild,
352358
'testhub-build-uuid': this.env.testhubBuildUuid,
353359
'testhub-build-run-id': this.env.testhubBuildRunId,
354-
...(visualConfig ? { 'visual-config': visualConfig } : {})
360+
...(visualConfig ? { 'visual-config': visualConfig } : {}),
361+
...(priority ? { priority: true } : {})
355362
},
356363
relationships: {
357364
resources: {

packages/client/test/client.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ describe('PercyClient', () => {
199199
delete process.env.PERCY_AUTO_ENABLED_GROUP_BUILD;
200200
delete process.env.PERCY_ORIGINATED_SOURCE;
201201
delete process.env.PERCY_VISUAL_CONFIG;
202+
delete process.env.PERCY_PRIORITY;
202203
});
203204

204205
it('creates a new build', async () => {
@@ -238,6 +239,21 @@ describe('PercyClient', () => {
238239
}));
239240
});
240241

242+
it('sends priority: true when PERCY_PRIORITY is set (internal signal)', async () => {
243+
process.env.PERCY_PRIORITY = 'true';
244+
245+
await client.createBuild();
246+
247+
expect(api.requests['/builds'][0].body.data.attributes)
248+
.toEqual(jasmine.objectContaining({ priority: true }));
249+
});
250+
251+
it('does not send a priority attribute when PERCY_PRIORITY is unset', async () => {
252+
await client.createBuild();
253+
254+
expect(api.requests['/builds'][0].body.data.attributes.priority).toBeUndefined();
255+
});
256+
241257
it('creates a new build with projectType passed as null', async () => {
242258
await expectAsync(client.createBuild({ projectType: null })).toBeResolvedTo({
243259
data: {

0 commit comments

Comments
 (0)