Skip to content

Commit

Permalink
Improve CI and fix iOS debug build (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaalaniz authored Sep 28, 2023
1 parent e9631ff commit 352d77d
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 15 deletions.
27 changes: 24 additions & 3 deletions .github/actions/setup-lightsaber-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,30 @@ runs:
path: |
androidApp/build
- name: iOS App Build Cache
- name: iOS App Debug iphoneos Build Cache
uses: actions/cache@v3
with:
key: build-ios-${{ github.sha }}
key: build-ios-debug-iphoneos-${{ github.sha }}
path: |
build
iosApp/build/ios/Debug-iphoneos
- name: iOS App Release iphoneos Build Cache
uses: actions/cache@v3
with:
key: build-ios-release-iphoneos-${{ github.sha }}
path: |
iosApp/build/ios/Release-iphoneos
- name: iOS App Debug iphonesimulator Build Cache
uses: actions/cache@v3
with:
key: build-ios-debug-iphonesimulator-${{ github.sha }}
path: |
iosApp/build/ios/Debug-iphonesimulator
- name: iOS App Release iphonesimulator Build Cache
uses: actions/cache@v3
with:
key: build-ios-release-iphonesimulator-${{ github.sha }}
path: |
iosApp/build/ios/Release-iphonesimulator
80 changes: 72 additions & 8 deletions .github/workflows/lightsaber-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Build Shared
# TODO Understand why compileIosMainKotlinMetadata fails every time
run: ./gradlew shared:build -x compileIosMainKotlinMetadata
run: ./gradlew shared:assemble -x compileIosMainKotlinMetadata

build-androidApp:
runs-on: macos-latest
Expand All @@ -32,20 +32,67 @@ jobs:
- name: Build Android App
run: ./gradlew androidApp:build

build-debug-iosApp:
build-iosApp:
runs-on: macos-latest
strategy:
matrix:
configuration: [Debug, Release]
target: [iphonesimulator, iphoneos]
needs: build-shared
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-lightsaber-ci

# Signing Xcode applications
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Shared Pod Install
run: ./gradlew shared:podInstall
run: ./gradlew podInstall

- name: Build iOS App
env:
LIGHTSABER_TEAM_ID: ${{ secrets.LIGHTSABER_TEAM_ID }}
run: |
xcodebuild -workspace ${{ github.workspace }}/iosApp/iosApp.xcworkspace \
-scheme iosApp \
-configuration ${{ matrix.configuration }} \
-xcconfig ${{ github.workspace }}/iosApp/Configuration/Config.xcconfig \
OBJROOT=${{ github.workspace }}/iosApp/build/ios SYMROOT=${{ github.workspace }}/iosApp/build/ios \
-sdk ${{ matrix.target }}
# TODO Setup xcodebuild command correctly
# - name: Build Debug iOS App
# run: xcodebuild -workspace ./iosApp/iosApp.xcworkspace -scheme iosApp -configuration Debug |
# OBJROOT=./build/ios SYMROOT=./build/ios -arch arm64 -allowProvisioningUpdates
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision
test-shared:
runs-on: macos-latest
Expand All @@ -67,4 +114,21 @@ jobs:
- uses: mobile-dev-inc/[email protected]
with:
api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }}
app-file: androidApp/build/outputs/apk/debug/androidApp-debug.apk
app-file: androidApp/build/outputs/apk/debug/androidApp-debug.apk

e2e-test-iosApp:
runs-on: macos-latest
needs: build-iosApp
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-lightsaber-ci


# TODO Run e2e tests when Compose Multiplatform supports either Compose test tags or
# accessibility labels
- name: Check for app file
run: test -e ./iosApp/build/ios/Release-iphonesimulator/Lightsaber.app
# - uses: mobile-dev-inc/[email protected]
# with:
# api-key: ${{ secrets.MAESTRO_CLOUD_API_KEY }}
# app-file: ./iosApp/build/ios/Release-iphonesimulator/Lightsaber.app
14 changes: 10 additions & 4 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand All @@ -366,6 +368,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}";
PRODUCT_NAME = "${APP_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "lightsaber-development";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -377,9 +380,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = "${TEAM_ID}";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = iosApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
Expand All @@ -390,6 +395,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}";
PRODUCT_NAME = "${APP_NAME}";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "lightsaber-development";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class IosSoundPlayer(private val audioEngine: AVAudioEngine) : SoundPlayer {
}
soundResourceToPlayerNodeMap.clear()
}
playingSounds.clear()

audioEngine.stop()
}
Expand Down

0 comments on commit 352d77d

Please sign in to comment.