Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596#!/bin/bashset -euo pipefailcd "$(dirname "$0")/../.."unset BASH_ENV# shellcheck source=Scripts/product.envsource Scripts/product.envwork=$(mktemp -d "${TMPDIR:-/tmp}/launch-tests.XXXXXX")trap 'rm -rf "$work"' EXITmkdir -p "$work/bin" "$work/home" "$work/project/Scripts"export LAUNCH_TEST_LOG="$work/tools.log"for tool in gh git security xcrun cloudflared ssh swiftc; do # shellcheck disable=SC2016 printf '%s\n' '#!/bin/bash' 'printf "%s\n" "$0 $*" >> "$LAUNCH_TEST_LOG"' 'exit 99' > "$work/bin/$tool" chmod +x "$work/bin/$tool"donecount=0check() { if ! "$@"; then printf 'Launch test failed: %s\n' "$*" >&2; exit 1; fi count=$((count + 1))}fails() { if "$@" > "$work/failure.log" 2>&1; then return 1; fi; }plan() { env PATH="$work/bin:$PATH" HOME="$work/home" bash Scripts/launch.sh "$@"; }plan --dry-run > "$work/plan"check grep -Fq "$PRODUCT_NAME ($PRODUCT_CLI, $PRODUCT_BUNDLE_ID)" "$work/plan"check grep -Fq "$PRODUCT_KNOT_URL" "$work/plan"check grep -Fq "$PRODUCT_GITHUB_REPO" "$work/plan"check grep -Fq "$PRODUCT_SITE_REPO/$PRODUCT_SITE_FEED" "$work/plan"for name in DEVELOPER_ID_P12 DEVELOPER_ID_PASSWORD DEVELOPER_ID_IDENTITY ASC_PRIVATE_KEY ASC_KEY_ID ASC_ISSUER_ID APPLE_TEAM_ID MIRROR_TOKEN SPARKLE_PRIVATE_KEY SPARKLE_PUBLIC_KEY; do check grep -Fq "$name" "$work/plan"donecheck grep -Fq 'Keychain' "$work/plan"check grep -Fq 'cloudflared tunnel route dns' "$work/plan"check grep -Fq 'No commands, secrets, files, or remotes changed' "$work/plan"check grep -Fq 'every 15 minutes or by manual dispatch (not pushes)' "$work/plan"check grep -Fq "mirrors only $PRODUCT_DEFAULT_BRANCH and eligible v tags" "$work/plan"check grep -Fq 'fresh Keychain helper' "$work/plan"check grep -Fq 'GitHub environment mirror' "$work/plan"check grep -Fq 'Contents and Workflows read/write' "$work/plan"check grep -Fq 'BLOCK release tag push and manual release dispatch' "$work/plan"check grep -Fq 'workflow_dispatch on main' "$work/plan"check grep -Fq "displayTitle 'Release v$PRODUCT_FIRST_VERSION'" "$work/plan"check grep -Fq 'docs/releasing-setup.md' "$work/plan"check grep -Fq 'Exit 3 means required' "$work/plan"check grep -Fq 'New GitHub tag pushes, including mirrored tags, trigger the default-branch dispatcher' "$work/plan"check grep -Fq 'no secret-bearing tangled workflows' "$work/plan"plan --dry-run --version 2.3.4 --site-repo '/tmp/site with spaces' --site-feed 'dist/appcast.xml' > "$work/custom"check grep -Fq 'v2.3.4' "$work/custom"check grep -Fq '/tmp/site with spaces/dist/appcast.xml' "$work/custom"check plan --help > "$work/help"check grep -Fq 'Usage:' "$work/help"for version in v1.0 '' '1;touch sentinel' 1.2.3.4 -1 1.x 1 1.2 1.2.3-beta 1.2.3+build.42 $'1.2.3\n'; do check fails plan --dry-run --version "$version"donecheck fails plan --unknowncheck fails plan --versioncheck fails plan --replace-secretcheck fails plan --dry-run --replace-secret UNKNOWNcheck fails plan --dry-run --replace-secret SPARKLE_PRIVATE_KEYcheck plan --dry-run --replace-secret DEVELOPER_ID_PASSWORD > "$work/replace-plan"check grep -Fq 'Replacement requested: DEVELOPER_ID_PASSWORD' "$work/replace-plan"check fails plan --dry-run --site-feed ../appcast.xmlcheck fails plan --dry-run --site-feed /appcast.xmlcheck fails plan </dev/nullcheck grep -Fq 'Run interactively' "$work/failure.log"check test ! -e "$LAUNCH_TEST_LOG"check test -z "$(find "$work/home" -mindepth 1 -print)"cp Scripts/launch.sh Scripts/product.env Scripts/version.sh "$work/project/Scripts/"while IFS= read -r line; do case $line in 'export PRODUCT_NAME='*) line='export PRODUCT_NAME=Crate' ;; 'export PRODUCT_CLI='*) line='export PRODUCT_CLI=crt' ;; 'export PRODUCT_BUNDLE_ID='*) line='export PRODUCT_BUNDLE_ID=org.example.crate' ;; 'export PRODUCT_GITHUB_REPO='*) line='export PRODUCT_GITHUB_REPO=example/crate' ;; 'export PRODUCT_KNOT_URL='*) line='export PRODUCT_KNOT_URL=git@knot.example.org:example.org/crate' ;; esac printf '%s\n' "$line"done < "$work/project/Scripts/product.env" > "$work/product.env"mv "$work/product.env" "$work/project/Scripts/product.env"env PATH="$work/bin:$PATH" HOME="$work/home" bash "$work/project/Scripts/launch.sh" --dry-run > "$work/renamed"check grep -Fq 'Crate (crt, org.example.crate)' "$work/renamed"check grep -Fq 'example/crate' "$work/renamed"check grep -Fq 'git@knot.example.org:example.org/crate' "$work/renamed"check test ! -e "$LAUNCH_TEST_LOG"swiftc -swift-version 6 -warnings-as-errors Scripts/launch-keychain.swift -o "$work/keychain"check fails "$work/keychain"check fails "$work/keychain" getcheck fails "$work/keychain" ensure-updatecheck fails "$work/keychain" put unused unused </dev/nullcheck grep -Fq 'empty secret' "$work/failure.log"printf 'invalid seed' | "$work/keychain" put https://sparkle-project.org unused > "$work/key-error" 2>&1 && exit 1check grep -Fq 'base64 Ed25519 seed' "$work/key-error"source Scripts/script-root-test.shcheck script_root_test InteractiveLaunchTestscheck swift test --package-path Scripts/tests/LaunchTests -Xswiftc -warnings-as-errorsprintf 'Launch shell checks passed: %s\n' "$count"