Fix percy target branch for PRs (#43160)
* Fix percy target branch for PRs * Add debug logging * Try diff branch name * Use PR_TARGET_BRANCH instead * renable visReg jobs * parse target branch from `branch_specifier` * rename debugging print out * set `PERCY_BRANCH` and `PERCY_TARGET_BRANCH` * log PERCY_TARGET_BRANCH * cleanup error messages
This commit is contained in:
parent
4acfc04f85
commit
fcba9a6456
|
@ -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: ~
|
||||
|
|
|
@ -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}";`);
|
||||
|
|
|
@ -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'"
|
||||
|
|
Loading…
Reference in a new issue