From d90a993001d22406154f5439e143b59325aa98f7 Mon Sep 17 00:00:00 2001 From: Liza Dayoub Date: Mon, 12 Aug 2019 16:47:15 -0600 Subject: [PATCH 01/10] Fix percy target branch for PRs --- src/dev/ci_setup/get_percy_env.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index ead64fd2b905..aa3dfd06a9f7 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -25,5 +25,8 @@ const shortCommit = commit.slice(0, 8); const isPr = process.env.JOB_NAME.includes('elastic+kibana+pull-request'); +const { stdout: branch } = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD']); + 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_TARGET_BRANCH="${isPr ? 'master' : branch}";`); From 9ae4376eb9bb9640f501b2b6d382b571160552d1 Mon Sep 17 00:00:00 2001 From: Liza Dayoub Date: Mon, 12 Aug 2019 17:21:47 -0600 Subject: [PATCH 02/10] Add debug logging --- src/dev/ci_setup/get_percy_env.js | 2 +- src/dev/ci_setup/setup_percy.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index aa3dfd06a9f7..26a3c292fcc0 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -29,4 +29,4 @@ const { stdout: branch } = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD 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_TARGET_BRANCH="${isPr ? 'master' : branch}";`); +console.log(`export PERCY_TARGET_BRANCH="${isPr ? process.env.ghprbTargetBranch : branch}";`); diff --git a/src/dev/ci_setup/setup_percy.sh b/src/dev/ci_setup/setup_percy.sh index c008dc1d5cdb..5531cd3c0b0e 100755 --- a/src/dev/ci_setup/setup_percy.sh +++ b/src/dev/ci_setup/setup_percy.sh @@ -15,3 +15,4 @@ 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_TARGET_BRANCH='$PERCY_TARGET_BRANCH'" \ No newline at end of file From 5606b0eeffba0dbf2289f76548ae8802e79433d0 Mon Sep 17 00:00:00 2001 From: Liza Dayoub Date: Tue, 13 Aug 2019 09:17:49 -0600 Subject: [PATCH 03/10] Try diff branch name --- src/dev/ci_setup/get_percy_env.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index 26a3c292fcc0..82db8c57d9b9 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -27,6 +27,8 @@ const isPr = process.env.JOB_NAME.includes('elastic+kibana+pull-request'); const { stdout: branch } = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD']); +const prBranch = 'origin/${process.env.ghprbTargetBranch}'; + 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_TARGET_BRANCH="${isPr ? process.env.ghprbTargetBranch : branch}";`); +console.log(`export PERCY_TARGET_BRANCH="${isPr ? prBranch : branch}";`); From 8e945729229d766a16888060290cd915d2d4e728 Mon Sep 17 00:00:00 2001 From: Liza Dayoub Date: Tue, 13 Aug 2019 10:04:01 -0600 Subject: [PATCH 04/10] Use PR_TARGET_BRANCH instead --- src/dev/ci_setup/get_percy_env.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index 82db8c57d9b9..dd9a6b2ecaab 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -27,7 +27,7 @@ const isPr = process.env.JOB_NAME.includes('elastic+kibana+pull-request'); const { stdout: branch } = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD']); -const prBranch = 'origin/${process.env.ghprbTargetBranch}'; +const prBranch = 'origin/' + process.env.PR_TARGET_BRANCH; console.log(`export PERCY_PARALLEL_TOTAL=2;`); console.log(`export PERCY_PARALLEL_NONCE="${shortCommit}/${isPr ? 'PR' : pkg.branch}/${process.env.BUILD_ID}";`); From 304614746fc7213c28a205ecaecb566740da6802 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 13 Aug 2019 14:10:14 -0700 Subject: [PATCH 05/10] renable visReg jobs --- .ci/jobs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: ~ From 26d483a4890254274225c6d30d4f619251287c96 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 13 Aug 2019 14:11:00 -0700 Subject: [PATCH 06/10] parse target branch from `branch_specifier` --- src/dev/ci_setup/get_percy_env.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index dd9a6b2ecaab..7a0dca496c39 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -24,11 +24,21 @@ const { stdout: commit } = execa.sync('git', ['rev-parse', 'HEAD']); const shortCommit = commit.slice(0, 8); const isPr = process.env.JOB_NAME.includes('elastic+kibana+pull-request'); +let branch = process.env.PR_TARGET_BRANCH; -const { stdout: branch } = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD']); +if (!isPr) { + if (!process.env.branch_specifier) { + throw new Error('Unable to determine PERCY_BRANCH without a [branch_specifier]'); + } -const prBranch = 'origin/' + process.env.PR_TARGET_BRANCH; + [, branch] = process.env.branch_specifier.split('refs/heads/'); + if (!branch) { + throw new Error( + `Unable to determine PERCY_BRANCH from [branch_specifier=${process.env.branch_specifier}], expected it to 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_TARGET_BRANCH="${isPr ? prBranch : branch}";`); +console.log(`export PERCY_BRANCH="${branch}";`); From fa572716c36a21484c6b01f746144f82b78c74f5 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 13 Aug 2019 14:16:48 -0700 Subject: [PATCH 07/10] rename debugging print out --- src/dev/ci_setup/setup_percy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/ci_setup/setup_percy.sh b/src/dev/ci_setup/setup_percy.sh index 5531cd3c0b0e..ccfd98b555ea 100755 --- a/src/dev/ci_setup/setup_percy.sh +++ b/src/dev/ci_setup/setup_percy.sh @@ -15,4 +15,4 @@ 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_TARGET_BRANCH='$PERCY_TARGET_BRANCH'" \ No newline at end of file +echo " -- PERCY_BRANCH='$PERCY_BRANCH'" From 31dd2bd41c55844810d38d23baefd8be43f9fa50 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 13 Aug 2019 15:56:36 -0700 Subject: [PATCH 08/10] set `PERCY_BRANCH` and `PERCY_TARGET_BRANCH` --- src/dev/ci_setup/get_percy_env.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index 7a0dca496c39..f140601ffa3b 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -23,22 +23,34 @@ 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'); -let branch = process.env.PR_TARGET_BRANCH; +if (isPr && !(process.env.PR_TARGET_BRANCH && process.env.PR_SOURCE_BRANCH)) { + throw new Error('Unable to determine percy environment in prs without [PR_TARGET_BRANCH] and [PR_SOURCE_BRANCH] environment variables'); +} -if (!isPr) { +let branch; +if (isPr) { + branch = process.env.PR_SOURCE_BRANCH; +} else { if (!process.env.branch_specifier) { - throw new Error('Unable to determine PERCY_BRANCH without a [branch_specifier]'); + throw new Error('getPercyEnv: branch_specifier environment variable required'); } - [, branch] = process.env.branch_specifier.split('refs/heads/'); + branch = process.env.branch_specifier.split('refs/heads/')[1]; + if (!branch) { throw new Error( - `Unable to determine PERCY_BRANCH from [branch_specifier=${process.env.branch_specifier}], expected it to start with [refs/heads/]` + `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}";`); From 9015e487e2733a0289e13bf027f8711fda407628 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 13 Aug 2019 15:58:11 -0700 Subject: [PATCH 09/10] log PERCY_TARGET_BRANCH --- src/dev/ci_setup/setup_percy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dev/ci_setup/setup_percy.sh b/src/dev/ci_setup/setup_percy.sh index ccfd98b555ea..ed6a15d056fe 100755 --- a/src/dev/ci_setup/setup_percy.sh +++ b/src/dev/ci_setup/setup_percy.sh @@ -16,3 +16,4 @@ 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'" From 8d6023a3d336b0a80fcae4e6aebccc791475b492 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 13 Aug 2019 15:59:52 -0700 Subject: [PATCH 10/10] cleanup error messages --- src/dev/ci_setup/get_percy_env.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dev/ci_setup/get_percy_env.js b/src/dev/ci_setup/get_percy_env.js index f140601ffa3b..66853ef2a5af 100644 --- a/src/dev/ci_setup/get_percy_env.js +++ b/src/dev/ci_setup/get_percy_env.js @@ -24,12 +24,14 @@ 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'); + 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('Unable to determine percy environment in prs without [PR_TARGET_BRANCH] and [PR_SOURCE_BRANCH] environment variables'); + throw new Error( + 'getPercyEnv: Unable to determine percy environment in prs without [PR_TARGET_BRANCH] and [PR_SOURCE_BRANCH] environment variables' + ); } let branch; @@ -37,14 +39,14 @@ if (isPr) { branch = process.env.PR_SOURCE_BRANCH; } else { if (!process.env.branch_specifier) { - throw new Error('getPercyEnv: branch_specifier environment variable required'); + 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/]` + `getPercyEnv: [branch_specifier=${process.env.branch_specifier}] must start with 'refs/heads/'` ); } }