Repository Public
1#!/usr/bin/env bash2# Valo-Plex iOS3# File: Scripts/build.sh4# Description: génération du projet, compilation, tests et lancement sur les simulateurs dédiés5# (aucun pilotage d'interface : les écrans s'ouvrent par arguments de lancement).6# usage : build.sh generate | debug | test | uitest | run [arguments] | shot <nom>7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -uo pipefail11cd "$(dirname "$0")/.."12SIM="${VALOPLEX_SIM:-ValoPlex iPhone}"13DD="build/DerivedData"14BUNDLE="com.spboucher.valoplex"15mkdir -p build/logs build/shots16filter() { grep -E "error:|warning: |\*\* |Executed [0-9]+ tests|Testing failed|failed \(|Test [Cc]ase .* failed|✘|Test run with" | grep -v "appintentsmetadataprocessor" | sed "s|$PWD/||" | awk '!seen[$0]++' | head -"${LINES_MAX:-60}"; }17udid() { xcrun simctl list devices | grep -F "$SIM (" | head -1 | sed -E 's/.*\(([0-9A-F-]{36})\).*/\1/'; }18case "${1:-debug}" in19 generate) xcodegen generate --quiet && echo "projet généré" ;;20 debug)21 xcodegen generate --quiet22 xcodebuild -project ValoPlex.xcodeproj -scheme ValoPlex -configuration Debug -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" build 2>&1 | tee build/logs/debug.log | filter ;;23 test)24 shift || true; xcodegen generate --quiet25 xcodebuild -project ValoPlex.xcodeproj -scheme ValoPlex -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:ValoPlexTests "$@" test 2>&1 | tee build/logs/test.log | filter ;;26 uitest)27 # parcours d'interface dans le simulateur (sans fenêtre), contre l'API de production28 shift || true; xcodegen generate --quiet29 xcodebuild -project ValoPlex.xcodeproj -scheme ValoPlex -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:ValoPlexUITests -parallel-testing-enabled NO "$@" test 2>&1 | tee build/logs/uitest.log | filter ;;30 run)31 # installe et lance l'app sur le simulateur ; arguments suivants = arguments de lancement (-VXTab, -VXOpen, -VXQuery, -VXAnchor)32 U="$(udid)"; xcrun simctl boot "$U" 2>/dev/null; xcrun simctl bootstatus "$U" >/dev/null 2>&133 xcrun simctl install "$U" "$DD/Build/Products/Debug-iphonesimulator/ValoPlex.app" && xcrun simctl terminate "$U" "$BUNDLE" >/dev/null 2>&134 xcrun simctl launch "$U" "$BUNDLE" "${@:2}" ;;35 shot)36 U="$(udid)"; xcrun simctl io "$U" screenshot "build/shots/${2:-capture}.png" >/dev/null 2>&1 && echo "build/shots/${2:-capture}.png" ;;37 *) echo "usage: build.sh generate|debug|test|run [args]|shot <nom>"; exit 2 ;;38esac39