diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a53b0f..aa069cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ concurrency: group: unity-floating-license cancel-in-progress: true +# Pull request builds report to, and upload their debug symbols to, the test project +# (TEST_* secrets). Everything else reports to the demo org. The build fingerprint hashes +# the destination, so cached players never cross between the two. jobs: format: name: Check formatting @@ -59,9 +62,9 @@ jobs: uses: ./.github/actions/build-fingerprint with: target: StandaloneWindows64 - sentry-dsn: ${{ secrets.DSN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Restore cached Windows player id: cached @@ -89,10 +92,10 @@ jobs: with: target: StandaloneWindows64 output-path: Build/StandaloneWindows64/SentaurSurvivors.exe - sentry-dsn: ${{ secrets.DSN }} - sentry-auth-token: ${{ secrets.AUTH_TOKEN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-auth-token: ${{ github.event_name == 'pull_request' && secrets.TEST_AUTH_TOKEN || secrets.AUTH_TOKEN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Upload Build Artifact uses: actions/upload-artifact@v4 @@ -139,18 +142,18 @@ jobs: uses: ./.github/actions/build-fingerprint with: target: StandaloneOSX - sentry-dsn: ${{ secrets.DSN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Fingerprint iOS build id: fingerprint-ios uses: ./.github/actions/build-fingerprint with: target: iOS - sentry-dsn: ${{ secrets.DSN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} # The archives are cached rather than the build directories: they are what the # artifacts are made of, and taring first avoids the symlink and permission @@ -203,10 +206,10 @@ jobs: with: target: StandaloneOSX output-path: Build/StandaloneOSX/SentaurSurvivors.app - sentry-dsn: ${{ secrets.DSN }} - sentry-auth-token: ${{ secrets.AUTH_TOKEN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-auth-token: ${{ github.event_name == 'pull_request' && secrets.TEST_AUTH_TOKEN || secrets.AUTH_TOKEN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} # Tar the bundle: upload-artifact drops the executable bit and flattens the # symlinks that the .app relies on to launch. @@ -221,10 +224,10 @@ jobs: with: target: iOS output-path: Build/iOS - sentry-dsn: ${{ secrets.DSN }} - sentry-auth-token: ${{ secrets.AUTH_TOKEN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-auth-token: ${{ github.event_name == 'pull_request' && secrets.TEST_AUTH_TOKEN || secrets.AUTH_TOKEN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Compile iOS Xcode project if: steps.cached-ios.outputs.hit != 'true' @@ -296,18 +299,18 @@ jobs: uses: ./.github/actions/build-fingerprint with: target: StandaloneLinux64 - sentry-dsn: ${{ secrets.DSN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Fingerprint Android build id: fingerprint-android uses: ./.github/actions/build-fingerprint with: target: Android - sentry-dsn: ${{ secrets.DSN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Restore cached Linux player id: cached-linux @@ -357,10 +360,10 @@ jobs: with: target: StandaloneLinux64 output-path: Build/StandaloneLinux64/SentaurSurvivors - sentry-dsn: ${{ secrets.DSN }} - sentry-auth-token: ${{ secrets.AUTH_TOKEN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-auth-token: ${{ github.event_name == 'pull_request' && secrets.TEST_AUTH_TOKEN || secrets.AUTH_TOKEN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Build Android player if: steps.cached-android.outputs.hit != 'true' @@ -368,10 +371,10 @@ jobs: with: target: Android output-path: Build/Android/SentaurSurvivors.apk - sentry-dsn: ${{ secrets.DSN }} - sentry-auth-token: ${{ secrets.AUTH_TOKEN }} - sentry-org: ${{ secrets.ORG }} - sentry-project: ${{ secrets.PROJECT }} + sentry-dsn: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} + sentry-auth-token: ${{ github.event_name == 'pull_request' && secrets.TEST_AUTH_TOKEN || secrets.AUTH_TOKEN }} + sentry-org: ${{ github.event_name == 'pull_request' && secrets.TEST_ORG || secrets.ORG }} + sentry-project: ${{ github.event_name == 'pull_request' && secrets.TEST_PROJECT || secrets.PROJECT }} - name: Upload Linux Build Artifact uses: actions/upload-artifact@v4 @@ -410,14 +413,26 @@ jobs: target: StandaloneLinux64 save: true - run-demo: + # Each demo starts as soon as its players are built: Windows alongside the later + # builds, iOS and Android once the chain is through. + run-demo-windows: name: Run Demo - # Only the Windows demo is enabled in run-demo.yml, and the Windows artifact is - # ready as soon as the first build finishes - so the demo runs alongside the - # macOS and Linux builds instead of behind them. Re-enabling a demo job for - # another platform means adding that platform's build back to this list. needs: build-windows uses: ./.github/workflows/run-demo.yml secrets: inherit with: build-run-id: ${{ github.run_id }} + platforms: windows + + # Still inside the workflow's license group, so a newer CI run cancels this one too. + # On main the players are uploaded by then, so the scheduled mobile demo carries on from + # them. A cancelled pull request run loses its mobile demo: re-run the job. + run-demo-mobile: + name: Run Demo Mobile + needs: [build-macos, build-linux] + if: ${{ !cancelled() }} + uses: ./.github/workflows/run-demo.yml + secrets: inherit + with: + build-run-id: ${{ github.run_id }} + platforms: ios,android diff --git a/.github/workflows/run-demo.yml b/.github/workflows/run-demo.yml index 999fdd4..bd570b4 100644 --- a/.github/workflows/run-demo.yml +++ b/.github/workflows/run-demo.yml @@ -4,62 +4,106 @@ name: Run Demo Builds # workflow directly, and having both would run every demo twice for each build. on: schedule: - - cron: '*/10 * * * *' # every 10 minutes + # Two cadences, split per job below on github.event.schedule: desktop is cheap and + # short, so it runs twice as often as the slower mobile jobs. + - cron: '*/10 * * * *' # desktop + - cron: '*/20 * * * *' # mobile workflow_call: inputs: build-run-id: description: 'The run ID of the build workflow that created the artifacts' required: false type: string + platforms: + description: 'Platforms to run, comma-separated with no spaces, e.g. ios,android (windows, ios, android, linux, macos). Empty runs the default set.' + required: false + type: string workflow_dispatch: + inputs: + platforms: + description: 'Platforms to run, comma-separated with no spaces, e.g. ios,android (windows, ios, android, linux, macos). Empty runs Windows, iOS and Android.' + required: false + type: string + +# Which jobs run: +# - With a platforms list, exactly the platforms it names. ci.yml always passes one: in +# a called workflow the github context is the caller's, so ci.yml's own weekly cron +# would otherwise look like a schedule here. +# - Without one, Windows, iOS and Android, each cron starting only its own cadence. +# Linux and macOS run only when a list names them. +# +# Pull request runs report to the test project (TEST_* secrets), everything else to the +# demo org. The player carries its DSN from the build, so this only has to match ci.yml. jobs: get-build-run: name: Get Build Run runs-on: ubuntu-latest outputs: - run-id: ${{ steps.get-run.outputs.run-id }} + windows-run-id: ${{ steps.get-run.outputs.windows }} + ios-run-id: ${{ steps.get-run.outputs.ios }} + android-run-id: ${{ steps.get-run.outputs.android }} + linux-run-id: ${{ steps.get-run.outputs.linux }} + macos-run-id: ${{ steps.get-run.outputs.macos }} steps: - - name: Set run ID - # Scheduled runs resolve the newest live Windows artifact on main; callers use their own run. + - name: Set run IDs + # Callers pass their own run; scheduled runs take each platform's newest live + # artifact on main. id: get-run shell: pwsh env: BUILD_RUN_ID: ${{ inputs.build-run-id }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + $artifacts = [ordered]@{ + windows = 'SentaurSurvivors-StandaloneWindows64' + ios = 'SentaurSurvivors-iOS' + android = 'SentaurSurvivors-Android' + linux = 'SentaurSurvivors-StandaloneLinux64' + macos = 'SentaurSurvivors-StandaloneOSX' + } + if (-not [string]::IsNullOrWhiteSpace($env:BUILD_RUN_ID)) { - "run-id=$env:BUILD_RUN_ID" >> $env:GITHUB_OUTPUT + foreach ($platform in $artifacts.Keys) { + "$platform=$env:BUILD_RUN_ID" >> $env:GITHUB_OUTPUT + } exit 0 } # Deliberately keyed off the artifact, not the run conclusion: a build run is - # marked failed when any platform fails, and the demo only needs the Windows + # marked failed when any platform fails, and each demo only needs its own # player. Asking for a green run made this fall back to a months-old build # whose artifact had a different internal layout. - $artifact = 'SentaurSurvivors-StandaloneWindows64' - $uri = 'https://api.github.com/repos/${{ github.repository }}/actions/artifacts' + - "?name=$artifact&per_page=100" - $found = Invoke-RestMethod -Uri $uri -Headers @{ Authorization = "Bearer $env:GH_TOKEN" } - - # Newest first, so the first live main artifact wins. - $match = $found.artifacts | - Where-Object { -not $_.expired -and $_.workflow_run.head_branch -eq 'main' } | - Select-Object -First 1 - - # Without this the run ID comes out empty and every download below fails with a - # confusing "artifact not found" instead of naming the real problem. - if (-not $match) { - throw "No live '$artifact' artifact found on main to take the player from." + foreach ($platform in $artifacts.Keys) { + $artifact = $artifacts[$platform] + $uri = 'https://api.github.com/repos/${{ github.repository }}/actions/artifacts' + + "?name=$artifact&per_page=100" + $found = Invoke-RestMethod -Uri $uri -Headers @{ Authorization = "Bearer $env:GH_TOKEN" } + + # Newest first, so the first live main artifact wins. + $match = $found.artifacts | + Where-Object { -not $_.expired -and $_.workflow_run.head_branch -eq 'main' } | + Select-Object -First 1 + + if (-not $match) { + # Every desktop cron runs the Windows demo, so a missing player there is an + # error. Elsewhere the job's download step fails and names the artifact. + if ($platform -eq 'windows') { + throw "No live '$artifact' artifact found on main to take the player from." + } + Write-Host "::warning::No live '$artifact' artifact found on main." + continue + } + + Write-Host "Using $artifact from run $($match.workflow_run.id) ($($match.created_at))." + "$platform=$($match.workflow_run.id)" >> $env:GITHUB_OUTPUT } - Write-Host "Using $artifact from run $($match.workflow_run.id) ($($match.created_at))." - "run-id=$($match.workflow_run.id)" >> $env:GITHUB_OUTPUT - run-windows: name: Run Windows Build needs: get-build-run + if: inputs.platforms && contains(format(',{0},', inputs.platforms), ',windows,') || !inputs.platforms && github.event.schedule != '*/20 * * * *' runs-on: windows-latest steps: @@ -70,14 +114,14 @@ jobs: uses: ./.github/actions/setup-demo-run with: artifact: SentaurSurvivors-StandaloneWindows64 - build-run-id: ${{ needs.get-build-run.outputs.run-id }} + build-run-id: ${{ needs.get-build-run.outputs.windows-run-id }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: Run Build - timeout-minutes: 10 + timeout-minutes: 5 shell: pwsh env: - SENTRY_DSN: ${{ secrets.DSN }} + SENTRY_DSN: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} run: | $executable = './build/SentaurSurvivors.exe' if (-not (Test-Path $executable)) { @@ -97,8 +141,7 @@ jobs: run-linux: name: Run Linux Build needs: get-build-run - # Temporarily disabled: only the Windows demo runs for now. - if: false + if: inputs.platforms && contains(format(',{0},', inputs.platforms), ',linux,') runs-on: ubuntu-latest steps: @@ -109,14 +152,14 @@ jobs: uses: ./.github/actions/setup-demo-run with: artifact: SentaurSurvivors-StandaloneLinux64 - build-run-id: ${{ needs.get-build-run.outputs.run-id }} + build-run-id: ${{ needs.get-build-run.outputs.linux-run-id }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: Run Build - timeout-minutes: 10 + timeout-minutes: 5 shell: bash env: - SENTRY_DSN: ${{ secrets.DSN }} + SENTRY_DSN: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} run: | executable=./build/SentaurSurvivors if [ ! -f "$executable" ]; then @@ -139,8 +182,7 @@ jobs: run-macos: name: Run macOS Build needs: get-build-run - # Temporarily disabled: only the Windows demo runs for now. - if: false + if: inputs.platforms && contains(format(',{0},', inputs.platforms), ',macos,') runs-on: macos-15 steps: @@ -152,7 +194,7 @@ jobs: with: artifact: SentaurSurvivors-StandaloneOSX path: . - build-run-id: ${{ needs.get-build-run.outputs.run-id }} + build-run-id: ${{ needs.get-build-run.outputs.macos-run-id }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: Extract Build @@ -162,10 +204,10 @@ jobs: tar -xzf SentaurSurvivors-macOS.tar.gz -C build - name: Run Build - timeout-minutes: 10 + timeout-minutes: 5 shell: bash env: - SENTRY_DSN: ${{ secrets.DSN }} + SENTRY_DSN: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} run: | executable=./build/SentaurSurvivors.app/Contents/MacOS/SentaurSurvivors if [ ! -f "$executable" ]; then @@ -186,8 +228,7 @@ jobs: run-ios: name: Run iOS Build needs: get-build-run - # Temporarily disabled: only the Windows demo runs for now. - if: false + if: inputs.platforms && contains(format(',{0},', inputs.platforms), ',ios,') || !inputs.platforms && github.event.schedule != '*/10 * * * *' runs-on: macos-15 steps: @@ -199,7 +240,7 @@ jobs: with: artifact: SentaurSurvivors-iOS path: . - build-run-id: ${{ needs.get-build-run.outputs.run-id }} + build-run-id: ${{ needs.get-build-run.outputs.ios-run-id }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: Extract Build @@ -212,7 +253,7 @@ jobs: timeout-minutes: 15 shell: pwsh env: - SENTRY_DSN: ${{ secrets.DSN }} + SENTRY_DSN: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} run: ./.github/scripts/run-demo-ios.ps1 -AppPath ./build/SentaurSurvivors.app -Dsn $env:SENTRY_DSN - name: Upload iOS player log @@ -226,8 +267,7 @@ jobs: run-android: name: Run Android Build needs: get-build-run - # Temporarily disabled: only the Windows demo runs for now. - if: false + if: inputs.platforms && contains(format(',{0},', inputs.platforms), ',android,') || !inputs.platforms && github.event.schedule != '*/10 * * * *' runs-on: ubuntu-24.04-arm env: ANDROID_SERIAL: localhost:5555 @@ -240,17 +280,23 @@ jobs: uses: ./.github/actions/setup-demo-run with: artifact: SentaurSurvivors-Android - build-run-id: ${{ needs.get-build-run.outputs.run-id }} + build-run-id: ${{ needs.get-build-run.outputs.android-run-id }} github-token: ${{ secrets.GITHUB_TOKEN }} # Redroid runs a real Android userspace in a container, which needs the binder - # kernel modules the stock runner image does not load. + # kernel module the stock runner image does not load. Older runner kernels ship it + # in a separate linux-modules-extra package; newer ones (7.0 azure) have no such + # package and carry their modules in linux-modules. - name: Start Redroid container shell: bash run: | sudo apt-get update - sudo apt-get install -y adb aapt "linux-modules-extra-$(uname -r)" - sudo modprobe binder_linux devices="binder,hwbinder,vndbinder" + sudo apt-get install -y adb aapt + binder=(binder_linux devices="binder,hwbinder,vndbinder") + if ! sudo modprobe "${binder[@]}"; then + sudo apt-get install -y "linux-modules-extra-$(uname -r)" + sudo modprobe "${binder[@]}" + fi sudo modprobe ashmem_linux || true docker run -d --rm --privileged --name redroid -p 5555:5555 \ redroid/redroid:13.0.0_64only-latest androidboot.redroid_gpu_mode=guest @@ -275,7 +321,7 @@ jobs: timeout-minutes: 15 shell: pwsh env: - SENTRY_DSN: ${{ secrets.DSN }} + SENTRY_DSN: ${{ github.event_name == 'pull_request' && secrets.TEST_DSN || secrets.DSN }} run: ./.github/scripts/run-demo-android.ps1 -ApkPath ./build/SentaurSurvivors.apk -Dsn $env:SENTRY_DSN - name: Upload Android player log diff --git a/AGENTS.md b/AGENTS.md index 89780b3..037ceb2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -95,6 +95,9 @@ unity command run_tests - CI (`ci.yml`) gates on two things only: the formatter with `--verify-no-changes`, and player builds for macOS, iOS, Windows, Linux, Android. No test job — clean compile + green build is the real bar. - `run-demo.yml` exercises the demo-config path with the intentional faults on. + It runs the players on Windows, iOS and Android: on every build, and on a cron for main + (desktop every 10 minutes, mobile every 20). Pull request builds report to the test + project (`TEST_*` secrets); main reports to the demo org. ## Commit attribution