Files
XStats/.github/workflows/ci.yml
T

61 lines
2.1 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
jobs:
build-and-test:
runs-on: macos-15
steps:
- uses: actions/checkout@v7
# CommandLineTools alone cannot expand SwiftUI's @Observable / @Entry
# macros — the plugins ship only with full Xcode. Pick the newest Xcode
# on the image rather than the default one or a pinned version that a
# future image may not carry.
- name: Select Xcode
run: |
find /Applications -maxdepth 1 -type d -name 'Xcode*.app' -print
XCODE=$(find /Applications -maxdepth 1 -type d -name 'Xcode_*.app' -print | sort -V | tail -1)
echo "Using $XCODE"
sudo xcode-select -s "$XCODE/Contents/Developer"
swift --version
- uses: actions/setup-go@v6
with:
go-version-file: server/api/go.mod
cache-dependency-path: server/api/go.sum
- name: Install build tools
run: brew install go-task xcodegen
- name: Test
run: task test
- name: Build app
run: task build CONFIG=Release BUMP=0 INSTALL=0
- name: Verify bundle
run: |
APP=build/DerivedData-arm64/Build/Products/Release/XStats.app
test -x "$APP/Contents/MacOS/XStats"
test -x "$APP/Contents/MacOS/XStatsHelper"
test -f "$APP/Contents/Library/LaunchDaemons/work.12306.xstats.helper.plist"
test -f "$APP/Contents/Resources/AppIcon.icns"
codesign --verify --verbose "$APP"
# Smoke test: there is no menu bar or window to drive in CI, so render
# every main-window page, popover and settings section off-screen. A view
# that traps on layout fails here rather than the first time a user opens it.
- name: Render UI snapshots
run: |
build/DerivedData-arm64/Build/Products/Release/XStats.app/Contents/MacOS/XStats --snapshot "$PWD/snapshots"
test "$(find snapshots -maxdepth 1 -type f -name '*.png' | wc -l | tr -d ' ')" -ge 20
- uses: actions/upload-artifact@v7
with:
name: ui-snapshots
path: snapshots/