rheaarchived
- 40 commits
- 1 branch
- 0 tags
- updated
ci.md
5.0 KB · 129 lines
1# CI: Gitea Actions on a self-hosted macOS runner23Part of epic #43 (CI & releases on self-hosted Gitea). This document covers the4one-time setup of the `act_runner` on this Mac; the workflow itself lives at5`.gitea/workflows/ci.yml` and is checked into the repo.67## What runs89On every push and pull request, the workflow:10111. Checks out the repo.122. Runs `xcodegen generate` to produce `Rhea.xcodeproj` (not committed —13 `project.yml` is the source of truth).143. Runs `xcodebuild build test -scheme Rhea -destination 'platform=macOS'`,15 which builds the app and runs both `RheaTests` (unit) and `RheaUITests`16 (XCUITest) targets, writing a result bundle.174. Uploads the `.xcresult` bundle as a workflow artifact, always (even on18 failure), so a failing run's logs/screenshots are inspectable from the19 Gitea Actions UI without re-running locally.2021A failing build or any failing test fails the check and is reported on the22Gitea PR page.2324## Runner prerequisites (one-time, on this Mac)2526The runner machine needs, ahead of any CI run:2728- **Xcode** installed, with the license accepted:29 `sudo xcodebuild -license accept`30- **XcodeGen**: `brew install xcodegen`31- A stable, always-logged-in user session (see the Accessibility caveat32 below — this rules out running the runner as a headless/background-only33 service user).3435## Registering `act_runner`36371. Install the runner binary:38 ```39 brew install act_runner40 ```41 (or download the binary for macOS from the Gitea releases page if not42 available via Homebrew on this system).43442. Get a registration token from the Gitea instance: **repo or org Settings45 → Actions → Runners → Create new runner**, copy the token shown.46473. Register the runner with the `macos` label so `runs-on: macos` in the48 workflow resolves to this machine:49 ```50 act_runner register \51 --instance https://git.danieldaum.net \52 --token <TOKEN> \53 --name mac-runner-1 \54 --labels macos55 ```56 This writes `.runner` config in the working directory you run it from —57 pick a stable location, e.g. `~/gitea-runner/`.58594. Daemonize with `launchd` so the runner survives reboots. Create60 `~/Library/LaunchAgents/net.danieldaum.act-runner.plist`:61 ```xml62 <?xml version="1.0" encoding="UTF-8"?>63 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"64 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">65 <plist version="1.0">66 <dict>67 <key>Label</key>68 <string>net.danieldaum.act-runner</string>69 <key>ProgramArguments</key>70 <array>71 <string>/opt/homebrew/bin/act_runner</string>72 <string>daemon</string>73 </array>74 <key>WorkingDirectory</key>75 <string>/Users/YOUR_USER/gitea-runner</string>76 <key>RunAtLoad</key>77 <true/>78 <key>KeepAlive</key>79 <true/>80 <key>StandardOutPath</key>81 <string>/Users/YOUR_USER/gitea-runner/runner.log</string>82 <key>StandardErrorPath</key>83 <string>/Users/YOUR_USER/gitea-runner/runner.err</string>84 </dict>85 </plist>86 ```87 Load it:88 ```89 launchctl load ~/Library/LaunchAgents/net.danieldaum.act-runner.plist90 ```91 Use a `LaunchAgent` (not a `LaunchDaemon`) — the runner must execute in a92 real logged-in GUI session for the reason below, and LaunchDaemons run93 outside any user session.9495## Known blocker: XCUITest needs Accessibility permission granted manually9697`RheaUITests` exercises the app via XCUITest, which requires the test98runner's automation session to have **System Settings → Privacy & Security →99Accessibility** access. This is a one-time grant tied to the specific process100(Xcode's generated `XCTRunner` host app / `xcodebuild`'s test runner) and101**cannot be granted by a workflow YAML or any CI script** — it's a manual,102interactive step on the runner machine itself, done once after Xcode/the103runner is set up:1041051. Run the test suite once locally on the runner Mac106 (`xcodebuild ... test`) so macOS prompts for Accessibility access, or107 trigger the prompt via **System Settings → Privacy & Security →108 Accessibility → +** and add the relevant `xcodebuild`/`XCTRunner` binary109 manually.1102. Enable the toggle.111112Without this, `RheaUITests` will fail or hang on the runner even though the113same suite passes when run interactively from Xcode by a user who has114already granted the permission. If CI test runs fail specifically in115`RheaUITests` with no clear assertion failure (timeouts, "Failed to get116matching snapshot" errors, or the run hanging), check this first.117118This also means the runner must operate under a real, logged-in GUI user119session (not a headless SSH-only login) — another reason to register it as120a `LaunchAgent` under the interactive user rather than a system121`LaunchDaemon`.122123## Verifying the workflow124125Push a branch and check **Gitea → repo → Actions** for a running/completed126job, or the checks panel on the PR page. A red check with logs in the127`test-results` artifact means a real build/test failure; a run that never128starts usually means the runner isn't registered, isn't labeled `macos`, or129isn't running (`launchctl list | grep act-runner`).