Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Makefile targets #1104

Merged
merged 30 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6c9835a
Add install-pkgx.sh
waliid Dec 12, 2024
aa34556
Add install-bundler.sh
waliid Dec 12, 2024
621d7e0
Set scripts permissions
waliid Dec 13, 2024
8ab42bd
Move archive-demo target in a dedicated script
waliid Dec 13, 2024
3426d00
Improve Makefile doc
waliid Dec 13, 2024
96d5556
Improve archive-demo.sh
waliid Dec 13, 2024
3d17426
Install pkgx and bundler before running archive
waliid Dec 13, 2024
26701f4
Print more information when the script fails
waliid Dec 13, 2024
2a48330
Use scripts to install pkgx and bundler
waliid Dec 13, 2024
aa3ac2e
Improve archive-demo script
waliid Dec 13, 2024
d38d740
Add deliver-demo script
waliid Dec 13, 2024
98eb6f3
Update nightly and release workflows to use non-interactive Makefile …
waliid Dec 13, 2024
1079732
Update Makefile help
waliid Dec 13, 2024
4340c26
Factorize interactive part
waliid Dec 13, 2024
fc0bca4
Avoid check quality issue
waliid Dec 14, 2024
6b7f280
Improve check-quality script
waliid Dec 14, 2024
3500098
Simplify server test targets
waliid Dec 14, 2024
b038b03
Fix install-bundler script by specifying gem as an environment binary
waliid Dec 15, 2024
5b0668b
Introduce dedicated script for tests
waliid Dec 15, 2024
6db834b
Simplify check-quality target
waliid Dec 16, 2024
75ed657
Harmonize done messages
waliid Dec 16, 2024
08c8db6
Simplify fix-quality target
waliid Dec 16, 2024
1e618ca
Remove unused/useless target
waliid Dec 16, 2024
13872ee
Move clean imports script to a dedicated file
waliid Dec 19, 2024
a5b3e2b
Move find dead code script in a dedicated file
waliid Dec 19, 2024
e9e04df
Move git hooks Makefile scripts in a dedicated files
waliid Dec 19, 2024
5a0e9f5
Improve scripts
waliid Jan 7, 2025
f8540db
Remove unused script
waliid Jan 7, 2025
7e56709
Convert tabs to spaces
waliid Jan 7, 2025
ce0b6ac
Fix incorrect metadata directory path
waliid Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ 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 }} \
${{ secrets.APPLE_DEV_CERTIFICATE_PASSWORD }}

- 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 }}
run: Scripts/private/archive-demo.sh -p ${{ matrix.platform }}
env:
TEAM_ID: ${{ secrets.TEAM_ID }}
KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nightlies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ 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 }} \
${{ secrets.APPLE_DEV_CERTIFICATE_PASSWORD }}

- 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 }}
Scripts/private/deliver-demo.sh -p ${{ matrix.platform }} -c nightly
env:
TEAM_ID: ${{ secrets.TEAM_ID }}
KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ 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 }} \
${{ secrets.APPLE_DEV_CERTIFICATE_PASSWORD }}

- 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 }}
Scripts/private/deliver-demo.sh -p ${{ matrix.platform }} -c release
env:
TEAM_ID: ${{ secrets.TEAM_ID }}
KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
Expand Down
183 changes: 45 additions & 138 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,167 +3,74 @@
.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

.PHONY: archive-demo-tvos
archive-demo-tvos: install-pkgx install-bundler
@pkgx bundle exec fastlane archive_demo_tvos

.PHONY: deliver-demo-nightly-ios
deliver-demo-nightly-ios: install-pkgx install-bundler
@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
@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
@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
@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
@echo "Starting test streams"
@Scripts/test-streams.sh -s
@echo "... done.\n"
test-streams-start:
@Scripts/public/test-streams.sh -s

.PHONY: test-streams-stop
test-streams-stop: install-pkgx
@echo "Stopping test streams"
@Scripts/test-streams.sh -k
@echo "... done.\n"
test-streams-stop:
@Scripts/public/test-streams.sh -k

.PHONY: test-ios
test-ios: install-pkgx install-bundler
@echo "Running unit tests..."
@Scripts/test-streams.sh -s
@pkgx bundle exec fastlane test_ios
@Scripts/test-streams.sh -k
@echo "... done.\n"
test-ios:
@Scripts/public/test-streams.sh -s
@Scripts/public/test.sh -p ios
@Scripts/public/test-streams.sh -k

.PHONY: test-tvos
test-tvos: install-pkgx install-bundler
@echo "Running unit tests..."
@Scripts/test-streams.sh -s
@pkgx bundle exec fastlane test_tvos
@Scripts/test-streams.sh -k
@echo "... done.\n"
test-tvos:
@Scripts/public/test-streams.sh -s
@Scripts/public/test.sh -p tvos
@Scripts/public/test-streams.sh -k

.PHONY: check-quality
check-quality: install-pkgx
@echo "Checking quality..."
@Scripts/check-quality.sh
@echo "... done.\n"
check-quality:
@Scripts/public/check-quality.sh

.PHONY: fix-quality
fix-quality: install-pkgx
@echo "Fixing quality..."
@Scripts/fix-quality.sh
@echo "... done.\n"
fix-quality:
@Scripts/public/fix-quality.sh

.PHONY: git-hook-install
git-hook-install:
@echo "Installing git hooks..."
@git config core.hooksPath hooks
@echo "... done.\n"
@Scripts/public/git-hooks.sh -i

.PHONY: git-hook-uninstall
git-hook-uninstall:
@echo "Uninstalling git hooks..."
@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"
@Scripts/public/git-hooks.sh -u

.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/public/clean-imports.sh

.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/public/find-dead-code.sh

.PHONY: help
help:
@echo "The following targets are available:"
@echo ""
@echo " all Default target"
@echo ""
@echo " fastlane Run fastlane"
@echo ""
@echo " archive-demo-ios Archive the iOS demo (for all configurations)"
@echo " archive-demo-tvos Archive the tvOS demo (for all configurations)"
@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 " 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 " test-streams-start Start servicing test streams"
@echo " test-streams-stop Stop servicing test streams"
@echo ""
@echo " test-ios Build and run unit tests for iOS"
@echo " test-tvos Build and run unit tests for tvOS"
@echo ""
@echo " check-quality Run quality checks"
@echo " fix-quality Fix quality automatically (if possible)"
@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 "Available targets:"
@echo
@echo "Default:"
@echo " all Default target"
@echo
@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 "Quality:"
@echo " check-quality Run quality checks"
@echo " fix-quality Automatically fix quality issues"
@echo
@echo "Git Hooks:"
@echo " git-hook-install Install custom hooks from ./hooks"
@echo " git-hook-uninstall Revert to default hooks"
@echo
@echo "Utilities:"
@echo " clean-imports Remove unused imports"
@echo " find-dead-code Locate dead code"
@echo
@echo "Other:"
@echo " help Show this help message"
21 changes: 0 additions & 21 deletions Scripts/check-quality.sh

This file was deleted.

8 changes: 0 additions & 8 deletions Scripts/fix-quality.sh

This file was deleted.

43 changes: 43 additions & 0 deletions Scripts/private/archive-demo.sh
Original file line number Diff line number Diff line change
@@ -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."
Loading