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

[PM-9375] Build a debug-for-simulator version of the app for easier automated testing #1151

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
505678c
Initial build script
KatherineInCode Aug 27, 2024
da86f7a
Update scripts
KatherineInCode Nov 15, 2024
445bdf8
Build out workflow
KatherineInCode Nov 18, 2024
ae5e2fd
Add a find to see what's going on
KatherineInCode Nov 18, 2024
0bab9cd
Fix typo
KatherineInCode Nov 18, 2024
e3d7e04
Recursive copy
KatherineInCode Nov 18, 2024
2108361
Update workflow
KatherineInCode Nov 19, 2024
815b690
Add simulator build to CI main
KatherineInCode Nov 19, 2024
47896a5
Merge branch 'main' into pm-9375/app-build
KatherineInCode Nov 19, 2024
9bdb6f6
Start merging build-sim into build workflow
KatherineInCode Nov 20, 2024
3a1ee75
Update build script to unify it
KatherineInCode Nov 20, 2024
718287b
Update ci-main
KatherineInCode Nov 20, 2024
0e6502b
Pass destination in to build flow
KatherineInCode Nov 20, 2024
43cf693
Remove unnecessary update
KatherineInCode Nov 20, 2024
d9577a3
Change file name
KatherineInCode Nov 20, 2024
b9e1802
Update name
KatherineInCode Nov 20, 2024
d7aac49
Delete things
KatherineInCode Nov 20, 2024
c3d4098
Update step name
KatherineInCode Nov 20, 2024
6b7a638
Temporary changes to test ci main flow
KatherineInCode Nov 20, 2024
fb6019b
Undo temporary
KatherineInCode Nov 20, 2024
8b619af
Merge branch 'main' into pm-9375/app-build
KatherineInCode Nov 20, 2024
6941e77
Use generic iOS simulator instead of specified one
KatherineInCode Nov 21, 2024
9289566
Pull simulator destination into build script
KatherineInCode Nov 22, 2024
8768c8d
Split out build mode from build variant
KatherineInCode Nov 22, 2024
460d931
Remove simulator as variant
KatherineInCode Nov 22, 2024
b5acb08
Revert version read
KatherineInCode Nov 22, 2024
a62d201
Update build script doc
vvolkgang Nov 23, 2024
ab2431f
Refactor build script, error if an unexpected build mode is provided
vvolkgang Nov 23, 2024
3956e3d
Only upload to testflight Device builds
vvolkgang Nov 23, 2024
5ca715c
Refactor simulator / device prepare and upload steps.
vvolkgang Nov 23, 2024
f6c06fe
Only retrieve secrets for Device builds
vvolkgang Nov 23, 2024
5653dc1
Fix artifacts preparation step; removes zip instructions
vvolkgang Nov 25, 2024
34cf1f6
Add compiler flags to artifact name
vvolkgang Nov 25, 2024
7c15338
All steps validations are now positive and specific to Device mode
vvolkgang Nov 25, 2024
c4dfbb0
Where we're going we don't need ruby
vvolkgang Nov 25, 2024
0d9b5c5
Fix compiler_flags usage in step
vvolkgang Nov 25, 2024
c786d3b
Fix capitalization
KatherineInCode Nov 26, 2024
1710764
Update .github/workflows/CI-main.yml
vvolkgang Nov 27, 2024
9077794
Remove comment
vvolkgang Nov 27, 2024
df97810
Merge branch 'main' into pm-9375/app-build
vvolkgang Nov 27, 2024
f5dc1ac
Add build mode to artifact name
vvolkgang Nov 27, 2024
371763a
Leftover copypasta :spaghetti:
vvolkgang Nov 27, 2024
3afcba7
Include derived data path
KatherineInCode Dec 2, 2024
3aebbfa
Update variables to match bwwl standards
KatherineInCode Dec 2, 2024
5f646f0
Merge branch 'main' into pm-9375/app-build
KatherineInCode Dec 2, 2024
327bcc3
Fix variable
KatherineInCode Dec 2, 2024
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
13 changes: 13 additions & 0 deletions .github/workflows/CI-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,16 @@ jobs:
upload_version_info: false
compiler-flags: "DEBUG_MENU"
secrets: inherit

build-simulator:
name: Build Simulator App
needs: resolve-values
uses: bitwarden/ios/.github/workflows/build.yml@main
with:
build-variant: Simulator
build-version: ${{ needs.resolve-values.outputs.version_name }}
build-number: ${{ needs.resolve-values.outputs.version_number }}
xcode-version: ${{ needs.resolve-values.outputs.xcode_version }}
distribute: ${{ fromJSON(needs.resolve-values.outputs.distribute_to_testflight) }}
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved
upload_version_info: false
secrets: inherit
19 changes: 0 additions & 19 deletions .github/workflows/build-for-simulator.yml

This file was deleted.

47 changes: 43 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
options:
- Beta
- Production
- Simulator
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved
build-version:
description: "Version Name Override - e.g. '2024.8.1'"
type: string
Expand Down Expand Up @@ -133,9 +134,11 @@ jobs:
name: version-info
path: version-info/version_info.json

- name: Read default Xcode version
- name: Read default Xcode version and simulator configuration
run: |
echo "DEFAULT_XCODE_VERSION=$(cat .xcode-version | tr -d '\n')" >> "$GITHUB_ENV"
echo "DEFAULT_SIMULATOR_NAME=$(cat .test-simulator-device-name | tr -d '\n')" >> "$GITHUB_ENV"
echo "DEFAULT_SIMULATOR_VERSION=$(cat .test-simulator-ios-version | tr -d '\n')" >> "$GITHUB_ENV"

- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
Expand All @@ -152,11 +155,13 @@ jobs:
${{ runner.os }}-mint-

- name: Log in to Azure
if: env.BUILD_VARIANT != 'Simulator'
uses: Azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1.6.1
with:
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Retrieve secrets
if: env.BUILD_VARIANT != 'Simulator'
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: "bitwarden-ci"
Expand Down Expand Up @@ -259,12 +264,14 @@ jobs:
plutil -replace BUNDLE_ID -string com.8bit.bitwarden.beta.watchkitapp BitwardenWatchApp/$TARGET_FILE

- name: Retrieve certificates
if: env.BUILD_VARIANT != 'Simulator'
run: |
mkdir -p $HOME/certificates
az keyvault secret show --id https://bitwarden-ci.vault.azure.net/certificates/ios-distribution |
jq -r .value | base64 -d > $HOME/certificates/ios-distribution.p12

- name: Download Fastlane credentials
if: env.BUILD_VARIANT != 'Simulator'
env:
ACCOUNT_NAME: bitwardenci
CONTAINER_NAME: mobile
Expand All @@ -275,6 +282,7 @@ jobs:
--file $HOME/secrets/$FILE --output none

- name: Configure Keychain Access
if: env.BUILD_VARIANT != 'Simulator'
env:
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
run: |
Expand All @@ -288,6 +296,7 @@ jobs:
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $KEYCHAIN_PASSWORD build.keychain

- name: Configure provisioning profiles
if: env.BUILD_VARIANT != 'Simulator'
run: |
./Scripts/configure_provisioning_profiles.sh ${{ env.BUILD_VARIANT }}

Expand All @@ -302,6 +311,7 @@ jobs:
echo 'app_identifier "com.8bit.bitwarden.beta"' > fastlane/Appfile

- name: Update APNS entitlements
if: env.BUILD_VARIANT != 'Simulator'
run: |
plutil -replace aps-environment -string production Bitwarden/Application/Support/Bitwarden.entitlements

Expand All @@ -310,17 +320,26 @@ jobs:
with:
bundler-cache: true

- name: Install Fastlane, Mint
- name: Update homebrew
run: |
brew update
brew install fastlane mint

- name: Install Fastlane
if: env.BUILD_VARIANT != 'Simulator'
run: |
brew install fastlane

- name: Install Mint
run: |
brew install mint

- name: Install Mint packages
if: steps.mint-cache.outputs.cache-hit != 'true'
run: |
mint bootstrap

- name: Select variant
if: env.BUILD_VARIANT != 'Simulator'
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved
run: |
./Scripts/select_variant.sh ${{ env.BUILD_VARIANT }} "${{ inputs.compiler-flags }}"

Expand All @@ -335,29 +354,49 @@ jobs:

- name: Build iOS app
run: |
./Scripts/build.sh
./Scripts/build.sh ${{ env.BUILD_VARIANT }} "platform=iOS Simulator,name=${{ env.SIMULATOR_NAME || env.DEFAULT_SIMULATOR_NAME }},OS=${{ env.SIMULATOR_VERSION || env.DEFAULT_SIMULATOR_VERSION }}"
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved

- name: Prepare APP files for upload to GitHub
if: env.BUILD_VARIANT == 'Simulator'
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved
run: |
find . -name "*.app"
mkdir -p export
cp -r build/DerivedData/Build/Products/Debug-iphonesimulator/Bitwarden.app export
cp -r build/DerivedData/Build/Products/Debug-watchsimulator/BitwardenWatchApp.app export

- name: Upload APP files
if: env.BUILD_VARIANT == 'Simulator'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Bitwarden iOS ${{ steps.version_info.outputs.version_name }} (${{ steps.version_info.outputs.version_number }}) ${{ env.BUILD_VARIANT }} ${{ env.XCODE_VERSION || env.DEFAULT_XCODE_VERSION }}
path: export
if-no-files-found: error

- name: Prepare IPA & dSYM files for upload to GitHub
if: env.BUILD_VARIANT != 'Simulator'
run: |
mkdir -p export/dSYMs
cp build/Bitwarden/Bitwarden.ipa export
cp -rv build/Bitwarden.xcarchive/dSYMs/*.dSYM export/dSYMs

- name: Upload IPA & dSYM files
if: env.BUILD_VARIANT != 'Simulator'
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Bitwarden iOS ${{ steps.version_info.outputs.version_name }} (${{ steps.version_info.outputs.version_number }}) ${{ env.BUILD_VARIANT }} ${{ env.XCODE_VERSION || env.DEFAULT_XCODE_VERSION }}
path: export
if-no-files-found: error

- name: Set up private auth key
if: env.BUILD_VARIANT != 'Simulator'
run: |
mkdir ~/private_keys
cat << EOF > ~/private_keys/AuthKey_J46C83CB96.p8
${{ secrets.APP_STORE_CONNECT_AUTH_KEY }}
EOF

- name: Validate app with App Store Connect
if: env.BUILD_VARIANT != 'Simulator'
run: |
xcrun altool --validate-app \
--type ios \
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
68 changes: 49 additions & 19 deletions Scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,73 @@
#!/usr/bin/env bash
#
# Builds the beta Bitwarden iOS app, and outputs an IPA file that can be uploaded to TestFlight.
# Builds the Bitwarden iOS app.
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved
# If run in Simulator mode, produces an APP file for the iOS Simulator for ease of automated testing.
# If run in Release or Beta mode, produces an IPA file that can be uploaded to Testflight.
#
# Usage:
#
# $ ./build.sh
# $ ./build.sh [mode] [destination]

set -euo pipefail

bold=$(tput -T ansi bold)
normal=$(tput -T ansi sgr0)

BUILD_DIR="build"
if [ $# -lt 1 ]; then
echo >&2 "Called without necessary arguments: ${bold}mode${normal}. ${bold}destination${normal}"
echo >&2 "For example: \`Scripts/build.sh Simulator \"platform=iOS Simulator,OS=18.1,name=iPhone 16 Pro\""
exit 1
fi

MODE=$1
DESTINATION=$2

BUILD_DIR="build"
DERIVED_DATA_PATH="${BUILD_DIR}/DerivedData"
ARCHIVE_PATH="${BUILD_DIR}/Bitwarden.xcarchive"
EXPORT_PATH="${BUILD_DIR}/Bitwarden"

echo "๐Ÿงฑ Building in $(pwd)"
echo "๐Ÿงฑ Building in ${bold}$(pwd)${normal}"
echo "๐Ÿงฑ Using build mode of ${bold}${MODE}${normal}."
echo "๐Ÿงฑ Derived Data path ${bold}${DERIVED_DATA_PATH}${normal}"
echo "๐Ÿงฑ Archive path ${bold}${ARCHIVE_PATH}${normal}"
echo "๐Ÿงฑ Export path ${bold}${EXPORT_PATH}${normal}"
echo ""

echo "๐ŸŒฑ Generating xcode project"
echo "๐ŸŒฑ Generating Xcode project"
mint run xcodegen
echo ""

mkdir -p "${BUILD_DIR}"

echo "๐Ÿ”จ Performing Xcode archive"
xcrun xcodebuild archive \
-project Bitwarden.xcodeproj \
-scheme Bitwarden \
-configuration Release \
-archivePath "${ARCHIVE_PATH}" \
| xcbeautify --renderer github-actions
echo ""
if [[ "$MODE" == "Simulator" ]]; then
echo "๐Ÿ”จ Performing Xcode build"
xcrun xcodebuild \
-project Bitwarden.xcodeproj \
-scheme Bitwarden \
-configuration Debug \
-destination "${DESTINATION}" \
-derivedDataPath "${DERIVED_DATA_PATH}" \
| xcbeautify --renderer github-actions
else
vvolkgang marked this conversation as resolved.
Show resolved Hide resolved
echo "๐Ÿ“ฆ Performing Xcode archive"
xcrun xcodebuild archive \
-project Bitwarden.xcodeproj \
-scheme Bitwarden \
-configuration Release \
-derivedDataPath "${DERIVED_DATA_PATH}" \
-archivePath "${ARCHIVE_PATH}" \
| xcbeautify --renderer github-actions

echo "๐Ÿšš Performing Xcode archive export"
xcrun xcodebuild -exportArchive \
-archivePath "${ARCHIVE_PATH}" \
-derivedDataPath "${DERIVED_DATA_PATH}" \
-exportPath "${EXPORT_PATH}" \
-exportOptionsPlist "Configs/export_options.plist" \
| xcbeautify --renderer github-actions

echo "๐Ÿ“ฆ Performing Xcode archive export"
xcrun xcodebuild -exportArchive \
-archivePath "${ARCHIVE_PATH}" \
-exportPath "${EXPORT_PATH}" \
-exportOptionsPlist "Configs/export_options.plist" \
| xcbeautify --renderer github-actions
fi

echo ""
echo "๐ŸŽ‰ Build complete"
Loading