@percy/env 1.31.12 → 1.31.13-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,22 +5,86 @@ into a common interface for consumption by `@percy/client`.
5
5
 
6
6
  ## Supported Environments
7
7
 
8
+ Auto-detected based on environment variables that the CI provider sets during a build.
9
+
8
10
  - [AppVeyor](https://www.browserstack.com/docs/percy/ci-cd/appveyor)
11
+ - [Atlassian Bamboo](#supported-environments) (needs doc)
12
+ - [AWS CodeBuild](#supported-environments) (needs doc)
9
13
  - [Azure Pipelines](https://www.browserstack.com/docs/percy/ci-cd/azure-pipelines)
10
14
  - [Bitbucket Pipelines](https://www.browserstack.com/docs/percy/ci-cd/bitbucket-pipeline)
15
+ - [Bitrise](#supported-environments) (needs doc)
11
16
  - [Buildkite](https://www.browserstack.com/docs/percy/ci-cd/buildkite)
12
17
  - [CircleCI](https://www.browserstack.com/docs/percy/ci-cd/circleci)
18
+ - [Cloudflare Pages](#supported-environments) (needs doc)
19
+ - [Codemagic](#supported-environments) (needs doc)
13
20
  - [Codeship](https://www.browserstack.com/docs/percy/ci-cd/codeship)
14
21
  - [Drone CI](https://docs.percy.io/docs/drone)
15
22
  - [GitHub Actions](https://www.browserstack.com/docs/percy/ci-cd/github-actions)
16
23
  - [GitLab CI](https://www.browserstack.com/docs/percy/ci-cd/gitlab)
24
+ - [GoCD](#supported-environments) (needs doc)
25
+ - [Google Cloud Build](#supported-environments) (needs doc)
26
+ - [Harness CI](#supported-environments) (needs doc)
17
27
  - [Heroku CI](#supported-environments) (needs doc)
18
28
  - [Jenkins](https://www.browserstack.com/docs/percy/ci-cd/jenkins)
19
29
  - [Jenkins PRB](https://www.browserstack.com/docs/percy/ci-cd/jenkins)
20
30
  - [Netlify](https://www.browserstack.com/docs/percy/ci-cd/netlify)
21
31
  - [Probo.CI](#supported-environments) (needs doc)
22
32
  - [Semaphore](https://www.browserstack.com/docs/percy/ci-cd/semaphore)
33
+ - [TeamCity](#supported-environments) (needs doc)
23
34
  - [Travis CI](https://www.browserstack.com/docs/percy/ci-cd/travis-ci)
35
+ - [Vercel](#vercel) — see note below
36
+ - [Woodpecker CI](#supported-environments) (needs doc)
37
+
38
+ ## Opt-in Environments
39
+
40
+ Kubernetes-native pipelines do not inject provider-identifying environment variables
41
+ into step containers by default. To enable Percy detection on these systems, expose
42
+ the following variables via template substitution in your pipeline definition.
43
+
44
+ ### Tekton Pipelines
45
+
46
+ ```yaml
47
+ steps:
48
+ - name: percy
49
+ image: node:20
50
+ env:
51
+ - name: TEKTON_PIPELINE_RUN # required — triggers detection
52
+ value: "$(context.pipelineRun.name)"
53
+ - name: TEKTON_COMMIT_SHA
54
+ value: "$(params.commit-sha)"
55
+ - name: TEKTON_BRANCH
56
+ value: "$(params.branch)"
57
+ - name: TEKTON_PULL_REQUEST # optional
58
+ value: "$(params.pr-number)"
59
+ ```
60
+
61
+ ### Argo Workflows
62
+
63
+ ```yaml
64
+ - name: percy
65
+ container:
66
+ image: node:20
67
+ env:
68
+ - name: ARGO_WORKFLOW_NAME # required — triggers detection
69
+ value: "{{workflow.name}}"
70
+ - name: ARGO_WORKFLOW_UID # recommended — used as parallel nonce
71
+ value: "{{workflow.uid}}"
72
+ - name: ARGO_COMMIT_SHA
73
+ value: "{{workflow.parameters.commit-sha}}"
74
+ - name: ARGO_BRANCH
75
+ value: "{{workflow.parameters.branch}}"
76
+ - name: ARGO_PULL_REQUEST # optional
77
+ value: "{{workflow.parameters.pr-number}}"
78
+ ```
79
+
80
+ ### Vercel
81
+
82
+ Vercel exposes its `VERCEL_*` system environment variables to the build step only
83
+ when **Automatically expose System Environment Variables** is enabled on the project
84
+ (Settings → Environment Variables). Percy also needs `PERCY_PARALLEL_TOTAL=-1`
85
+ set in the project environment for the parallel nonce to populate from
86
+ `VERCEL_DEPLOYMENT_ID` — otherwise reruns of the same deploy will create separate
87
+ Percy builds instead of deduping.
24
88
 
25
89
  ## Percy Environment Variables
26
90
 
@@ -18,6 +18,8 @@ export class PercyEnv {
18
18
  return 'circle';
19
19
  } else if (this.vars.CI_NAME === 'codeship') {
20
20
  return 'codeship';
21
+ } else if (this.vars.CI_SYSTEM_NAME === 'woodpecker' || this.vars.CI === 'woodpecker') {
22
+ return 'woodpecker';
21
23
  } else if (this.vars.DRONE === 'true') {
22
24
  return 'drone';
23
25
  } else if (this.vars.SEMAPHORE === 'true') {
@@ -42,6 +44,28 @@ export class PercyEnv {
42
44
  return 'netlify';
43
45
  } else if (this.vars.HARNESS_PROJECT_ID) {
44
46
  return 'harness';
47
+ } else if (this.vars.TEAMCITY_VERSION) {
48
+ return 'teamcity';
49
+ } else if (this.vars.CODEBUILD_BUILD_ID) {
50
+ return 'aws-codebuild';
51
+ } else if (this.vars.bamboo_buildKey) {
52
+ return 'bamboo';
53
+ } else if (this.vars.BITRISE_IO === 'true') {
54
+ return 'bitrise';
55
+ } else if (this.vars.CM_BUILD_ID) {
56
+ return 'codemagic';
57
+ } else if (this.vars.VERCEL === '1') {
58
+ return 'vercel';
59
+ } else if (this.vars.CF_PAGES === '1') {
60
+ return 'cloudflare-pages';
61
+ } else if (this.vars.GO_PIPELINE_NAME && this.vars.GO_SERVER_URL) {
62
+ return 'gocd';
63
+ } else if (this.vars.BUILD_ID && this.vars.PROJECT_ID && !this.vars.JENKINS_URL) {
64
+ return 'gcb';
65
+ } else if (this.vars.TEKTON_PIPELINE_RUN) {
66
+ return 'tekton';
67
+ } else if (this.vars.ARGO_WORKFLOW_NAME) {
68
+ return 'argo-workflows';
45
69
  } else if (this.vars.CI) {
46
70
  return 'CI/unknown';
47
71
  } else {
@@ -103,6 +127,30 @@ export class PercyEnv {
103
127
  return ((_github$pull_request = github(this.vars).pull_request) === null || _github$pull_request === void 0 ? void 0 : _github$pull_request.head.sha) || this.vars.GITHUB_SHA;
104
128
  case 'harness':
105
129
  return this.vars.DRONE_COMMIT_SHA;
130
+ case 'woodpecker':
131
+ return this.vars.CI_COMMIT_SHA;
132
+ case 'teamcity':
133
+ return this.vars.BUILD_VCS_NUMBER;
134
+ case 'aws-codebuild':
135
+ return this.vars.CODEBUILD_RESOLVED_SOURCE_VERSION;
136
+ case 'bamboo':
137
+ return this.vars.bamboo_planRepository_revision;
138
+ case 'bitrise':
139
+ return this.vars.BITRISE_GIT_COMMIT;
140
+ case 'codemagic':
141
+ return this.vars.CM_COMMIT;
142
+ case 'vercel':
143
+ return this.vars.VERCEL_GIT_COMMIT_SHA;
144
+ case 'cloudflare-pages':
145
+ return this.vars.CF_PAGES_COMMIT_SHA;
146
+ case 'gocd':
147
+ return this.vars.GO_REVISION;
148
+ case 'gcb':
149
+ return this.vars.COMMIT_SHA;
150
+ case 'tekton':
151
+ return this.vars.TEKTON_COMMIT_SHA;
152
+ case 'argo-workflows':
153
+ return this.vars.ARGO_COMMIT_SHA;
106
154
  }
107
155
  })();
108
156
  return commit || null;
@@ -149,6 +197,26 @@ export class PercyEnv {
149
197
  return this.vars.HEAD;
150
198
  case 'harness':
151
199
  return this.vars.DRONE_SOURCE_BRANCH || this.vars.DRONE_COMMIT_BRANCH;
200
+ case 'woodpecker':
201
+ return this.vars.CI_COMMIT_BRANCH;
202
+ case 'aws-codebuild':
203
+ return this.vars.CODEBUILD_WEBHOOK_HEAD_REF;
204
+ case 'bamboo':
205
+ return this.vars.bamboo_planRepository_branchName;
206
+ case 'bitrise':
207
+ return this.vars.BITRISE_GIT_BRANCH;
208
+ case 'codemagic':
209
+ return this.vars.CM_BRANCH;
210
+ case 'vercel':
211
+ return this.vars.VERCEL_GIT_COMMIT_REF;
212
+ case 'cloudflare-pages':
213
+ return this.vars.CF_PAGES_BRANCH;
214
+ case 'gcb':
215
+ return this.vars.BRANCH_NAME;
216
+ case 'tekton':
217
+ return this.vars.TEKTON_BRANCH;
218
+ case 'argo-workflows':
219
+ return this.vars.ARGO_BRANCH;
152
220
  }
153
221
  })();
154
222
  return (branch === null || branch === void 0 ? void 0 : branch.replace(/^refs\/\w+?\//, '')) || null;
@@ -159,7 +227,7 @@ export class PercyEnv {
159
227
  if (this.vars.PERCY_PULL_REQUEST) {
160
228
  return this.vars.PERCY_PULL_REQUEST;
161
229
  }
162
- let pr = ((_this$vars$CIRCLE_PUL, _this$vars$PULL_REQUE, _github$pull_request3, _this$vars$DRONE_COMM) => {
230
+ let pr = ((_this$vars$CIRCLE_PUL, _this$vars$PULL_REQUE, _github$pull_request3, _this$vars$DRONE_COMM, _this$vars$CODEBUILD_) => {
163
231
  switch (this.ci) {
164
232
  case 'travis':
165
233
  return this.vars.TRAVIS_PULL_REQUEST !== 'false' && this.vars.TRAVIS_PULL_REQUEST;
@@ -193,6 +261,24 @@ export class PercyEnv {
193
261
  return (_github$pull_request3 = github(this.vars).pull_request) === null || _github$pull_request3 === void 0 ? void 0 : _github$pull_request3.number;
194
262
  case 'harness':
195
263
  return this.vars.DRONE_BUILD_EVENT === 'pull_request' && ((_this$vars$DRONE_COMM = this.vars.DRONE_COMMIT_LINK) === null || _this$vars$DRONE_COMM === void 0 ? void 0 : _this$vars$DRONE_COMM.split('/').slice(-1)[0]);
264
+ case 'woodpecker':
265
+ return this.vars.CI_PIPELINE_EVENT === 'pull_request' && this.vars.CI_COMMIT_PULL_REQUEST;
266
+ case 'aws-codebuild':
267
+ return (_this$vars$CODEBUILD_ = this.vars.CODEBUILD_WEBHOOK_TRIGGER) === null || _this$vars$CODEBUILD_ === void 0 || (_this$vars$CODEBUILD_ = _this$vars$CODEBUILD_.match(/^pr\/(\d+)$/)) === null || _this$vars$CODEBUILD_ === void 0 ? void 0 : _this$vars$CODEBUILD_[1];
268
+ case 'bamboo':
269
+ return this.vars.bamboo_repository_pr_key;
270
+ case 'bitrise':
271
+ return this.vars.BITRISE_PULL_REQUEST;
272
+ case 'codemagic':
273
+ return this.vars.CM_PULL_REQUEST === 'true' && this.vars.CM_PULL_REQUEST_NUMBER;
274
+ case 'vercel':
275
+ return this.vars.VERCEL_GIT_PULL_REQUEST_ID;
276
+ case 'gcb':
277
+ return this.vars._PR_NUMBER;
278
+ case 'tekton':
279
+ return this.vars.TEKTON_PULL_REQUEST;
280
+ case 'argo-workflows':
281
+ return this.vars.ARGO_PULL_REQUEST;
196
282
  }
197
283
  })();
198
284
  return pr || null;
@@ -247,6 +333,30 @@ export class PercyEnv {
247
333
  return this.vars.GITHUB_RUN_ID;
248
334
  case 'harness':
249
335
  return this.vars.HARNESS_BUILD_ID;
336
+ case 'woodpecker':
337
+ return this.vars.CI_PIPELINE_NUMBER;
338
+ case 'teamcity':
339
+ return this.vars.BUILD_NUMBER;
340
+ case 'aws-codebuild':
341
+ return this.vars.CODEBUILD_BUILD_ID;
342
+ case 'bamboo':
343
+ return this.vars.bamboo_buildResultKey;
344
+ case 'bitrise':
345
+ return this.vars.BITRISE_BUILD_NUMBER;
346
+ case 'codemagic':
347
+ return this.vars.CM_BUILD_ID;
348
+ case 'vercel':
349
+ return this.vars.VERCEL_DEPLOYMENT_ID;
350
+ case 'cloudflare-pages':
351
+ return this.vars.CF_PAGES_COMMIT_SHA || null;
352
+ case 'gocd':
353
+ return this.vars.GO_PIPELINE_COUNTER && this.vars.GO_STAGE_COUNTER ? `${this.vars.GO_PIPELINE_COUNTER}.${this.vars.GO_STAGE_COUNTER}` : this.vars.GO_PIPELINE_COUNTER;
354
+ case 'gcb':
355
+ return this.vars.BUILD_ID;
356
+ case 'tekton':
357
+ return this.vars.TEKTON_PIPELINE_RUN;
358
+ case 'argo-workflows':
359
+ return this.vars.ARGO_WORKFLOW_UID || this.vars.ARGO_WORKFLOW_NAME;
250
360
  }
251
361
  })();
252
362
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/env",
3
- "version": "1.31.12",
3
+ "version": "1.31.13-beta.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "latest"
12
+ "tag": "beta"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -32,7 +32,7 @@
32
32
  "test:coverage": "yarn test --coverage"
33
33
  },
34
34
  "dependencies": {
35
- "@percy/logger": "1.31.12"
35
+ "@percy/logger": "1.31.13-beta.0"
36
36
  },
37
- "gitHead": "442fd8d120574657ee9e0c6e84af707a57db9503"
37
+ "gitHead": "69c6ad10d5724455cebf57f2043adc30559c3b31"
38
38
  }