SPB Git

Repository Public License

build.sh 2.9 KB 50 lines shellscript

1#!/usr/bin/env bash2# ORIX Secure3# File: Scripts/build.sh4# Description: Generate the Xcode project, build, and test (filtered output; full logs in build/logs).5#              usage: build.sh generate | kit | debug | release | uitest [xcodebuild args] | all6#              ORIX_SIM selects the simulator (default "ORIXSecure iPhone"; iPad: "ORIXSecure iPad").7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -uo pipefail11cd "$(dirname "$0")/.."12SIM="${ORIX_SIM:-ORIXSecure iPhone}"13DD="build/DerivedData"14mkdir -p build/logs15filter() { sed -E 's/\x1b\[[0-9;]*m//g' | grep -E "error:|warning: unre|\*\* |Test Suite .* (passed|failed)|Executed [0-9]+ tests|✘|Testing failed|failed \(|Test run with|Test Case .* (failed)" | sort -u | head -"${LINES_MAX:-60}" | cut -c1-400; }16case "${1:-debug}" in17  generate)18    xcodegen generate --quiet && echo "project generated" ;;19  kit)20    # Engines on the host Mac (fast): every package's tests. Prints one summary line per package.21    : > build/logs/kit.log22    for package in Packages/*/; do23      name=$(basename "$package")24      [[ -d "$package/Tests" ]] || continue25      (cd "$package" && swift test 2>&1) > "build/logs/kit-$name.log"26      cat "build/logs/kit-$name.log" >> build/logs/kit.log27      echo "$name: $(grep -E "Test run with|✘| error: " "build/logs/kit-$name.log" | sed -E 's/\x1b\[[0-9;]*m//g' | tr '\n' ' ' | cut -c1-300)"28    done ;;29  debug)30    xcodebuild -project ORIXSecure.xcodeproj -scheme ORIXSecure -configuration Debug -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" build 2>&1 | tee build/logs/debug.log | filter ;;31  release)32    xcodebuild -project ORIXSecure.xcodeproj -scheme ORIXSecure -configuration Release -destination "generic/platform=iOS Simulator" -derivedDataPath "$DD" build 2>&1 | tee build/logs/release.log | filter ;;33  uitest)34    shift || true35    NAME="${SIM// /_}"36    rm -rf "build/results/uitest-$NAME.xcresult"37    # Boot and wait: launching the test runner on a simulator that is still starting fails its preflight ("Busy").38    xcrun simctl boot "$SIM" 2>/dev/null || true39    xcrun simctl bootstatus "$SIM" -b >/dev/null 2>&1 || true40    # Photo Cleanup tests delete generated photos for real: seed them again before every run.41    ORIX_SIM="$SIM" Scripts/seed-photos.sh >/dev/null42    xcodebuild -project ORIXSecure.xcodeproj -scheme ORIXSecure -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" \43      -only-testing:ORIXSecureUITests -resultBundlePath "build/results/uitest-$NAME.xcresult" "$@" test 2>&1 | tee "build/logs/uitest-$NAME.log" | filter44    rm -rf "build/shots/$NAME"; mkdir -p "build/shots/$NAME"45    xcrun xcresulttool export attachments --path "build/results/uitest-$NAME.xcresult" --output-path "build/shots/$NAME" >/dev/null 2>&1 || true ;;46  all)47    "$0" generate && "$0" kit && "$0" debug && "$0" uitest ;;48  *) echo "usage: build.sh generate|kit|debug|release|uitest|all"; exit 2 ;;49esac50
Files main
Menu

Theme