From eec6e0a4924566f954e2e7595edb08fa9754821b Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 27 Oct 2023 03:33:10 -0700 Subject: [PATCH] patch-external: fail CI build Signed-off-by: Varun Patil --- Makefile | 5 +---- scripts/patch-external.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 scripts/patch-external.sh diff --git a/Makefile b/Makefile index 9e38ef85..0fca5f78 100644 --- a/Makefile +++ b/Makefile @@ -31,10 +31,7 @@ build-js-production: rm -f js/* && npm run build patch-external: - patch -p1 -N < patches/scroller-perf.patch || true - patch -p1 -N < patches/scroller-sticky.patch || true - patch -p1 -N < patches/plyr-wrap.patch || true - patch -p1 -N < patches/videojs-vhs-1439.patch || true + bash scripts/patch-external.sh watch-js: npm run watch diff --git a/scripts/patch-external.sh b/scripts/patch-external.sh new file mode 100755 index 00000000..c4c670e8 --- /dev/null +++ b/scripts/patch-external.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# This script is used to patch external libraries. +# If any patch fails, the script will exit with error code 1. + +# Do not exit on failure so that we can print all errors at once. +set +e + +# Check if the script is called from the root folder of the project. +if [ ! -f "scripts/patch-external.sh" ]; then + echo -e "\033[0;33mPlease run this script from the root folder of the project.\033[0m" + exit 1 +fi + +# Make sure node_modules is installed. +if [ ! -d "node_modules" ]; then + echo -e "\033[0;33mPlease run 'npm install' before running this script.\033[0m" + exit 1 +fi + +# Apply all patches. +HAS_ERROR=0 +for patch in patches/*.patch; do + echo -e "\n\033[0;32mApplying patch: $patch\033[0m" + patch -p1 -N < $patch + if [ $? -ne 0 ]; then + echo -e "\033[0;33mFailed to apply patch: $patch\033[0m" + HAS_ERROR=1 + fi +done + +# Exit with error code if any patch failed. +# This way we fail the CI build. +if [ $HAS_ERROR -ne 0 ]; then + echo -e "\n\033[0;31mFailed to apply some patches. See above for details.\033[0m" + exit 1 +else + echo -e "\n\033[0;32mAll patches applied successfully.\033[0m" +fi \ No newline at end of file