diff --git a/.ci/jobs.yml b/.ci/jobs.yml index fc3e80064fa6..89fce3cf488d 100644 --- a/.ci/jobs.yml +++ b/.ci/jobs.yml @@ -14,7 +14,7 @@ JOB: - kibana-ciGroup10 - kibana-ciGroup11 - kibana-ciGroup12 - # - kibana-visualRegression + - kibana-visualRegression # make sure all x-pack-ciGroups are listed in test/scripts/jenkins_xpack_ci_group.sh - x-pack-firefoxSmoke @@ -28,7 +28,7 @@ JOB: - x-pack-ciGroup8 - x-pack-ciGroup9 - x-pack-ciGroup10 - # - x-pack-visualRegression + - x-pack-visualRegression # `~` is yaml for `null` exclude: ~ diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index ead64fd2b905..66853ef2a5af 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -23,7 +23,36 @@ const pkg = require('../../../package.json'); const { stdout: commit } = execa.sync('git', ['rev-parse', 'HEAD']); const shortCommit = commit.slice(0, 8); +if (!process.env.JOB_NAME) { + throw new Error('getPercyEnv: [JOB_NAME] environment variable required'); +} + const isPr = process.env.JOB_NAME.includes('elastic+kibana+pull-request'); +if (isPr && !(process.env.PR_TARGET_BRANCH && process.env.PR_SOURCE_BRANCH)) { + throw new Error( + 'getPercyEnv: Unable to determine percy environment in prs without [PR_TARGET_BRANCH] and [PR_SOURCE_BRANCH] environment variables' + ); +} + +let branch; +if (isPr) { + branch = process.env.PR_SOURCE_BRANCH; +} else { + if (!process.env.branch_specifier) { + throw new Error('getPercyEnv: [branch_specifier] environment variable required'); + } + + branch = process.env.branch_specifier.split('refs/heads/')[1]; + + if (!branch) { + throw new Error( + `getPercyEnv: [branch_specifier=${process.env.branch_specifier}] must start with 'refs/heads/'` + ); + } +} console.log(`export PERCY_PARALLEL_TOTAL=2;`); -console.log(`export PERCY_PARALLEL_NONCE="${shortCommit}/${isPr ? 'PR' : pkg.branch}/${process.env.BUILD_ID}";`); +console.log(`export PERCY_PARALLEL_NONCE="${shortCommit}/${isPr ? 'PR' : branch}/${process.env.BUILD_ID}";`); +console.log(`export PERCY_BRANCH="${branch}";`); +// percy snapshots always target pkg.branch, so that feature branches can be based on master/7.x/etc. +console.log(`export PERCY_TARGET_BRANCH="${isPr ? process.env.PR_TARGET_BRANCH : pkg.branch}";`); diff --git a/src/dev/ci_setup/setup_percy.sh b/src/dev/ci_setup/setup_percy.sh index c008dc1d5cdb..ed6a15d056fe 100755 --- a/src/dev/ci_setup/setup_percy.sh +++ b/src/dev/ci_setup/setup_percy.sh @@ -15,3 +15,5 @@ export PUPPETEER_EXECUTABLE_PATH eval "$(node ./src/dev/ci_setup/get_percy_env)" echo " -- PERCY_PARALLEL_NONCE='$PERCY_PARALLEL_NONCE'" echo " -- PERCY_PARALLEL_TOTAL='$PERCY_PARALLEL_TOTAL'" +echo " -- PERCY_BRANCH='$PERCY_BRANCH'" +echo " -- PERCY_TARGET_BRANCH='$PERCY_TARGET_BRANCH'"