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

Merged
merged 46 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
10 changes: 10 additions & 0 deletions .github/workflows/CI-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,13 @@ 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-for-simulator.yml@main
with:
build-version: ${{ needs.resolve-values.outputs.version_name }}
build-number: ${{ needs.resolve-values.outputs.version_number }}
xcode-version: ${{ needs.resolve-values.outputs.xcode_version }}
secrets: inherit
137 changes: 135 additions & 2 deletions .github/workflows/build-for-simulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,149 @@ on:
workflow_dispatch:
inputs:
build-version:
description: "Unused"
description: "Version Name Override - e.g. '2024.8.1'"
type: string
build-number:
description: "Version Number Override - e.g. '1021'"
type: string
xcode-version:
description: "Xcode Version Override - e.g. '15.2'"
type: string
workflow_call:
inputs:
build-version:
description: "Version Name Override - e.g. '2024.8.1'"
type: string
build-number:
description: "Version Number Override - e.g. '1021'"
type: string
xcode-version:
description: "Xcode Version Override - e.g. '15.2'"
type: string
env:
XCODE_VERSION: ${{ inputs.xcode-version }}

jobs:
build:
name: Build
runs-on: macos-14
runs-on: macos-15
env:
MINT_PATH: .mint/lib
MINT_LINK_PATH: .mint/bin

steps:
- name: Log inputs to job summary
run: |
echo "<details><summary>Build Workflow Inputs</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```json' >> $GITHUB_STEP_SUMMARY
echo '${{ toJson(inputs) }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY

- name: Check out repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
filter: tree:0

- name: Calculate version
if: ${{ inputs.build-number == '' || inputs.build-version == '' }}
uses: bitwarden/ios/.github/actions/dispatch-and-download@main
id: dispatch-version
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: bitwarden
repo: ios
ref: main
workflow: _version.yml
workflow_inputs: '{"base_version_number": "${{ inputs.base_version_number }}", "version_name": "${{ inputs.build-version }}", "version_number": "${{ inputs.build-number }}", "patch_version": "${{ inputs.patch_version }}"}'

- name: Read version info
id: version_info
run: |
# test if dispatch-version was skipped. In that case, creates the same .json file expected by the Upload artifact step
if [ ! -f version-info/version_info.json ]; then
echo "::warning::version-version.json not found, was the previous step skipped? Creating a new file"
json='{
"version_number": "${{ inputs.build-number }}",
"version_name": "${{ inputs.build-version }}"
}'

# file will be used by the upload step
mkdir version-info
echo "$json" > version-info/version_info.json
else
echo "::notice::version-version.json found!"
fi

content=$(cat version-info/version_info.json)
echo "version_name=$(echo $content | jq -r .version_name)" >> $GITHUB_OUTPUT
echo "version_number=$(echo $content | jq -r .version_number)" >> $GITHUB_OUTPUT

- name: Upload version info artifact
if: ${{ inputs.upload_version_info }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: version-info
path: version-info/version_info.json

- name: Read default Xcode version
run: |
echo "DEFAULT_XCODE_VERSION=$(cat .xcode-version | tr -d '\n')" >> "$GITHUB_ENV"

- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: ${{ env.XCODE_VERSION || env.DEFAULT_XCODE_VERSION }}

- name: Cache Mint packages
id: mint-cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: .mint
key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
restore-keys: |
${{ runner.os }}-mint-

- name: Configure Ruby
uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0
with:
bundler-cache: true

- name: Install Mint
run: |
brew update
brew install mint

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

- name: Update build version and number
run: |
yq -i '.settings.MARKETING_VERSION = "${{ steps.version_info.outputs.version_name }}"' 'project.yml'
yq -i '.settings.CURRENT_PROJECT_VERSION = "${{ steps.version_info.outputs.version_number }}"' 'project.yml'

- name: Update CI build info
run: |
./Scripts/update_app_ci_build_info.sh ${{ github.run_id }} ${{ github.run_number }} ${{ github.run_attempt }} "Simulator Build"

- name: Build iOS app
run: |
./Scripts/build-sim.sh

- name: Prepare APP files for upload to GitHub
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
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Bitwarden iOS-Simulator ${{ 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
32 changes: 32 additions & 0 deletions Scripts/build-sim.sh
KatherineInCode marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# Builds the beta Bitwarden iOS app in Debug mode for the iOS Simulator, for ease of automated testing.
#
# Usage:
#
# $ ./build-sim.sh

set -euo pipefail

BUILD_DIR="build"
DERIVED_DATA_PATH="${BUILD_DIR}/DerivedData"

echo "๐Ÿงฑ Building in $(pwd)"
echo "๐Ÿงฑ Derived Data path ${DERIVED_DATA_PATH}"
echo ""

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

mkdir -p "${BUILD_DIR}"

echo "๐Ÿ”จ Performing Xcode build"
xcrun xcodebuild \
-project Bitwarden.xcodeproj \
-scheme Bitwarden \
-configuration Debug \
-destination "platform=iOS Simulator,OS=18.1,name=iPhone 16" \
KatherineInCode marked this conversation as resolved.
Show resolved Hide resolved
-derivedDataPath "${DERIVED_DATA_PATH}" \
| xcbeautify --renderer github-actions

echo "๐ŸŽ‰ Build complete"
7 changes: 3 additions & 4 deletions Scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@

set -euo pipefail

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

BUILD_DIR="build"

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

echo "๐Ÿงฑ Building in $(pwd)"
echo "๐Ÿงฑ Archive path ${ARCHIVE_PATH}"
echo "๐Ÿงฑ Export path ${EXPORT_PATH}"
echo ""

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

mkdir -p "${BUILD_DIR}"
Expand Down
Loading