#!/bin/bash

pipe_to_github_summary() {
    if [[ "" == "${GITHUB_STEP_SUMMARY}" ]]; then
        cat
    else
        tee -a "${GITHUB_STEP_SUMMARY}"
    fi
}

cd cutbox_command || exit 1

make build

cutbox_cli="$(swift build --show-bin-path)"/CutBoxCLI

if [[ ! -e $cutbox_cli ]]; then
    exit 1
fi

cat <<-EOF
====================================================
 CutBox - cutbox cli - build success
====================================================

Testing...
----------------------------------------------------
EOF

make test | xcpretty -f ../bin/quickspec_markdown_xcpretty_formatter.rb | pipe_to_github_summary
