From a4646166532c4df50652440f62ea8266b59dd21f Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Sat, 5 Nov 2022 02:12:24 +0800 Subject: [PATCH] chore: Resolve E2E test failures in forked repos (#15120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * improve * Update scripts/integration-tests/utils/e2e-check.js Co-authored-by: Nicolò Ribaudo * review * Update scripts/integration-tests/utils/e2e-check.js Co-authored-by: Huáng Jùnliàng * review * review * Update scripts/integration-tests/utils/e2e-check.js Co-authored-by: Huáng Jùnliàng Co-authored-by: Nicolò Ribaudo Co-authored-by: Huáng Jùnliàng --- scripts/integration-tests/publish-local.sh | 11 ++++++++++ scripts/integration-tests/utils/e2e-check.js | 21 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 scripts/integration-tests/utils/e2e-check.js diff --git a/scripts/integration-tests/publish-local.sh b/scripts/integration-tests/publish-local.sh index 6e82395d291d..1dd7c1b01a3c 100755 --- a/scripts/integration-tests/publish-local.sh +++ b/scripts/integration-tests/publish-local.sh @@ -25,6 +25,17 @@ initializeE2Egit yarn +# Does not trap on error +node --experimental-fetch scripts/integration-tests/utils/e2e-check.js && :; ret=$? + +if [ $ret -eq 10 ]; then + cleanup + exit 0 +elif [ $ret -ne 0 ]; then + cleanup + exit 1 +fi + startLocalRegistry "$PWD"/scripts/integration-tests/verdaccio-config.yml loginLocalRegistry diff --git a/scripts/integration-tests/utils/e2e-check.js b/scripts/integration-tests/utils/e2e-check.js new file mode 100644 index 000000000000..d45d88e84378 --- /dev/null +++ b/scripts/integration-tests/utils/e2e-check.js @@ -0,0 +1,21 @@ +import fs from "fs"; + +const resp = await fetch( + "https://raw.githubusercontent.com/babel/babel/main/package.json" +); +const mainRepoPackageJson = await resp.json(); + +if ( + mainRepoPackageJson.version !== + JSON.parse(fs.readFileSync("package.json")).version +) { + if (process.env.GITHUB_REPOSITORY === "babel/babel") { + console.error("The branch is not up to date with main, please rebase"); + process.exitCode = 1; + } else { + console.error( + "The branch is not up to date with main of babel/babel, skipping" + ); + process.exitCode = 10; + } +}