Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : SP Music8# File : Scripts/prod-smoke.sh9# Module : Scripts10# Repository : https://git.spboucher.ai/sp-music-ios11# Created : 2026-11-1712# Last Modified : 2026-11-1713#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# SP Music iOS41# File: Scripts/prod-smoke.sh42# Description: Read-only production smoke test with a temporary listener account.43#44# Author: Simon-Pierre Boucher45# Contact: contact@spboucher.ai46# SP Music iOS — read-only smoke test against production (music.spboucher.ai) on the simulator.47# Creates a temporary LISTENER account with one session directly in the production database, runs48# Tests/AppTests/ProductionSmokeTests.swift, then deletes the account (and with it its session) whatever happened.49set -euo pipefail50cd "$(dirname "$0")/.."51NODE="${SPMUSIC_PROD_NODE:-m5ma}"52cleanup() { ssh "$NODE" '/opt/homebrew/opt/postgresql@17/bin/psql -q -d sp_music -c "DELETE FROM users WHERE email = '"'"'ios-smoke@example.test'"'"' AND NOT is_owner" && echo "temporary account deleted"'; }53trap cleanup EXIT54TOKEN=$(ssh "$NODE" 'bash -s' <<'REMOTE'55set -euo pipefail56PSQL=/opt/homebrew/opt/postgresql@17/bin/psql57TOKEN=$(python3 -c "import secrets;print(secrets.token_urlsafe(32))"); CSRF=$(python3 -c "import secrets;print(secrets.token_urlsafe(24))")58HASH=$(printf %s "$TOKEN" | shasum -a 256 | cut -d" " -f1)59$PSQL -q -d sp_music -v ON_ERROR_STOP=1 -v th="$HASH" -v csrf="$CSRF" >/dev/null <<'SQL'60DELETE FROM users WHERE email = 'ios-smoke@example.test' AND NOT is_owner;61WITH u AS (INSERT INTO users (email, display_name, role) VALUES ('ios-smoke@example.test', 'Essai iOS (temporaire)', 'listener') RETURNING id)62INSERT INTO sessions (user_id, token_hash, csrf_token, method, user_agent, ip, expires_at) SELECT id, :'th', :'csrf', 'device', 'SPMusic-iOS smoke test', 'local', now() + interval '30 minutes' FROM u;63SQL64printf %s "$TOKEN"65REMOTE66)67xcodegen generate >/dev/null68TEST_RUNNER_SPMUSIC_PROD_SESSION="$TOKEN" xcodebuild test -project SPMusic.xcodeproj -scheme SPMusic -destination "platform=iOS Simulator,name=SPMusic iPhone" -derivedDataPath build/dd \69 -only-testing:SPMusicTests/ProductionSmokeTests -parallel-testing-enabled NO 2>&1 | grep -E "error:|✔|✘|NOTE:|recorded|TEST (SUCCEEDED|FAILED)|BUILD FAILED" | sed "s|$PWD/||"70