Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
workflow_dispatch:

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'push' }}

jobs:
build-and-test:
Expand Down Expand Up @@ -37,7 +37,52 @@ jobs:
run: swift build --build-tests

- name: Run tests
run: swift test --parallel
run: |
set -euo pipefail
LOG_FILE="$(mktemp -t xctest-log.XXXXXX.log)"
TEST_BUNDLE="$(find .build -type d -name 'SnapshotReportKitPackageTests.xctest' | head -n 1)"
if [ -z "${TEST_BUNDLE}" ]; then
echo "[ci] ERROR: test bundle not found under .build"
find .build -maxdepth 4 -type d -name '*.xctest' -print || true
exit 1
fi

echo "Running xctest bundle: ${TEST_BUNDLE}"
echo "Logs: ${LOG_FILE}"

xcrun xctest "${TEST_BUNDLE}" >"${LOG_FILE}" 2>&1 &
TEST_PID=$!
START_TS=$(date +%s)
TIMEOUT_SECONDS=$((10 * 60))

while kill -0 "${TEST_PID}" 2>/dev/null; do
NOW_TS=$(date +%s)
ELAPSED=$((NOW_TS - START_TS))
echo "[ci] xctest still running (${ELAPSED}s elapsed)"
ps -p "${TEST_PID}" -o pid=,ppid=,%cpu=,%mem=,etime=,command= || true
echo "===== xctest log (tail -n 40) ====="
tail -n 40 "${LOG_FILE}" || true

if [ "${ELAPSED}" -ge "${TIMEOUT_SECONDS}" ]; then
echo "[ci] ERROR: xctest exceeded timeout (${TIMEOUT_SECONDS}s)"
kill -TERM "${TEST_PID}" 2>/dev/null || true
sleep 5
kill -KILL "${TEST_PID}" 2>/dev/null || true
echo "===== xctest log (tail) ====="
tail -n 200 "${LOG_FILE}" || true
exit 124
fi

sleep 30
done

set +e
wait "${TEST_PID}"
STATUS=$?
set -e
echo "===== xctest log (tail) ====="
tail -n 200 "${LOG_FILE}" || true
exit "${STATUS}"

- name: CLI smoke test
run: swift run snapshot-report --help
3 changes: 3 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ jobs:
mkdir -p "dist/${ROOT}"

BIN=".build/${ARCH}-apple-macosx/release/snapshot-report"
BUNDLE=".build/${ARCH}-apple-macosx/release/SnapshotReportKit_SnapshotReportCore.bundle"
cp "${BIN}" "dist/${ROOT}/snapshot-report"
cp -R "${BUNDLE}" "dist/${ROOT}/SnapshotReportKit_SnapshotReportCore.bundle"
chmod +x "dist/${ROOT}/snapshot-report"

tar -C dist -czf "dist/${ROOT}.tar.gz" "${ROOT}"
Expand Down Expand Up @@ -160,6 +162,7 @@ jobs:

def install
bin.install "snapshot-report" => "snapshot-report-nightly"
bin.install "SnapshotReportKit_SnapshotReportCore.bundle"
end

test do
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ jobs:
mkdir -p "dist/${ROOT}"

BIN=".build/${ARCH}-apple-macosx/release/snapshot-report"
BUNDLE=".build/${ARCH}-apple-macosx/release/SnapshotReportKit_SnapshotReportCore.bundle"
cp "${BIN}" "dist/${ROOT}/snapshot-report"
cp -R "${BUNDLE}" "dist/${ROOT}/SnapshotReportKit_SnapshotReportCore.bundle"
chmod +x "dist/${ROOT}/snapshot-report"

tar -C dist -czf "dist/${ROOT}.tar.gz" "${ROOT}"
Expand Down Expand Up @@ -143,6 +145,7 @@ jobs:

def install
bin.install "snapshot-report"
bin.install "SnapshotReportKit_SnapshotReportCore.bundle"
end

test do
Expand Down
1 change: 1 addition & 0 deletions scripts/generate-homebrew-formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SnapshotReport < Formula

def install
bin.install "snapshot-report"
bin.install "SnapshotReportKit_SnapshotReportCore.bundle"
end

test do
Expand Down