From 6c9835a89f04e6f15b7697ba37944371b1ce8579 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:41:42 +0100 Subject: [PATCH 01/30] Add install-pkgx.sh --- Scripts/install-pkgx.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Scripts/install-pkgx.sh diff --git a/Scripts/install-pkgx.sh b/Scripts/install-pkgx.sh new file mode 100644 index 000000000..35036b3fc --- /dev/null +++ b/Scripts/install-pkgx.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +echo "Installing pkgx..." +curl -Ssf https://pkgx.sh | sh &> /dev/null +echo "... done." From aa345560833d37e443f8a7a2967319e41cc25068 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:41:53 +0100 Subject: [PATCH 02/30] Add install-bundler.sh --- Scripts/install-bundler.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Scripts/install-bundler.sh diff --git a/Scripts/install-bundler.sh b/Scripts/install-bundler.sh new file mode 100644 index 000000000..96c4c452f --- /dev/null +++ b/Scripts/install-bundler.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +echo "Installing bundler..." +pkgx bundle config set path '.bundle' +pkgx bundle install +echo "... done." From 621d7e026973b9a5cbfe7d80fb1493929ad2ad2c Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 08:11:29 +0100 Subject: [PATCH 03/30] Set scripts permissions --- Scripts/install-bundler.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 Scripts/install-bundler.sh diff --git a/Scripts/install-bundler.sh b/Scripts/install-bundler.sh old mode 100644 new mode 100755 From 8ab42bd7a1b474ec3a5de2f03810706c606a6487 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 08:11:48 +0100 Subject: [PATCH 04/30] Move archive-demo target in a dedicated script --- .github/workflows/ci.yml | 2 +- Makefile | 26 +++++---------------- Scripts/archive-demo.sh | 50 ++++++++++++++++++++++++++++++++++++++++ Scripts/install-pkgx.sh | 0 4 files changed, 57 insertions(+), 21 deletions(-) create mode 100755 Scripts/archive-demo.sh mode change 100644 => 100755 Scripts/install-pkgx.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10c588e22..447ccc136 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: ${{ secrets.APP_STORE_CONNECT_API_KEY }} - name: Archive the demo - run: make archive-demo-${{ matrix.platform }} + run: make archive-demo-${{ matrix.platform }} MODE="--non-interactive" env: TEAM_ID: ${{ secrets.TEAM_ID }} KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} diff --git a/Makefile b/Makefile index 1f7b95cce..ce3c0e9ee 100644 --- a/Makefile +++ b/Makefile @@ -3,30 +3,14 @@ .PHONY: all all: help -.PHONY: install-pkgx -install-pkgx: - @echo "Installing pkgx..." - @curl -Ssf https://pkgx.sh | sh &> /dev/null - @echo "... done.\n" - -.PHONY: install-bundler -install-bundler: - @echo "Installing bundler..." - @pkgx bundle config set path '.bundle' - @pkgx bundle install - @echo "... done.\n" - -.PHONY: fastlane -fastlane: install-pkgx install-bundler - @pkgx bundle exec fastlane .PHONY: archive-demo-ios -archive-demo-ios: install-pkgx install-bundler - @pkgx bundle exec fastlane archive_demo_ios +archive-demo-ios: + @Scripts/archive-demo.sh $(MODE) --platform ios .PHONY: archive-demo-tvos -archive-demo-tvos: install-pkgx install-bundler - @pkgx bundle exec fastlane archive_demo_tvos +archive-demo-tvos: + @Scripts/archive-demo.sh $(MODE) --platform tvos .PHONY: deliver-demo-nightly-ios deliver-demo-nightly-ios: install-pkgx install-bundler @@ -142,7 +126,9 @@ help: @echo " fastlane Run fastlane" @echo "" @echo " archive-demo-ios Archive the iOS demo (for all configurations)" + @echo " Example: make archive-demo-ios MODE=--non-interactive (interactive by default)" @echo " archive-demo-tvos Archive the tvOS demo (for all configurations)" + @echo " Example: make archive-demo-tvos MODE=--non-interactive (interactive by default)" @echo "" @echo " deliver-demo-nightly-ios Deliver a demo nightly build for iOS" @echo " deliver-demo-nightly-tvos Deliver a demo nightly build for tvOS" diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh new file mode 100755 index 000000000..bd12f2124 --- /dev/null +++ b/Scripts/archive-demo.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +function usage { + if [[ $# -lt 2 ]]; then + echo + echo "Usage: $0 [--non-interactive] --platform [ios | tvos]" + echo + echo "Params:" + echo " --non-interactive: (Optional) Avoid setting the ENV variables interactively (interactive by default)." + echo " --platform: (Required) Platform for which to archive the demo." + echo + exit 1 + fi +} + +usage "$1" "$2" + +PLATFORM="" +IS_INTERACTIVE=true + +if [[ $1 == "--non-interactive" && $2 == "--platform" ]]; then + IS_INTERACTIVE=false + PLATFORM="$3" +elif [[ $1 == "--platform" ]]; then + PLATFORM="$2" +else + usage "$1" "$2" +fi + +TEAM_ID="" +KEY_ISSUER_ID="" +KEY_ID="" +APPLE_API_KEY_BASE64="" + +if [[ $IS_INTERACTIVE == true ]]; then + read -rp "TEAM_ID: " TEAM_ID + read -rp "KEY_ISSUER_ID: " KEY_ISSUER_ID + read -rp "KEY_ID: " KEY_ID + read -rp "APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 + export TEAM_ID + export KEY_ISSUER_ID + export KEY_ID + "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" +fi + +if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then + usage "$1" "$2" +fi + +pkgx bundle exec fastlane "archive_demo_$PLATFORM" \ No newline at end of file diff --git a/Scripts/install-pkgx.sh b/Scripts/install-pkgx.sh old mode 100644 new mode 100755 From 3426d008d8d54ca258e65a9e69fe04486ee76d19 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:18:52 +0100 Subject: [PATCH 05/30] Improve Makefile doc --- Makefile | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index ce3c0e9ee..2f90de81f 100644 --- a/Makefile +++ b/Makefile @@ -120,36 +120,34 @@ find-dead-code: .PHONY: help help: @echo "The following targets are available:" - @echo "" + @echo @echo " all Default target" - @echo "" - @echo " fastlane Run fastlane" - @echo "" + @echo @echo " archive-demo-ios Archive the iOS demo (for all configurations)" @echo " Example: make archive-demo-ios MODE=--non-interactive (interactive by default)" @echo " archive-demo-tvos Archive the tvOS demo (for all configurations)" @echo " Example: make archive-demo-tvos MODE=--non-interactive (interactive by default)" - @echo "" + @echo @echo " deliver-demo-nightly-ios Deliver a demo nightly build for iOS" @echo " deliver-demo-nightly-tvos Deliver a demo nightly build for tvOS" - @echo "" + @echo @echo " deliver-demo-release-ios Deliver a demo release build for iOS" @echo " deliver-demo-release-tvos Deliver a demo release build for tvOS" - @echo "" + @echo @echo " test-streams-start Start servicing test streams" @echo " test-streams-stop Stop servicing test streams" - @echo "" + @echo @echo " test-ios Build and run unit tests for iOS" @echo " test-tvos Build and run unit tests for tvOS" - @echo "" + @echo @echo " check-quality Run quality checks" @echo " fix-quality Fix quality automatically (if possible)" - @echo "" + @echo @echo " git-hook-install Use hooks located in ./hooks" @echo " git-hook-uninstall Use default hooks located in .git/hooks" - @echo "" + @echo @echo " spm-reload Reload SPM dependencies" @echo " clean-imports Remove useless imports from the project" @echo " find-dead-code Find dead code" - @echo "" + @echo @echo " help Display this help message" From 96d5556c0250e3b699a1e45531eb68d0a8dc779a Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:15:19 +0100 Subject: [PATCH 06/30] Improve archive-demo.sh --- Makefile | 2 +- Scripts/archive-demo.sh | 46 +++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 2f90de81f..143e13b79 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: help .PHONY: archive-demo-ios -archive-demo-ios: +archive-demo-ios: @Scripts/archive-demo.sh $(MODE) --platform ios .PHONY: archive-demo-tvos diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh index bd12f2124..07be25e2d 100755 --- a/Scripts/archive-demo.sh +++ b/Scripts/archive-demo.sh @@ -1,20 +1,16 @@ #!/bin/bash function usage { - if [[ $# -lt 2 ]]; then - echo - echo "Usage: $0 [--non-interactive] --platform [ios | tvos]" - echo - echo "Params:" - echo " --non-interactive: (Optional) Avoid setting the ENV variables interactively (interactive by default)." - echo " --platform: (Required) Platform for which to archive the demo." - echo - exit 1 - fi + echo + echo "[!] Usage: $0 [--non-interactive] --platform [ios | tvos]" + echo + echo " Params:" + echo " --non-interactive: (Optional) Avoid setting the ENV variables interactively (interactive by default)." + echo " --platform: (Required) Platform for which to archive the demo." + echo + exit 1 } -usage "$1" "$2" - PLATFORM="" IS_INTERACTIVE=true @@ -24,27 +20,33 @@ if [[ $1 == "--non-interactive" && $2 == "--platform" ]]; then elif [[ $1 == "--platform" ]]; then PLATFORM="$2" else - usage "$1" "$2" + usage +fi + +if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then + usage fi +echo -e "Archiving $PLATFORM demo..." + TEAM_ID="" KEY_ISSUER_ID="" KEY_ID="" APPLE_API_KEY_BASE64="" if [[ $IS_INTERACTIVE == true ]]; then - read -rp "TEAM_ID: " TEAM_ID - read -rp "KEY_ISSUER_ID: " KEY_ISSUER_ID - read -rp "KEY_ID: " KEY_ID - read -rp "APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 + echo "Please provide information related to your Apple account:" + echo + read -rp " TEAM_ID: " TEAM_ID + read -rp " KEY_ISSUER_ID: " KEY_ISSUER_ID + read -rp " KEY_ID: " KEY_ID + read -rp " APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 export TEAM_ID export KEY_ISSUER_ID export KEY_ID "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" + echo fi -if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then - usage "$1" "$2" -fi - -pkgx bundle exec fastlane "archive_demo_$PLATFORM" \ No newline at end of file +pkgx bundle exec fastlane "archive_demo_$PLATFORM" +echo "... done" \ No newline at end of file From 3d1742635c5b13f8c4dec9be2d2617c78cfa91f2 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:35:26 +0100 Subject: [PATCH 07/30] Install pkgx and bundler before running archive --- Scripts/archive-demo.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh index 07be25e2d..acebedaac 100755 --- a/Scripts/archive-demo.sh +++ b/Scripts/archive-demo.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + function usage { echo echo "[!] Usage: $0 [--non-interactive] --platform [ios | tvos]" @@ -44,9 +46,12 @@ if [[ $IS_INTERACTIVE == true ]]; then export TEAM_ID export KEY_ISSUER_ID export KEY_ID - "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" echo + "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" fi +"$(dirname "$0")/install-pkgx.sh" +"$(dirname "$0")/install-bundler.sh" + pkgx bundle exec fastlane "archive_demo_$PLATFORM" echo "... done" \ No newline at end of file From 26701f4b27998cd8a9e51542d94d9df00a2ec2ad Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:44:26 +0100 Subject: [PATCH 08/30] Print more information when the script fails --- Scripts/archive-demo.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh index acebedaac..a6c9ee3a4 100755 --- a/Scripts/archive-demo.sh +++ b/Scripts/archive-demo.sh @@ -43,10 +43,21 @@ if [[ $IS_INTERACTIVE == true ]]; then read -rp " KEY_ISSUER_ID: " KEY_ISSUER_ID read -rp " KEY_ID: " KEY_ID read -rp " APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 + + if [[ -z "$TEAM_ID" || -z "$KEY_ISSUER_ID" || -z "$KEY_ID" || -z "$APPLE_API_KEY_BASE64" ]]; then + echo + [[ -z "$TEAM_ID" ]] && echo " TEAM_ID is missing!" + [[ -z "$KEY_ISSUER_ID" ]] && echo " KEY_ISSUER_ID is missing!" + [[ -z "$KEY_ID" ]] && echo " KEY_ID is missing!" + [[ -z "$APPLE_API_KEY_BASE64" ]] && echo " APPLE_API_KEY_BASE64 is missing!" + exit 1 + fi + echo + export TEAM_ID export KEY_ISSUER_ID export KEY_ID - echo + "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" fi From 2a48330cc11f0fbd39d863d887d4368080172870 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:49:46 +0100 Subject: [PATCH 09/30] Use scripts to install pkgx and bundler --- Makefile | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 143e13b79..b8f123518 100644 --- a/Makefile +++ b/Makefile @@ -13,43 +13,54 @@ archive-demo-tvos: @Scripts/archive-demo.sh $(MODE) --platform tvos .PHONY: deliver-demo-nightly-ios -deliver-demo-nightly-ios: install-pkgx install-bundler +deliver-demo-nightly-ios: + @Scripts/install-pkgx.sh + @Scripts/install-bundler.sh @echo "Delivering demo nightly build for iOS..." @pkgx +magick +rsvg-convert bundle exec fastlane deliver_demo_nightly_ios @echo "... done.\n" .PHONY: deliver-demo-nightly-tvos -deliver-demo-nightly-tvos: install-pkgx install-bundler +deliver-demo-nightly-tvos: + @Scripts/install-pkgx.sh + @Scripts/install-bundler.sh @echo "Delivering demo nightly build for tvOS..." @pkgx +magick +rsvg-convert bundle exec fastlane deliver_demo_nightly_tvos @echo "... done.\n" .PHONY: deliver-demo-release-ios -deliver-demo-release-ios: install-pkgx install-bundler +deliver-demo-release-ios: + @Scripts/install-pkgx.sh + @Scripts/install-bundler.sh @echo "Delivering demo release build for iOS..." @pkgx bundle exec fastlane deliver_demo_release_ios @echo "... done.\n" .PHONY: deliver-demo-release-tvos install-bundler -deliver-demo-release-tvos: install-pkgx +deliver-demo-release-tvos: + @Scripts/install-pkgx.sh @echo "Delivering demo release build for tvOS..." @pkgx bundle exec fastlane deliver_demo_release_tvos @echo "... done.\n" .PHONY: test-streams-start -test-streams-start: install-pkgx +test-streams-start: + @Scripts/install-pkgx.sh @echo "Starting test streams" @Scripts/test-streams.sh -s @echo "... done.\n" .PHONY: test-streams-stop -test-streams-stop: install-pkgx +test-streams-stop: + @Scripts/install-pkgx.sh @echo "Stopping test streams" @Scripts/test-streams.sh -k @echo "... done.\n" .PHONY: test-ios -test-ios: install-pkgx install-bundler +test-ios: + @Scripts/install-pkgx.sh + @Scripts/install-bundler.sh @echo "Running unit tests..." @Scripts/test-streams.sh -s @pkgx bundle exec fastlane test_ios @@ -57,7 +68,9 @@ test-ios: install-pkgx install-bundler @echo "... done.\n" .PHONY: test-tvos -test-tvos: install-pkgx install-bundler +test-tvos: + @Scripts/install-pkgx.sh + @Scripts/install-bundler.sh @echo "Running unit tests..." @Scripts/test-streams.sh -s @pkgx bundle exec fastlane test_tvos @@ -65,13 +78,15 @@ test-tvos: install-pkgx install-bundler @echo "... done.\n" .PHONY: check-quality -check-quality: install-pkgx +check-quality: + @Scripts/install-pkgx.sh @echo "Checking quality..." @Scripts/check-quality.sh @echo "... done.\n" .PHONY: fix-quality -fix-quality: install-pkgx +fix-quality: + @Scripts/install-pkgx.sh @echo "Fixing quality..." @Scripts/fix-quality.sh @echo "... done.\n" From aa3ac2ed61a928b1e9ab6f3fe5a2ecb1df4b9807 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:05:21 +0100 Subject: [PATCH 10/30] Improve archive-demo script --- Scripts/archive-demo.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh index a6c9ee3a4..eac423420 100755 --- a/Scripts/archive-demo.sh +++ b/Scripts/archive-demo.sh @@ -31,12 +31,12 @@ fi echo -e "Archiving $PLATFORM demo..." -TEAM_ID="" -KEY_ISSUER_ID="" -KEY_ID="" -APPLE_API_KEY_BASE64="" - if [[ $IS_INTERACTIVE == true ]]; then + TEAM_ID="" + KEY_ISSUER_ID="" + KEY_ID="" + APPLE_API_KEY_BASE64="" + echo "Please provide information related to your Apple account:" echo read -rp " TEAM_ID: " TEAM_ID @@ -53,7 +53,7 @@ if [[ $IS_INTERACTIVE == true ]]; then exit 1 fi echo - + export TEAM_ID export KEY_ISSUER_ID export KEY_ID From d38d7407e74de9ff34dc90cc3b0e95ec16accd4f Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:20:33 +0100 Subject: [PATCH 11/30] Add deliver-demo script --- Makefile | 27 +++++--------- Scripts/deliver-demo.sh | 79 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 19 deletions(-) create mode 100755 Scripts/deliver-demo.sh diff --git a/Makefile b/Makefile index b8f123518..85cb84530 100644 --- a/Makefile +++ b/Makefile @@ -14,34 +14,19 @@ archive-demo-tvos: .PHONY: deliver-demo-nightly-ios deliver-demo-nightly-ios: - @Scripts/install-pkgx.sh - @Scripts/install-bundler.sh - @echo "Delivering demo nightly build for iOS..." - @pkgx +magick +rsvg-convert bundle exec fastlane deliver_demo_nightly_ios - @echo "... done.\n" + @Scripts/deliver-demo.sh $(MODE) --platform ios --configuration nightly .PHONY: deliver-demo-nightly-tvos deliver-demo-nightly-tvos: - @Scripts/install-pkgx.sh - @Scripts/install-bundler.sh - @echo "Delivering demo nightly build for tvOS..." - @pkgx +magick +rsvg-convert bundle exec fastlane deliver_demo_nightly_tvos - @echo "... done.\n" + @Scripts/deliver-demo.sh $(MODE) --platform tvos --configuration nightly .PHONY: deliver-demo-release-ios deliver-demo-release-ios: - @Scripts/install-pkgx.sh - @Scripts/install-bundler.sh - @echo "Delivering demo release build for iOS..." - @pkgx bundle exec fastlane deliver_demo_release_ios - @echo "... done.\n" + @Scripts/deliver-demo.sh $(MODE) --platform ios --configuration release .PHONY: deliver-demo-release-tvos install-bundler deliver-demo-release-tvos: - @Scripts/install-pkgx.sh - @echo "Delivering demo release build for tvOS..." - @pkgx bundle exec fastlane deliver_demo_release_tvos - @echo "... done.\n" + @Scripts/deliver-demo.sh $(MODE) --platform tvos --configuration release .PHONY: test-streams-start test-streams-start: @@ -144,10 +129,14 @@ help: @echo " Example: make archive-demo-tvos MODE=--non-interactive (interactive by default)" @echo @echo " deliver-demo-nightly-ios Deliver a demo nightly build for iOS" + @echo " Example: make deliver-demo-nightly-ios MODE=--non-interactive (interactive by default)" @echo " deliver-demo-nightly-tvos Deliver a demo nightly build for tvOS" + @echo " Example: make deliver-demo-nightly-tvos MODE=--non-interactive (interactive by default)" @echo @echo " deliver-demo-release-ios Deliver a demo release build for iOS" + @echo " Example: make deliver-demo-release-ios MODE=--non-interactive (interactive by default)" @echo " deliver-demo-release-tvos Deliver a demo release build for tvOS" + @echo " Example: make deliver-demo-release-tvos MODE=--non-interactive (interactive by default)" @echo @echo " test-streams-start Start servicing test streams" @echo " test-streams-stop Stop servicing test streams" diff --git a/Scripts/deliver-demo.sh b/Scripts/deliver-demo.sh new file mode 100755 index 000000000..382187d2a --- /dev/null +++ b/Scripts/deliver-demo.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +set -e + +function usage { + echo + echo "[!] Usage: $0 [--non-interactive] --platform [ios | tvos] --configuration [nightly | release]" + echo + echo " Params:" + echo " --non-interactive: (Optional) Avoid setting the ENV variables interactively (interactive by default)." + echo " --platform: (Required) Platform for which to deliver the demo." + echo " --configuration: (Required) Configuration for which to deliver the demo." + echo + exit 1 +} + +PLATFORM="" +CONFIGURATION="" +IS_INTERACTIVE=true + +if [[ $1 == "--non-interactive" && $2 == "--platform" && $4 == "--configuration" ]]; then + IS_INTERACTIVE=false + PLATFORM="$3" + CONFIGURATION="$5" +elif [[ $1 == "--platform" && $3 == "--configuration" ]]; then + PLATFORM="$2" + CONFIGURATION="$4" +else + usage +fi + +if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then + usage +fi + +if [[ $CONFIGURATION != "nightly" && $CONFIGURATION != "release" ]]; then + usage +fi + +echo -e "Delivering demo $CONFIGURATION build for $PLATFORM..." + +if [[ $IS_INTERACTIVE == true ]]; then + TEAM_ID="" + KEY_ISSUER_ID="" + KEY_ID="" + APPLE_API_KEY_BASE64="" + + echo "Please provide information related to your Apple account:" + echo + read -rp " TEAM_ID: " TEAM_ID + read -rp " KEY_ISSUER_ID: " KEY_ISSUER_ID + read -rp " KEY_ID: " KEY_ID + read -rp " APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 + + if [[ -z "$TEAM_ID" || -z "$KEY_ISSUER_ID" || -z "$KEY_ID" || -z "$APPLE_API_KEY_BASE64" ]]; then + echo + [[ -z "$TEAM_ID" ]] && echo " TEAM_ID is missing!" + [[ -z "$KEY_ISSUER_ID" ]] && echo " KEY_ISSUER_ID is missing!" + [[ -z "$KEY_ID" ]] && echo " KEY_ID is missing!" + [[ -z "$APPLE_API_KEY_BASE64" ]] && echo " APPLE_API_KEY_BASE64 is missing!" + exit 1 + fi + echo + + export TEAM_ID + export KEY_ISSUER_ID + export KEY_ID + + "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" +fi + +"$(dirname "$0")/install-pkgx.sh" +"$(dirname "$0")/install-bundler.sh" + +eval "$(pkgx --shellcode)" +env +bundle +magick +rsvg-convert + +bundle exec fastlane "deliver_demo_${CONFIGURATION}_${PLATFORM}" +echo "... done" \ No newline at end of file From 98eb6f35355f101550dc7b6b1e5e056e58bc1514 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:23:08 +0100 Subject: [PATCH 12/30] Update nightly and release workflows to use non-interactive Makefile targets --- .github/workflows/nightlies.yml | 3 ++- .github/workflows/releases.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightlies.yml b/.github/workflows/nightlies.yml index 3eda4af04..bde9bdaa9 100644 --- a/.github/workflows/nightlies.yml +++ b/.github/workflows/nightlies.yml @@ -34,7 +34,8 @@ jobs: - name: Deliver the demo run: | - make deliver-demo-nightly-${{ matrix.platform }} + make deliver-demo-nightly-${{ matrix.platform }} \ + MODE="--non-interactive" env: TEAM_ID: ${{ secrets.TEAM_ID }} KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 418c0e4be..acdff5d03 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -34,7 +34,8 @@ jobs: - name: Deliver the demo run: | - make deliver-demo-release-${{ matrix.platform }} + make deliver-demo-release-${{ matrix.platform }} \ + MODE="--non-interactive" env: TEAM_ID: ${{ secrets.TEAM_ID }} KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} From 10797320ba902dc0dff958bfbd61cf2e1d7d96d4 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:32:54 +0100 Subject: [PATCH 13/30] Update Makefile help --- Makefile | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 85cb84530..597811bf7 100644 --- a/Makefile +++ b/Makefile @@ -119,39 +119,39 @@ find-dead-code: .PHONY: help help: - @echo "The following targets are available:" + @echo "Available targets:" @echo - @echo " all Default target" + @echo "Default:" + @echo " all Default target" @echo - @echo " archive-demo-ios Archive the iOS demo (for all configurations)" - @echo " Example: make archive-demo-ios MODE=--non-interactive (interactive by default)" - @echo " archive-demo-tvos Archive the tvOS demo (for all configurations)" - @echo " Example: make archive-demo-tvos MODE=--non-interactive (interactive by default)" + @echo "Archive:" + @echo " archive-demo-ios Archive iOS demo [MODE=\"--non-interactive\"]" + @echo " archive-demo-tvos Archive tvOS demo [MODE=\"--non-interactive\"]" @echo - @echo " deliver-demo-nightly-ios Deliver a demo nightly build for iOS" - @echo " Example: make deliver-demo-nightly-ios MODE=--non-interactive (interactive by default)" - @echo " deliver-demo-nightly-tvos Deliver a demo nightly build for tvOS" - @echo " Example: make deliver-demo-nightly-tvos MODE=--non-interactive (interactive by default)" + @echo "Deliver:" + @echo " deliver-demo-nightly-ios Deliver nightly iOS demo build [MODE=\"--non-interactive\"]" + @echo " deliver-demo-nightly-tvos Deliver nightly tvOS demo build [MODE=\"--non-interactive\"]" + @echo " deliver-demo-release-ios Deliver release iOS demo build [MODE=\"--non-interactive\"]" + @echo " deliver-demo-release-tvos Deliver release tvOS demo build [MODE=\"--non-interactive\"]" @echo - @echo " deliver-demo-release-ios Deliver a demo release build for iOS" - @echo " Example: make deliver-demo-release-ios MODE=--non-interactive (interactive by default)" - @echo " deliver-demo-release-tvos Deliver a demo release build for tvOS" - @echo " Example: make deliver-demo-release-tvos MODE=--non-interactive (interactive by default)" + @echo "Test:" + @echo " test-streams-start Start test streams" + @echo " test-streams-stop Stop test streams" + @echo " test-ios Build & run iOS unit tests" + @echo " test-tvos Build & run tvOS unit tests" @echo - @echo " test-streams-start Start servicing test streams" - @echo " test-streams-stop Stop servicing test streams" + @echo "Quality:" + @echo " check-quality Run quality checks" + @echo " fix-quality Automatically fix quality issues" @echo - @echo " test-ios Build and run unit tests for iOS" - @echo " test-tvos Build and run unit tests for tvOS" + @echo "Git Hooks:" + @echo " git-hook-install Install custom hooks from ./hooks" + @echo " git-hook-uninstall Revert to default hooks" @echo - @echo " check-quality Run quality checks" - @echo " fix-quality Fix quality automatically (if possible)" + @echo "Utilities:" + @echo " spm-reload Reload SPM dependencies" + @echo " clean-imports Remove unused imports" + @echo " find-dead-code Locate dead code" @echo - @echo " git-hook-install Use hooks located in ./hooks" - @echo " git-hook-uninstall Use default hooks located in .git/hooks" - @echo - @echo " spm-reload Reload SPM dependencies" - @echo " clean-imports Remove useless imports from the project" - @echo " find-dead-code Find dead code" - @echo - @echo " help Display this help message" + @echo "Other:" + @echo " help Show this help message" From 4340c261bec92f867f9620782d5a1a3264e7740a Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:19:32 +0100 Subject: [PATCH 14/30] Factorize interactive part --- Scripts/archive-demo.sh | 33 +++------------------- Scripts/deliver-demo.sh | 33 +++------------------- Scripts/set-apple-api-env-interactively.sh | 28 ++++++++++++++++++ 3 files changed, 36 insertions(+), 58 deletions(-) create mode 100755 Scripts/set-apple-api-env-interactively.sh diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh index eac423420..43c499aae 100755 --- a/Scripts/archive-demo.sh +++ b/Scripts/archive-demo.sh @@ -32,37 +32,12 @@ fi echo -e "Archiving $PLATFORM demo..." if [[ $IS_INTERACTIVE == true ]]; then - TEAM_ID="" - KEY_ISSUER_ID="" - KEY_ID="" - APPLE_API_KEY_BASE64="" - - echo "Please provide information related to your Apple account:" - echo - read -rp " TEAM_ID: " TEAM_ID - read -rp " KEY_ISSUER_ID: " KEY_ISSUER_ID - read -rp " KEY_ID: " KEY_ID - read -rp " APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 - - if [[ -z "$TEAM_ID" || -z "$KEY_ISSUER_ID" || -z "$KEY_ID" || -z "$APPLE_API_KEY_BASE64" ]]; then - echo - [[ -z "$TEAM_ID" ]] && echo " TEAM_ID is missing!" - [[ -z "$KEY_ISSUER_ID" ]] && echo " KEY_ISSUER_ID is missing!" - [[ -z "$KEY_ID" ]] && echo " KEY_ID is missing!" - [[ -z "$APPLE_API_KEY_BASE64" ]] && echo " APPLE_API_KEY_BASE64 is missing!" - exit 1 - fi - echo - - export TEAM_ID - export KEY_ISSUER_ID - export KEY_ID - - "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" + source Scripts/set-apple-api-env-interactively.sh + Scripts/configure-environment.sh "$APPLE_API_KEY_BASE64" fi -"$(dirname "$0")/install-pkgx.sh" -"$(dirname "$0")/install-bundler.sh" +Scripts/install-pkgx.sh +Scripts/install-bundler.sh pkgx bundle exec fastlane "archive_demo_$PLATFORM" echo "... done" \ No newline at end of file diff --git a/Scripts/deliver-demo.sh b/Scripts/deliver-demo.sh index 382187d2a..7ec3d7b07 100755 --- a/Scripts/deliver-demo.sh +++ b/Scripts/deliver-demo.sh @@ -40,37 +40,12 @@ fi echo -e "Delivering demo $CONFIGURATION build for $PLATFORM..." if [[ $IS_INTERACTIVE == true ]]; then - TEAM_ID="" - KEY_ISSUER_ID="" - KEY_ID="" - APPLE_API_KEY_BASE64="" - - echo "Please provide information related to your Apple account:" - echo - read -rp " TEAM_ID: " TEAM_ID - read -rp " KEY_ISSUER_ID: " KEY_ISSUER_ID - read -rp " KEY_ID: " KEY_ID - read -rp " APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 - - if [[ -z "$TEAM_ID" || -z "$KEY_ISSUER_ID" || -z "$KEY_ID" || -z "$APPLE_API_KEY_BASE64" ]]; then - echo - [[ -z "$TEAM_ID" ]] && echo " TEAM_ID is missing!" - [[ -z "$KEY_ISSUER_ID" ]] && echo " KEY_ISSUER_ID is missing!" - [[ -z "$KEY_ID" ]] && echo " KEY_ID is missing!" - [[ -z "$APPLE_API_KEY_BASE64" ]] && echo " APPLE_API_KEY_BASE64 is missing!" - exit 1 - fi - echo - - export TEAM_ID - export KEY_ISSUER_ID - export KEY_ID - - "$(dirname "$0")/configure-environment.sh" "$APPLE_API_KEY_BASE64" + source Scripts/set-apple-api-env-interactively.sh + Scripts/configure-environment.sh "$APPLE_API_KEY_BASE64" fi -"$(dirname "$0")/install-pkgx.sh" -"$(dirname "$0")/install-bundler.sh" +Scripts/install-pkgx.sh +Scripts/install-bundler.sh eval "$(pkgx --shellcode)" env +bundle +magick +rsvg-convert diff --git a/Scripts/set-apple-api-env-interactively.sh b/Scripts/set-apple-api-env-interactively.sh new file mode 100755 index 000000000..890fe7c7d --- /dev/null +++ b/Scripts/set-apple-api-env-interactively.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +TEAM_ID="" +KEY_ISSUER_ID="" +KEY_ID="" +APPLE_API_KEY_BASE64="" + +echo "Please provide information related to your Apple account:" +echo +read -rp " TEAM_ID: " TEAM_ID +read -rp " KEY_ISSUER_ID: " KEY_ISSUER_ID +read -rp " KEY_ID: " KEY_ID +read -rp " APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 + +if [[ -z "$TEAM_ID" || -z "$KEY_ISSUER_ID" || -z "$KEY_ID" || -z "$APPLE_API_KEY_BASE64" ]]; then + echo + [[ -z "$TEAM_ID" ]] && echo " TEAM_ID is missing!" + [[ -z "$KEY_ISSUER_ID" ]] && echo " KEY_ISSUER_ID is missing!" + [[ -z "$KEY_ID" ]] && echo " KEY_ID is missing!" + [[ -z "$APPLE_API_KEY_BASE64" ]] && echo " APPLE_API_KEY_BASE64 is missing!" + exit 1 +fi +echo + +export TEAM_ID +export KEY_ISSUER_ID +export KEY_ID +export APPLE_API_KEY_BASE64 \ No newline at end of file From fc0bca4655ec49f04613b191ae8110c275fc1871 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Sat, 14 Dec 2024 13:27:15 +0100 Subject: [PATCH 15/30] Avoid check quality issue https://github.com/pkgxdev/pkgx/issues/1059 --- Scripts/check-quality.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Scripts/check-quality.sh b/Scripts/check-quality.sh index e31a467b5..62906b474 100755 --- a/Scripts/check-quality.sh +++ b/Scripts/check-quality.sh @@ -3,19 +3,24 @@ set -e eval "$(pkgx --shellcode)" -env +swiftlint +rubocop +shellcheck +markdownlint +yamllint echo "... checking Swift code..." +env +swiftlint if [ $# -eq 0 ]; then swiftlint --quiet --strict elif [[ "$1" == "only-changes" ]]; then git diff --staged --name-only | grep ".swift$" | xargs swiftlint lint --quiet --strict fi + echo "... checking Ruby scripts..." -rubocop --format quiet +rm -rf ~/.pkgx/sqlite.org # Avoid https://github.com/pkgxdev/pkgx/issues/1059 +pkgx rubocop --format quiet + echo "... checking Shell scripts..." -shellcheck Scripts/*.sh hooks/* Artifacts/**/*.sh +pkgx shellcheck Scripts/*.sh hooks/* Artifacts/**/*.sh + echo "... checking Markdown documentation..." -markdownlint --ignore fastlane . +pkgx markdownlint --ignore fastlane . + echo "... checking YAML files..." -yamllint .*.yml .github +pkgx yamllint .*.yml .github From 6b7f280ea20509c5592be4e42c631ca768153d11 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Sat, 14 Dec 2024 14:29:03 +0100 Subject: [PATCH 16/30] Improve check-quality script --- Scripts/check-quality.sh | 6 +++--- hooks/pre-commit | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Scripts/check-quality.sh b/Scripts/check-quality.sh index 62906b474..217c5f1c1 100755 --- a/Scripts/check-quality.sh +++ b/Scripts/check-quality.sh @@ -6,10 +6,10 @@ eval "$(pkgx --shellcode)" echo "... checking Swift code..." env +swiftlint -if [ $# -eq 0 ]; then - swiftlint --quiet --strict -elif [[ "$1" == "only-changes" ]]; then +if [[ "$1" == "--only-changes" ]]; then git diff --staged --name-only | grep ".swift$" | xargs swiftlint lint --quiet --strict +else + swiftlint --quiet --strict fi echo "... checking Ruby scripts..." diff --git a/hooks/pre-commit b/hooks/pre-commit index b9a31b506..e68d777fc 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,7 +1,7 @@ #!/bin/sh # Quality check -if Scripts/check-quality.sh only-changes; then +if Scripts/check-quality.sh --only-changes; then echo "✅ Quality checked" else echo "❌ Quality check failed" From 3500098c7c64cd50d2a99755f0df768931855bdf Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Sat, 14 Dec 2024 14:41:18 +0100 Subject: [PATCH 17/30] Simplify server test targets --- Makefile | 6 ------ Scripts/test-streams.sh | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 597811bf7..88933ca04 100644 --- a/Makefile +++ b/Makefile @@ -30,17 +30,11 @@ deliver-demo-release-tvos: .PHONY: test-streams-start test-streams-start: - @Scripts/install-pkgx.sh - @echo "Starting test streams" @Scripts/test-streams.sh -s - @echo "... done.\n" .PHONY: test-streams-stop test-streams-stop: - @Scripts/install-pkgx.sh - @echo "Stopping test streams" @Scripts/test-streams.sh -k - @echo "... done.\n" .PHONY: test-ios test-ios: diff --git a/Scripts/test-streams.sh b/Scripts/test-streams.sh index d3c292836..b49639693 100755 --- a/Scripts/test-streams.sh +++ b/Scripts/test-streams.sh @@ -3,6 +3,7 @@ SCRIPT_NAME=$(basename "$0") SCRIPT_DIR=$(dirname "$0") +Scripts/install-pkgx.sh eval "$(pkgx --shellcode)" env +python +ffmpeg +packager @@ -142,9 +143,11 @@ function usage { while getopts sk OPT; do case "$OPT" in s) + echo "Starting test streams" serve_test_streams "$GENERATED_DIR" ;; k) + echo "Stopping test streams" kill_test_streams "$GENERATED_DIR" ;; *) @@ -153,3 +156,5 @@ while getopts sk OPT; do ;; esac done + +echo "... done" \ No newline at end of file From b038b03fb68e8f82bbb9d38804d9d77b0794e78a Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Sun, 15 Dec 2024 13:05:43 +0100 Subject: [PATCH 18/30] Fix install-bundler script by specifying gem as an environment binary --- Scripts/install-bundler.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Scripts/install-bundler.sh b/Scripts/install-bundler.sh index 96c4c452f..036b4e046 100755 --- a/Scripts/install-bundler.sh +++ b/Scripts/install-bundler.sh @@ -2,7 +2,11 @@ set -e +eval "$(pkgx --shellcode)" + +env +gem +bundle + echo "Installing bundler..." -pkgx bundle config set path '.bundle' -pkgx bundle install +bundle config set path '.bundle' +bundle install echo "... done." From 5b0668bf33d206a1cbf85c97f2cf154201189958 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Sun, 15 Dec 2024 13:06:38 +0100 Subject: [PATCH 19/30] Introduce dedicated script for tests --- Makefile | 16 ++-------------- Scripts/test.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 14 deletions(-) create mode 100755 Scripts/test.sh diff --git a/Makefile b/Makefile index 88933ca04..6f7c0bc5f 100644 --- a/Makefile +++ b/Makefile @@ -38,23 +38,11 @@ test-streams-stop: .PHONY: test-ios test-ios: - @Scripts/install-pkgx.sh - @Scripts/install-bundler.sh - @echo "Running unit tests..." - @Scripts/test-streams.sh -s - @pkgx bundle exec fastlane test_ios - @Scripts/test-streams.sh -k - @echo "... done.\n" + @Scripts/test.sh --platform ios .PHONY: test-tvos test-tvos: - @Scripts/install-pkgx.sh - @Scripts/install-bundler.sh - @echo "Running unit tests..." - @Scripts/test-streams.sh -s - @pkgx bundle exec fastlane test_tvos - @Scripts/test-streams.sh -k - @echo "... done.\n" + @Scripts/test.sh --platform tvos .PHONY: check-quality check-quality: diff --git a/Scripts/test.sh b/Scripts/test.sh new file mode 100755 index 000000000..658376505 --- /dev/null +++ b/Scripts/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -e + +function usage { + echo + echo "[!] Usage: $0 --platform [ios | tvos]" + echo + exit 1 +} + +if [[ "$1" != "--platform" ]]; then + usage +fi + +PLATFORM="$2" +if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then + usage +fi + +Scripts/test-streams.sh -s + +Scripts/install-pkgx.sh +Scripts/install-bundler.sh + +echo "Running unit tests..." +pkgx +xcodes bundle exec fastlane "test_$PLATFORM" +echo "... done." + +Scripts/test-streams.sh -k \ No newline at end of file From 6db834bc20e2591fc9b3b325f56c6f0e401899b8 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:47:01 +0100 Subject: [PATCH 20/30] Simplify check-quality target --- Makefile | 3 --- Scripts/check-quality.sh | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6f7c0bc5f..00b360afe 100644 --- a/Makefile +++ b/Makefile @@ -46,10 +46,7 @@ test-tvos: .PHONY: check-quality check-quality: - @Scripts/install-pkgx.sh - @echo "Checking quality..." @Scripts/check-quality.sh - @echo "... done.\n" .PHONY: fix-quality fix-quality: diff --git a/Scripts/check-quality.sh b/Scripts/check-quality.sh index 217c5f1c1..e53ea399c 100755 --- a/Scripts/check-quality.sh +++ b/Scripts/check-quality.sh @@ -2,6 +2,10 @@ set -e +echo "Checking quality..." + +Scripts/install-pkgx.sh + eval "$(pkgx --shellcode)" echo "... checking Swift code..." @@ -24,3 +28,5 @@ pkgx markdownlint --ignore fastlane . echo "... checking YAML files..." pkgx yamllint .*.yml .github + +echo "...done" \ No newline at end of file From 75ed65718e719410ebc55a2ce01fb9f35a24f898 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:50:19 +0100 Subject: [PATCH 21/30] Harmonize done messages --- Scripts/archive-demo.sh | 2 +- Scripts/check-quality.sh | 2 +- Scripts/deliver-demo.sh | 2 +- Scripts/test-streams.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh index 43c499aae..505405fdf 100755 --- a/Scripts/archive-demo.sh +++ b/Scripts/archive-demo.sh @@ -40,4 +40,4 @@ Scripts/install-pkgx.sh Scripts/install-bundler.sh pkgx bundle exec fastlane "archive_demo_$PLATFORM" -echo "... done" \ No newline at end of file +echo "... done." \ No newline at end of file diff --git a/Scripts/check-quality.sh b/Scripts/check-quality.sh index e53ea399c..e44b19734 100755 --- a/Scripts/check-quality.sh +++ b/Scripts/check-quality.sh @@ -29,4 +29,4 @@ pkgx markdownlint --ignore fastlane . echo "... checking YAML files..." pkgx yamllint .*.yml .github -echo "...done" \ No newline at end of file +echo "... done." \ No newline at end of file diff --git a/Scripts/deliver-demo.sh b/Scripts/deliver-demo.sh index 7ec3d7b07..5908fd18d 100755 --- a/Scripts/deliver-demo.sh +++ b/Scripts/deliver-demo.sh @@ -51,4 +51,4 @@ eval "$(pkgx --shellcode)" env +bundle +magick +rsvg-convert bundle exec fastlane "deliver_demo_${CONFIGURATION}_${PLATFORM}" -echo "... done" \ No newline at end of file +echo "... done." \ No newline at end of file diff --git a/Scripts/test-streams.sh b/Scripts/test-streams.sh index b49639693..2078153e9 100755 --- a/Scripts/test-streams.sh +++ b/Scripts/test-streams.sh @@ -157,4 +157,4 @@ while getopts sk OPT; do esac done -echo "... done" \ No newline at end of file +echo "... done." \ No newline at end of file From 08c8db671e89ab0856b8d43bfb6107787753256d Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:55:49 +0100 Subject: [PATCH 22/30] Simplify fix-quality target --- Makefile | 3 --- Scripts/fix-quality.sh | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 00b360afe..1355d7e5f 100644 --- a/Makefile +++ b/Makefile @@ -50,10 +50,7 @@ check-quality: .PHONY: fix-quality fix-quality: - @Scripts/install-pkgx.sh - @echo "Fixing quality..." @Scripts/fix-quality.sh - @echo "... done.\n" .PHONY: git-hook-install git-hook-install: diff --git a/Scripts/fix-quality.sh b/Scripts/fix-quality.sh index 270647ef5..024c35375 100755 --- a/Scripts/fix-quality.sh +++ b/Scripts/fix-quality.sh @@ -2,7 +2,11 @@ set -e +Scripts/install-pkgx.sh + eval "$(pkgx --shellcode)" env +swiftlint +echo "Fixing quality..." swiftlint --fix && swiftlint +echo "... done." \ No newline at end of file From 1e618cab404ca055a46c05ed3564b2dea6e25daa Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:57:41 +0100 Subject: [PATCH 23/30] Remove unused/useless target --- Makefile | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Makefile b/Makefile index 1355d7e5f..3b4a2a047 100644 --- a/Makefile +++ b/Makefile @@ -64,15 +64,6 @@ git-hook-uninstall: @git config --unset core.hooksPath @echo "... done.\n" -.PHONY: spm-reload -spm-reload: - @echo "Remove dependencies..." - @swift package reset - @echo "... done.\n" - @echo "Reload dependencies..." - @swift package update - @echo "... done.\n" - .PHONY: clean-imports clean-imports: @echo "Cleaning imports..." @@ -125,7 +116,6 @@ help: @echo " git-hook-uninstall Revert to default hooks" @echo @echo "Utilities:" - @echo " spm-reload Reload SPM dependencies" @echo " clean-imports Remove unused imports" @echo " find-dead-code Locate dead code" @echo From 13872ee49a097fb24a3f9306bf513f3744fe01a7 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Thu, 19 Dec 2024 06:59:38 +0100 Subject: [PATCH 24/30] Move clean imports script to a dedicated file --- Makefile | 8 +------- Scripts/clean-imports.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100755 Scripts/clean-imports.sh diff --git a/Makefile b/Makefile index 3b4a2a047..59c9622e2 100644 --- a/Makefile +++ b/Makefile @@ -66,13 +66,7 @@ git-hook-uninstall: .PHONY: clean-imports clean-imports: - @echo "Cleaning imports..." - @mkdir -p .build - @xcodebuild -scheme Pillarbox -destination generic/platform=ios > ./.build/xcodebuild.log - @pkgx swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log - @xcodebuild -scheme Pillarbox-demo -project ./Demo/Pillarbox-demo.xcodeproj -destination generic/platform=iOS > ./.build/xcodebuild.log - @pkgx swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log - @echo "... done.\n" + @Scripts/clean-imports.sh .PHONY: find-dead-code find-dead-code: diff --git a/Scripts/clean-imports.sh b/Scripts/clean-imports.sh new file mode 100755 index 000000000..51d7fcf8b --- /dev/null +++ b/Scripts/clean-imports.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Cleaning imports..." +mkdir -p .build +xcodebuild -scheme Pillarbox -destination generic/platform=ios > ./.build/xcodebuild.log +pkgx swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log +xcodebuild -scheme Pillarbox-demo -project ./Demo/Pillarbox-demo.xcodeproj -destination generic/platform=iOS > ./.build/xcodebuild.log +pkgx swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log +echo "... done." \ No newline at end of file From a5b3e2b73c739757e99e19a9f1fc7f0a10a26c4a Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Thu, 19 Dec 2024 07:02:33 +0100 Subject: [PATCH 25/30] Move find dead code script in a dedicated file --- Makefile | 8 +------- Scripts/find-dead-code.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100755 Scripts/find-dead-code.sh diff --git a/Makefile b/Makefile index 59c9622e2..28e13a5fe 100644 --- a/Makefile +++ b/Makefile @@ -70,13 +70,7 @@ clean-imports: .PHONY: find-dead-code find-dead-code: - @echo "Start checking dead code..." - @mkdir -p .build - @xcodebuild -scheme Pillarbox -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null - @pkgx periphery scan --retain-public --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ - @xcodebuild -scheme Pillarbox-demo -project ./Demo/Pillarbox-demo.xcodeproj -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null - @pkgx periphery scan --project ./Demo/Pillarbox-demo.xcodeproj --schemes Pillarbox-demo --targets Pillarbox-demo --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ - @echo "... done.\n" + @Scripts/find-dead-code.sh .PHONY: help help: diff --git a/Scripts/find-dead-code.sh b/Scripts/find-dead-code.sh new file mode 100755 index 000000000..d349300f7 --- /dev/null +++ b/Scripts/find-dead-code.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Start checking dead code..." +mkdir -p .build +xcodebuild -scheme Pillarbox -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null +pkgx periphery scan --retain-public --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ +xcodebuild -scheme Pillarbox-demo -project ./Demo/Pillarbox-demo.xcodeproj -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null +pkgx periphery scan --project ./Demo/Pillarbox-demo.xcodeproj --schemes Pillarbox-demo --targets Pillarbox-demo --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ +echo "... done." \ No newline at end of file From e9e04df8b07e6101b0be5c6f4e23c3eab0022d52 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Thu, 19 Dec 2024 07:19:47 +0100 Subject: [PATCH 26/30] Move git hooks Makefile scripts in a dedicated files --- Makefile | 8 ++------ Scripts/git-hooks.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100755 Scripts/git-hooks.sh diff --git a/Makefile b/Makefile index 28e13a5fe..210958f6e 100644 --- a/Makefile +++ b/Makefile @@ -54,15 +54,11 @@ fix-quality: .PHONY: git-hook-install git-hook-install: - @echo "Installing git hooks..." - @git config core.hooksPath hooks - @echo "... done.\n" + @Scripts/git-hooks.sh --install .PHONY: git-hook-uninstall git-hook-uninstall: - @echo "Uninstalling git hooks..." - @git config --unset core.hooksPath - @echo "... done.\n" + @Scripts/git-hooks.sh --uninstall .PHONY: clean-imports clean-imports: diff --git a/Scripts/git-hooks.sh b/Scripts/git-hooks.sh new file mode 100755 index 000000000..fd83555ef --- /dev/null +++ b/Scripts/git-hooks.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [[ $1 == '--install' ]]; then + echo "Installing git hooks..." + git config core.hooksPath hooks + echo "... done." +elif [[ $1 == '--uninstall' ]]; then + echo "Uninstalling git hooks..." + git config --unset core.hooksPath + echo "... done." +else + echo "[!] Usage: $0 [--install | --uninstall]" +fi \ No newline at end of file From 5a0e9f5cdf242deee55a133018a1ab7e1b49840d Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:48:36 +0100 Subject: [PATCH 27/30] Improve scripts --- .github/workflows/ci.yml | 6 +- .github/workflows/nightlies.yml | 7 +-- .github/workflows/releases.yml | 7 +-- Makefile | 59 +++++-------------- Scripts/archive-demo.sh | 43 -------------- Scripts/check-quality.sh | 32 ---------- Scripts/deliver-demo.sh | 54 ----------------- Scripts/find-dead-code.sh | 9 --- Scripts/fix-quality.sh | 12 ---- Scripts/git-hooks.sh | 13 ---- Scripts/install-bundler.sh | 12 ---- Scripts/install-pkgx.sh | 7 --- .../{ => private}/add-apple-certificate.sh | 0 Scripts/private/archive-demo.sh | 43 ++++++++++++++ .../{ => private}/configure-environment.sh | 0 Scripts/private/deliver-demo.sh | 46 +++++++++++++++ Scripts/private/fix-quality.sh | 15 +++++ .../set-apple-api-env-interactively.sh | 0 Scripts/public/check-quality.sh | 54 +++++++++++++++++ Scripts/{ => public}/clean-imports.sh | 12 +++- Scripts/public/find-dead-code.sh | 17 ++++++ Scripts/public/git-hooks.sh | 33 +++++++++++ Scripts/{ => public}/test-streams.sh | 37 +++++++----- Scripts/public/test.sh | 43 ++++++++++++++ Scripts/test.sh | 30 ---------- hooks/pre-commit | 2 +- 26 files changed, 306 insertions(+), 287 deletions(-) delete mode 100755 Scripts/archive-demo.sh delete mode 100755 Scripts/check-quality.sh delete mode 100755 Scripts/deliver-demo.sh delete mode 100755 Scripts/find-dead-code.sh delete mode 100755 Scripts/fix-quality.sh delete mode 100755 Scripts/git-hooks.sh delete mode 100755 Scripts/install-bundler.sh delete mode 100755 Scripts/install-pkgx.sh rename Scripts/{ => private}/add-apple-certificate.sh (100%) create mode 100755 Scripts/private/archive-demo.sh rename Scripts/{ => private}/configure-environment.sh (100%) create mode 100755 Scripts/private/deliver-demo.sh create mode 100755 Scripts/private/fix-quality.sh rename Scripts/{ => private}/set-apple-api-env-interactively.sh (100%) create mode 100755 Scripts/public/check-quality.sh rename Scripts/{ => public}/clean-imports.sh (51%) create mode 100755 Scripts/public/find-dead-code.sh create mode 100755 Scripts/public/git-hooks.sh rename Scripts/{ => public}/test-streams.sh (93%) create mode 100755 Scripts/public/test.sh delete mode 100755 Scripts/test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 447ccc136..9afe74c93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Add Apple certificate run: | - Scripts/add-apple-certificate.sh \ + Scripts/private/add-apple-certificate.sh \ $RUNNER_TEMP \ ${{ secrets.KEYCHAIN_PASSWORD }} \ ${{ secrets.APPLE_DEV_CERTIFICATE }} \ @@ -59,11 +59,11 @@ jobs: - name: Configure environment run: | - Scripts/configure-environment.sh \ + Scripts/private/configure-environment.sh \ ${{ secrets.APP_STORE_CONNECT_API_KEY }} - name: Archive the demo - run: make archive-demo-${{ matrix.platform }} MODE="--non-interactive" + run: Scripts/private/archive-demo.sh -p ${{ matrix.platform }} env: TEAM_ID: ${{ secrets.TEAM_ID }} KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} diff --git a/.github/workflows/nightlies.yml b/.github/workflows/nightlies.yml index bde9bdaa9..ac6710982 100644 --- a/.github/workflows/nightlies.yml +++ b/.github/workflows/nightlies.yml @@ -21,7 +21,7 @@ jobs: - name: Add Apple certificate run: | - Scripts/add-apple-certificate.sh \ + Scripts/private/add-apple-certificate.sh \ $RUNNER_TEMP \ ${{ secrets.KEYCHAIN_PASSWORD }} \ ${{ secrets.APPLE_DEV_CERTIFICATE }} \ @@ -29,13 +29,12 @@ jobs: - name: Configure environment run: | - Scripts/configure-environment.sh \ + Scripts/private/configure-environment.sh \ ${{ secrets.APP_STORE_CONNECT_API_KEY }} - name: Deliver the demo run: | - make deliver-demo-nightly-${{ matrix.platform }} \ - MODE="--non-interactive" + Scripts/private/deliver-demo.sh -p ${{ matrix.platform }} -c nightly env: TEAM_ID: ${{ secrets.TEAM_ID }} KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index acdff5d03..46110d944 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -21,7 +21,7 @@ jobs: - name: Add Apple certificate run: | - Scripts/add-apple-certificate.sh \ + Scripts/private/add-apple-certificate.sh \ $RUNNER_TEMP \ ${{ secrets.KEYCHAIN_PASSWORD }} \ ${{ secrets.APPLE_DEV_CERTIFICATE }} \ @@ -29,13 +29,12 @@ jobs: - name: Configure environment run: | - Scripts/configure-environment.sh \ + Scripts/private/configure-environment.sh \ ${{ secrets.APP_STORE_CONNECT_API_KEY }} - name: Deliver the demo run: | - make deliver-demo-release-${{ matrix.platform }} \ - MODE="--non-interactive" + Scripts/private/deliver-demo.sh -p ${{ matrix.platform }} -c release env: TEAM_ID: ${{ secrets.TEAM_ID }} KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} diff --git a/Makefile b/Makefile index 210958f6e..cda4ce04e 100644 --- a/Makefile +++ b/Makefile @@ -3,70 +3,49 @@ .PHONY: all all: help - -.PHONY: archive-demo-ios -archive-demo-ios: - @Scripts/archive-demo.sh $(MODE) --platform ios - -.PHONY: archive-demo-tvos -archive-demo-tvos: - @Scripts/archive-demo.sh $(MODE) --platform tvos - -.PHONY: deliver-demo-nightly-ios -deliver-demo-nightly-ios: - @Scripts/deliver-demo.sh $(MODE) --platform ios --configuration nightly - -.PHONY: deliver-demo-nightly-tvos -deliver-demo-nightly-tvos: - @Scripts/deliver-demo.sh $(MODE) --platform tvos --configuration nightly - -.PHONY: deliver-demo-release-ios -deliver-demo-release-ios: - @Scripts/deliver-demo.sh $(MODE) --platform ios --configuration release - -.PHONY: deliver-demo-release-tvos install-bundler -deliver-demo-release-tvos: - @Scripts/deliver-demo.sh $(MODE) --platform tvos --configuration release - .PHONY: test-streams-start test-streams-start: - @Scripts/test-streams.sh -s + @Scripts/public/test-streams.sh -s .PHONY: test-streams-stop test-streams-stop: - @Scripts/test-streams.sh -k + @Scripts/public/test-streams.sh -k .PHONY: test-ios test-ios: - @Scripts/test.sh --platform ios + @Scripts/public/test-streams.sh -s + @Scripts/public/test.sh -p ios + @Scripts/public/test-streams.sh -k .PHONY: test-tvos test-tvos: - @Scripts/test.sh --platform tvos + @Scripts/public/test-streams.sh -s + @Scripts/public/test.sh -p tvos + @Scripts/public/test-streams.sh -k .PHONY: check-quality check-quality: - @Scripts/check-quality.sh + @Scripts/public/check-quality.sh .PHONY: fix-quality fix-quality: - @Scripts/fix-quality.sh + @Scripts/public/fix-quality.sh .PHONY: git-hook-install git-hook-install: - @Scripts/git-hooks.sh --install + @Scripts/public/git-hooks.sh -i .PHONY: git-hook-uninstall git-hook-uninstall: - @Scripts/git-hooks.sh --uninstall + @Scripts/public/git-hooks.sh -u .PHONY: clean-imports clean-imports: - @Scripts/clean-imports.sh + @Scripts/public/clean-imports.sh .PHONY: find-dead-code find-dead-code: - @Scripts/find-dead-code.sh + @Scripts/public/find-dead-code.sh .PHONY: help help: @@ -75,16 +54,6 @@ help: @echo "Default:" @echo " all Default target" @echo - @echo "Archive:" - @echo " archive-demo-ios Archive iOS demo [MODE=\"--non-interactive\"]" - @echo " archive-demo-tvos Archive tvOS demo [MODE=\"--non-interactive\"]" - @echo - @echo "Deliver:" - @echo " deliver-demo-nightly-ios Deliver nightly iOS demo build [MODE=\"--non-interactive\"]" - @echo " deliver-demo-nightly-tvos Deliver nightly tvOS demo build [MODE=\"--non-interactive\"]" - @echo " deliver-demo-release-ios Deliver release iOS demo build [MODE=\"--non-interactive\"]" - @echo " deliver-demo-release-tvos Deliver release tvOS demo build [MODE=\"--non-interactive\"]" - @echo @echo "Test:" @echo " test-streams-start Start test streams" @echo " test-streams-stop Stop test streams" diff --git a/Scripts/archive-demo.sh b/Scripts/archive-demo.sh deleted file mode 100755 index 505405fdf..000000000 --- a/Scripts/archive-demo.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -set -e - -function usage { - echo - echo "[!] Usage: $0 [--non-interactive] --platform [ios | tvos]" - echo - echo " Params:" - echo " --non-interactive: (Optional) Avoid setting the ENV variables interactively (interactive by default)." - echo " --platform: (Required) Platform for which to archive the demo." - echo - exit 1 -} - -PLATFORM="" -IS_INTERACTIVE=true - -if [[ $1 == "--non-interactive" && $2 == "--platform" ]]; then - IS_INTERACTIVE=false - PLATFORM="$3" -elif [[ $1 == "--platform" ]]; then - PLATFORM="$2" -else - usage -fi - -if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then - usage -fi - -echo -e "Archiving $PLATFORM demo..." - -if [[ $IS_INTERACTIVE == true ]]; then - source Scripts/set-apple-api-env-interactively.sh - Scripts/configure-environment.sh "$APPLE_API_KEY_BASE64" -fi - -Scripts/install-pkgx.sh -Scripts/install-bundler.sh - -pkgx bundle exec fastlane "archive_demo_$PLATFORM" -echo "... done." \ No newline at end of file diff --git a/Scripts/check-quality.sh b/Scripts/check-quality.sh deleted file mode 100755 index e44b19734..000000000 --- a/Scripts/check-quality.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -set -e - -echo "Checking quality..." - -Scripts/install-pkgx.sh - -eval "$(pkgx --shellcode)" - -echo "... checking Swift code..." -env +swiftlint -if [[ "$1" == "--only-changes" ]]; then - git diff --staged --name-only | grep ".swift$" | xargs swiftlint lint --quiet --strict -else - swiftlint --quiet --strict -fi - -echo "... checking Ruby scripts..." -rm -rf ~/.pkgx/sqlite.org # Avoid https://github.com/pkgxdev/pkgx/issues/1059 -pkgx rubocop --format quiet - -echo "... checking Shell scripts..." -pkgx shellcheck Scripts/*.sh hooks/* Artifacts/**/*.sh - -echo "... checking Markdown documentation..." -pkgx markdownlint --ignore fastlane . - -echo "... checking YAML files..." -pkgx yamllint .*.yml .github - -echo "... done." \ No newline at end of file diff --git a/Scripts/deliver-demo.sh b/Scripts/deliver-demo.sh deleted file mode 100755 index 5908fd18d..000000000 --- a/Scripts/deliver-demo.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -set -e - -function usage { - echo - echo "[!] Usage: $0 [--non-interactive] --platform [ios | tvos] --configuration [nightly | release]" - echo - echo " Params:" - echo " --non-interactive: (Optional) Avoid setting the ENV variables interactively (interactive by default)." - echo " --platform: (Required) Platform for which to deliver the demo." - echo " --configuration: (Required) Configuration for which to deliver the demo." - echo - exit 1 -} - -PLATFORM="" -CONFIGURATION="" -IS_INTERACTIVE=true - -if [[ $1 == "--non-interactive" && $2 == "--platform" && $4 == "--configuration" ]]; then - IS_INTERACTIVE=false - PLATFORM="$3" - CONFIGURATION="$5" -elif [[ $1 == "--platform" && $3 == "--configuration" ]]; then - PLATFORM="$2" - CONFIGURATION="$4" -else - usage -fi - -if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then - usage -fi - -if [[ $CONFIGURATION != "nightly" && $CONFIGURATION != "release" ]]; then - usage -fi - -echo -e "Delivering demo $CONFIGURATION build for $PLATFORM..." - -if [[ $IS_INTERACTIVE == true ]]; then - source Scripts/set-apple-api-env-interactively.sh - Scripts/configure-environment.sh "$APPLE_API_KEY_BASE64" -fi - -Scripts/install-pkgx.sh -Scripts/install-bundler.sh - -eval "$(pkgx --shellcode)" -env +bundle +magick +rsvg-convert - -bundle exec fastlane "deliver_demo_${CONFIGURATION}_${PLATFORM}" -echo "... done." \ No newline at end of file diff --git a/Scripts/find-dead-code.sh b/Scripts/find-dead-code.sh deleted file mode 100755 index d349300f7..000000000 --- a/Scripts/find-dead-code.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -echo "Start checking dead code..." -mkdir -p .build -xcodebuild -scheme Pillarbox -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null -pkgx periphery scan --retain-public --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ -xcodebuild -scheme Pillarbox-demo -project ./Demo/Pillarbox-demo.xcodeproj -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null -pkgx periphery scan --project ./Demo/Pillarbox-demo.xcodeproj --schemes Pillarbox-demo --targets Pillarbox-demo --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ -echo "... done." \ No newline at end of file diff --git a/Scripts/fix-quality.sh b/Scripts/fix-quality.sh deleted file mode 100755 index 024c35375..000000000 --- a/Scripts/fix-quality.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -Scripts/install-pkgx.sh - -eval "$(pkgx --shellcode)" -env +swiftlint - -echo "Fixing quality..." -swiftlint --fix && swiftlint -echo "... done." \ No newline at end of file diff --git a/Scripts/git-hooks.sh b/Scripts/git-hooks.sh deleted file mode 100755 index fd83555ef..000000000 --- a/Scripts/git-hooks.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -if [[ $1 == '--install' ]]; then - echo "Installing git hooks..." - git config core.hooksPath hooks - echo "... done." -elif [[ $1 == '--uninstall' ]]; then - echo "Uninstalling git hooks..." - git config --unset core.hooksPath - echo "... done." -else - echo "[!] Usage: $0 [--install | --uninstall]" -fi \ No newline at end of file diff --git a/Scripts/install-bundler.sh b/Scripts/install-bundler.sh deleted file mode 100755 index 036b4e046..000000000 --- a/Scripts/install-bundler.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -eval "$(pkgx --shellcode)" - -env +gem +bundle - -echo "Installing bundler..." -bundle config set path '.bundle' -bundle install -echo "... done." diff --git a/Scripts/install-pkgx.sh b/Scripts/install-pkgx.sh deleted file mode 100755 index 35036b3fc..000000000 --- a/Scripts/install-pkgx.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -echo "Installing pkgx..." -curl -Ssf https://pkgx.sh | sh &> /dev/null -echo "... done." diff --git a/Scripts/add-apple-certificate.sh b/Scripts/private/add-apple-certificate.sh similarity index 100% rename from Scripts/add-apple-certificate.sh rename to Scripts/private/add-apple-certificate.sh diff --git a/Scripts/private/archive-demo.sh b/Scripts/private/archive-demo.sh new file mode 100755 index 000000000..9d85bd92c --- /dev/null +++ b/Scripts/private/archive-demo.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +function usage { + echo + echo "Usage: $0 -p [ios | tvos]" + echo + exit 1 +} + +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +bundle +} + +if [[ -z "$1" ]]; then + usage +fi + +while getopts p: OPT; do + case "$OPT" in + p) + PLATFORM=$OPTARG + ;; + *) + usage + ;; + esac +done + +if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then + usage +fi + +install_tools + +echo -e "Archiving $PLATFORM demo..." +bundle config set path '.bundle' +bundle install +bundle exec fastlane "archive_demo_$PLATFORM" +echo "... done." \ No newline at end of file diff --git a/Scripts/configure-environment.sh b/Scripts/private/configure-environment.sh similarity index 100% rename from Scripts/configure-environment.sh rename to Scripts/private/configure-environment.sh diff --git a/Scripts/private/deliver-demo.sh b/Scripts/private/deliver-demo.sh new file mode 100755 index 000000000..eb3aa967e --- /dev/null +++ b/Scripts/private/deliver-demo.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -e + +function usage { + echo + echo "Usage: $0 -p [ios | tvos] -c [nightly | release]" + echo + exit 1 +} + +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +bundle +magick +rsvg-convert +} + +while getopts p:c: OPT; do + case "$OPT" in + p) + PLATFORM=$OPTARG + ;; + c) + CONFIGURATION=$OPTARG + ;; + *) + usage + ;; + esac +done + +if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then + usage +fi + +if [[ $CONFIGURATION != "nightly" && $CONFIGURATION != "release" ]]; then + usage +fi + +install_tools + +echo -e "Delivering demo $CONFIGURATION build for $PLATFORM..." +bundle config set path '.bundle' +bundle install +bundle exec fastlane "deliver_demo_${CONFIGURATION}_${PLATFORM}" +echo "... done." \ No newline at end of file diff --git a/Scripts/private/fix-quality.sh b/Scripts/private/fix-quality.sh new file mode 100755 index 000000000..64a8a741e --- /dev/null +++ b/Scripts/private/fix-quality.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +swiftlint +} + +install_tools + +echo "Fixing quality..." +swiftlint --fix && swiftlint +echo "... done." \ No newline at end of file diff --git a/Scripts/set-apple-api-env-interactively.sh b/Scripts/private/set-apple-api-env-interactively.sh similarity index 100% rename from Scripts/set-apple-api-env-interactively.sh rename to Scripts/private/set-apple-api-env-interactively.sh diff --git a/Scripts/public/check-quality.sh b/Scripts/public/check-quality.sh new file mode 100755 index 000000000..44dcd3420 --- /dev/null +++ b/Scripts/public/check-quality.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -e + +function usage { + echo + echo "Usage: $0 [OPTION]" + echo " -c check only changes." + echo + exit 1 +} + +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +swiftlint +shellcheck +markdownlint +} + +while getopts c OPT; do + case "$OPT" in + c) + ONLY_CHANGES=true + ;; + *) + usage + ;; + esac +done + +install_tools + +echo "Checking quality..." + +echo "... checking Swift code..." +if [[ "$ONLY_CHANGES" == true ]]; then + git diff --staged --name-only | grep ".swift$" | xargs swiftlint lint --quiet --strict +else + swiftlint --quiet --strict +fi + +echo "... checking Ruby scripts..." +rm -rf ~/.pkgx/sqlite.org # Avoid https://github.com/pkgxdev/pkgx/issues/1059 +pkgx rubocop --format quiet + +echo "... checking Shell scripts..." +shellcheck Scripts/**/*.sh hooks/* Artifacts/**/*.sh + +echo "... checking Markdown documentation..." +markdownlint --ignore fastlane . + +echo "... checking YAML files..." +pkgx yamllint .*.yml .github + +echo "... done." \ No newline at end of file diff --git a/Scripts/clean-imports.sh b/Scripts/public/clean-imports.sh similarity index 51% rename from Scripts/clean-imports.sh rename to Scripts/public/clean-imports.sh index 51d7fcf8b..e30f9da82 100755 --- a/Scripts/clean-imports.sh +++ b/Scripts/public/clean-imports.sh @@ -1,9 +1,17 @@ #!/bin/bash +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +swiftlint +} + +install_tools + echo "Cleaning imports..." mkdir -p .build xcodebuild -scheme Pillarbox -destination generic/platform=ios > ./.build/xcodebuild.log -pkgx swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log +swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log xcodebuild -scheme Pillarbox-demo -project ./Demo/Pillarbox-demo.xcodeproj -destination generic/platform=iOS > ./.build/xcodebuild.log -pkgx swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log +swiftlint analyze --fix --compiler-log-path ./.build/xcodebuild.log echo "... done." \ No newline at end of file diff --git a/Scripts/public/find-dead-code.sh b/Scripts/public/find-dead-code.sh new file mode 100755 index 000000000..f2e722db6 --- /dev/null +++ b/Scripts/public/find-dead-code.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +periphery +} + +install_tools + +echo "Start checking dead code..." +mkdir -p .build +xcodebuild -scheme Pillarbox -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null +periphery scan --retain-public --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ +xcodebuild -scheme Pillarbox-demo -project ./Demo/Pillarbox-demo.xcodeproj -destination generic/platform=iOS -derivedDataPath ./.build/derived-data clean build &> /dev/null +periphery scan --project ./Demo/Pillarbox-demo.xcodeproj --schemes Pillarbox-demo --targets Pillarbox-demo --skip-build --index-store-path ./.build/derived-data/Index.noindex/DataStore/ +echo "... done." \ No newline at end of file diff --git a/Scripts/public/git-hooks.sh b/Scripts/public/git-hooks.sh new file mode 100755 index 000000000..b3a9c2b2c --- /dev/null +++ b/Scripts/public/git-hooks.sh @@ -0,0 +1,33 @@ +#!/bin/bash + + +function usage { + echo + echo "Usage: $0 [OPTION]" + echo " -i install git hooks." + echo " -u uninstall git hooks." + echo + exit 1 +} + +if [[ -z "$1" ]]; then + usage +fi + +while getopts iu OPT; do + case "$OPT" in + i) + echo "Installing git hooks..." + git config core.hooksPath hooks + echo "... done." + ;; + u) + echo "Uninstalling git hooks..." + git config --unset core.hooksPath + echo "... done." + ;; + *) + usage + ;; + esac +done \ No newline at end of file diff --git a/Scripts/test-streams.sh b/Scripts/public/test-streams.sh similarity index 93% rename from Scripts/test-streams.sh rename to Scripts/public/test-streams.sh index 2078153e9..a6697e851 100755 --- a/Scripts/test-streams.sh +++ b/Scripts/public/test-streams.sh @@ -1,12 +1,7 @@ #!/bin/bash -SCRIPT_NAME=$(basename "$0") SCRIPT_DIR=$(dirname "$0") -Scripts/install-pkgx.sh -eval "$(pkgx --shellcode)" -env +python +ffmpeg +packager - GENERATED_DIR="/tmp/pillarbox" METADATA_DIR="$SCRIPT_DIR/../metadata" @@ -131,30 +126,40 @@ function kill_test_streams { } function usage { - echo "Generate test streams and manage an HTTP server to serve them locally." - echo "" - echo "Usage: $SCRIPT_NAME [-s] [-k]" - echo "" - echo "Options:" - echo " -s: Start serving test streams." - echo " -k: Kill the server." + echo + echo "Usage: $0 [OPTION]" + echo " -s start serving test streams." + echo " -k kill the server." + echo + exit 1 +} + +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +python +ffmpeg +packager } +if [[ -z "$1" ]]; then + usage +fi + while getopts sk OPT; do case "$OPT" in s) echo "Starting test streams" + install_tools serve_test_streams "$GENERATED_DIR" + echo "... done." ;; k) echo "Stopping test streams" + install_tools kill_test_streams "$GENERATED_DIR" + echo "... done." ;; *) usage - exit 1 ;; esac -done - -echo "... done." \ No newline at end of file +done \ No newline at end of file diff --git a/Scripts/public/test.sh b/Scripts/public/test.sh new file mode 100755 index 000000000..2558632ad --- /dev/null +++ b/Scripts/public/test.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +function usage { + echo + echo "Usage: $0 -p [ios | tvos]" + echo + exit 1 +} + +function install_tools { + curl -Ssf https://pkgx.sh | sh &> /dev/null + eval "$(pkgx --shellcode)" + env +ruby +bundle +xcodes +} + +if [[ -z "$1" ]]; then + usage +fi + +while getopts p: OPT; do + case "$OPT" in + p) + PLATFORM=$OPTARG + ;; + *) + usage + ;; + esac +done + +if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then + usage +fi + +install_tools + +echo "Running unit tests..." +bundle config set path '.bundle' +bundle install +bundle exec fastlane "test_$PLATFORM" +echo "... done." \ No newline at end of file diff --git a/Scripts/test.sh b/Scripts/test.sh deleted file mode 100755 index 658376505..000000000 --- a/Scripts/test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -e - -function usage { - echo - echo "[!] Usage: $0 --platform [ios | tvos]" - echo - exit 1 -} - -if [[ "$1" != "--platform" ]]; then - usage -fi - -PLATFORM="$2" -if [[ $PLATFORM != "ios" && $PLATFORM != "tvos" ]]; then - usage -fi - -Scripts/test-streams.sh -s - -Scripts/install-pkgx.sh -Scripts/install-bundler.sh - -echo "Running unit tests..." -pkgx +xcodes bundle exec fastlane "test_$PLATFORM" -echo "... done." - -Scripts/test-streams.sh -k \ No newline at end of file diff --git a/hooks/pre-commit b/hooks/pre-commit index e68d777fc..b79280206 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,7 +1,7 @@ #!/bin/sh # Quality check -if Scripts/check-quality.sh --only-changes; then +if Scripts/public/check-quality.sh -c; then echo "✅ Quality checked" else echo "❌ Quality check failed" From f8540db8344ff43aa2271b7d8ec7445ea549697b Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:16:04 +0100 Subject: [PATCH 28/30] Remove unused script --- .../set-apple-api-env-interactively.sh | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100755 Scripts/private/set-apple-api-env-interactively.sh diff --git a/Scripts/private/set-apple-api-env-interactively.sh b/Scripts/private/set-apple-api-env-interactively.sh deleted file mode 100755 index 890fe7c7d..000000000 --- a/Scripts/private/set-apple-api-env-interactively.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -TEAM_ID="" -KEY_ISSUER_ID="" -KEY_ID="" -APPLE_API_KEY_BASE64="" - -echo "Please provide information related to your Apple account:" -echo -read -rp " TEAM_ID: " TEAM_ID -read -rp " KEY_ISSUER_ID: " KEY_ISSUER_ID -read -rp " KEY_ID: " KEY_ID -read -rp " APPLE_API_KEY_BASE64: " APPLE_API_KEY_BASE64 - -if [[ -z "$TEAM_ID" || -z "$KEY_ISSUER_ID" || -z "$KEY_ID" || -z "$APPLE_API_KEY_BASE64" ]]; then - echo - [[ -z "$TEAM_ID" ]] && echo " TEAM_ID is missing!" - [[ -z "$KEY_ISSUER_ID" ]] && echo " KEY_ISSUER_ID is missing!" - [[ -z "$KEY_ID" ]] && echo " KEY_ID is missing!" - [[ -z "$APPLE_API_KEY_BASE64" ]] && echo " APPLE_API_KEY_BASE64 is missing!" - exit 1 -fi -echo - -export TEAM_ID -export KEY_ISSUER_ID -export KEY_ID -export APPLE_API_KEY_BASE64 \ No newline at end of file From 7e56709fe562b5d6ae306ea6e60f7cc575a652cc Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:23:14 +0100 Subject: [PATCH 29/30] Convert tabs to spaces --- Scripts/public/git-hooks.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Scripts/public/git-hooks.sh b/Scripts/public/git-hooks.sh index b3a9c2b2c..4d32fb16f 100755 --- a/Scripts/public/git-hooks.sh +++ b/Scripts/public/git-hooks.sh @@ -1,6 +1,5 @@ #!/bin/bash - function usage { echo echo "Usage: $0 [OPTION]" @@ -10,21 +9,21 @@ function usage { exit 1 } -if [[ -z "$1" ]]; then - usage +if [[ -z "$1" ]]; then + usage fi while getopts iu OPT; do case "$OPT" in i) - echo "Installing git hooks..." - git config core.hooksPath hooks - echo "... done." + echo "Installing git hooks..." + git config core.hooksPath hooks + echo "... done." ;; u) - echo "Uninstalling git hooks..." - git config --unset core.hooksPath - echo "... done." + echo "Uninstalling git hooks..." + git config --unset core.hooksPath + echo "... done." ;; *) usage From ce0b6acbfec53fea3c0c0a5207698100363bb757 Mon Sep 17 00:00:00 2001 From: Walid Kayhal <3347810+waliid@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:42:46 +0100 Subject: [PATCH 30/30] Fix incorrect metadata directory path --- Scripts/public/test-streams.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/public/test-streams.sh b/Scripts/public/test-streams.sh index a6697e851..8217767b2 100755 --- a/Scripts/public/test-streams.sh +++ b/Scripts/public/test-streams.sh @@ -4,7 +4,7 @@ SCRIPT_DIR=$(dirname "$0") GENERATED_DIR="/tmp/pillarbox" -METADATA_DIR="$SCRIPT_DIR/../metadata" +METADATA_DIR="$SCRIPT_DIR/../../metadata" SUBTITLES_DIR="$METADATA_DIR/subtitles" JSON_DIR="$METADATA_DIR/json"