|
| 1 | +name: Glass probe (real app) |
| 2 | +# Draws Cap Glass in the real GPUI app on macOS (Metal), Windows (Direct3D 11 |
| 3 | +# on WARP) and Linux (wgpu on lavapipe), captures the window and scores every |
| 4 | +# scene and preset against the CPU model in apps/desktop-gpui/glass, which is |
| 5 | +# fitted to Apple's own glass. |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened, ready_for_review] |
| 10 | + paths: |
| 11 | + - "apps/desktop-gpui/glass/**" |
| 12 | + - "apps/desktop-gpui/patches/zed-glass.patch" |
| 13 | + - "apps/desktop-gpui/src/ui/glass.rs" |
| 14 | + - "apps/desktop-gpui/src/glass_probe.rs" |
| 15 | + - "scripts/glass-probe/**" |
| 16 | + - ".github/workflows/glass-probe.yml" |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + pull-requests: read |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: glass-probe-${{ github.event.pull_request.number || github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + # A pull request from a fork that changes only this workflow or the probe's |
| 29 | + # scripts does not queue the three-runner matrix; one that also changes the |
| 30 | + # glass itself does, and so does any change from this repository. |
| 31 | + scope: |
| 32 | + name: Scope |
| 33 | + runs-on: blacksmith-2vcpu-ubuntu-2404 |
| 34 | + timeout-minutes: 5 |
| 35 | + outputs: |
| 36 | + run: ${{ steps.scope.outputs.run }} |
| 37 | + steps: |
| 38 | + - name: Scope |
| 39 | + id: scope |
| 40 | + env: |
| 41 | + GH_TOKEN: ${{ github.token }} |
| 42 | + EVENT: ${{ github.event_name }} |
| 43 | + PR: ${{ github.event.pull_request.number }} |
| 44 | + SAME_REPO: ${{ github.event.pull_request.head.repo.full_name == github.repository }} |
| 45 | + run: | |
| 46 | + set -euo pipefail |
| 47 | + if [[ "$EVENT" != pull_request || "$SAME_REPO" == true ]]; then |
| 48 | + echo "run=true" >> "$GITHUB_OUTPUT"; exit 0 |
| 49 | + fi |
| 50 | + gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/files" --paginate --jq '.[].filename' > "$RUNNER_TEMP/changed.txt" |
| 51 | + glass='^apps/desktop-gpui/(glass/.*|patches/zed-glass\.patch|src/ui/glass\.rs|src/glass_probe\.rs)$' |
| 52 | + if grep -qE "$glass" "$RUNNER_TEMP/changed.txt"; then |
| 53 | + echo "run=true" >> "$GITHUB_OUTPUT" |
| 54 | + else |
| 55 | + echo "run=false" >> "$GITHUB_OUTPUT" |
| 56 | + echo "A fork pull request that changes no glass code does not run the glass probe." | tee -a "$GITHUB_STEP_SUMMARY" |
| 57 | + fi |
| 58 | +
|
| 59 | + probe: |
| 60 | + name: Glass probe (${{ matrix.settings.name }}) |
| 61 | + needs: scope |
| 62 | + if: needs.scope.outputs.run == 'true' |
| 63 | + timeout-minutes: 75 |
| 64 | + strategy: |
| 65 | + fail-fast: false |
| 66 | + matrix: |
| 67 | + settings: |
| 68 | + - name: macOS |
| 69 | + slug: macos |
| 70 | + target: aarch64-apple-darwin |
| 71 | + runner: blacksmith-6vcpu-macos-15 |
| 72 | + - name: Windows |
| 73 | + slug: windows |
| 74 | + target: x86_64-pc-windows-msvc |
| 75 | + runner: windows-2022 |
| 76 | + - name: Linux X11 |
| 77 | + slug: linux-x11 |
| 78 | + target: x86_64-unknown-linux-gnu |
| 79 | + runner: blacksmith-8vcpu-ubuntu-2404 |
| 80 | + runs-on: ${{ matrix.settings.runner }} |
| 81 | + env: |
| 82 | + CARGO_PROFILE_DEV_DEBUG: "0" |
| 83 | + steps: |
| 84 | + - name: Checkout repository |
| 85 | + uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Install Linux desktop dependencies |
| 88 | + if: ${{ runner.os == 'Linux' }} |
| 89 | + uses: ./.github/actions/install-desktop-deps |
| 90 | + |
| 91 | + - name: Install a window manager and software Vulkan |
| 92 | + if: ${{ runner.os == 'Linux' }} |
| 93 | + run: sudo apt-get install -y openbox mesa-vulkan-drivers libvulkan1 |
| 94 | + |
| 95 | + - name: Rust setup |
| 96 | + uses: dtolnay/rust-toolchain@1.95.0 |
| 97 | + with: |
| 98 | + targets: ${{ matrix.settings.target }} |
| 99 | + |
| 100 | + - uses: ./.github/actions/setup-rust-cache |
| 101 | + with: |
| 102 | + target: ${{ matrix.settings.target }} |
| 103 | + prefix-key: v1-rust-gpui |
| 104 | + save-cache: "false" |
| 105 | + workspaces: apps/desktop-gpui -> target |
| 106 | + |
| 107 | + - name: Run setup |
| 108 | + shell: bash |
| 109 | + run: node scripts/setup.js |
| 110 | + env: |
| 111 | + RUST_TARGET_TRIPLE: ${{ matrix.settings.target }} |
| 112 | + |
| 113 | + - name: Prepare GPUI dependency |
| 114 | + shell: bash |
| 115 | + run: | |
| 116 | + node scripts/sync-desktop-versions.mjs |
| 117 | + ./scripts/prepare-gpui-dependency.sh |
| 118 | +
|
| 119 | + - name: Test the glass model |
| 120 | + shell: bash |
| 121 | + run: cargo +1.95.0 test --manifest-path apps/desktop-gpui/Cargo.toml --locked -p cap-glass |
| 122 | + |
| 123 | + - name: Build the app |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + cargo +1.95.0 build --manifest-path apps/desktop-gpui/Cargo.toml --locked \ |
| 127 | + --target ${{ matrix.settings.target }} --bin cap-gpui |
| 128 | + if [[ "$RUNNER_OS" == "macOS" ]]; then |
| 129 | + for frameworks in "$GITHUB_WORKSPACE/apps/desktop-gpui/target/${{ matrix.settings.target }}/debug/Frameworks" \ |
| 130 | + "$GITHUB_WORKSPACE/apps/desktop-gpui/target/${{ matrix.settings.target }}/Frameworks"; do |
| 131 | + mkdir -p "$frameworks" |
| 132 | + ln -sfn "$GITHUB_WORKSPACE/target/Frameworks/Spacedrive.framework" "$frameworks/Spacedrive.framework" |
| 133 | + done |
| 134 | + fi |
| 135 | +
|
| 136 | + - name: Screen capture permission |
| 137 | + if: ${{ runner.os == 'macOS' }} |
| 138 | + run: | |
| 139 | + set -euo pipefail |
| 140 | + sudo pmset -a displaysleep 0 sleep 0 || true |
| 141 | + caffeinate -u -t 2 |
| 142 | + app="$GITHUB_WORKSPACE/apps/desktop-gpui/target/${{ matrix.settings.target }}/debug/cap-gpui" |
| 143 | + db="/Library/Application Support/com.apple.TCC/TCC.db" |
| 144 | + now=$(date +%s) |
| 145 | + for client in "$app" /bin/bash /Users/runner/bin/Runner.Worker /Users/runner/bin/Runner.Listener; do |
| 146 | + sudo sqlite3 "$db" "INSERT OR REPLACE INTO access (service,client,client_type,auth_value,auth_reason,auth_version,indirect_object_identifier,flags,last_modified) VALUES ('kTCCServiceScreenCapture','$client',1,2,4,1,'UNUSED',0,$now);" |
| 147 | + done |
| 148 | + sudo killall tccd || true |
| 149 | + sleep 2 |
| 150 | +
|
| 151 | + - name: Glass probe |
| 152 | + shell: bash |
| 153 | + run: | |
| 154 | + app="$GITHUB_WORKSPACE/apps/desktop-gpui/target/${{ matrix.settings.target }}/debug/cap-gpui" |
| 155 | + out="$RUNNER_TEMP/glass-probe" |
| 156 | + case "$RUNNER_OS" in |
| 157 | + macOS) |
| 158 | + scripts/glass-probe/run.sh "$app" "$out" |
| 159 | + ;; |
| 160 | + Windows) |
| 161 | + export PATH="$(cygpath "$GITHUB_WORKSPACE/target/debug"):$PATH" |
| 162 | + scripts/glass-probe/run.sh "$app.exe" "$out" |
| 163 | + ;; |
| 164 | + Linux) |
| 165 | + export LD_LIBRARY_PATH="$GITHUB_WORKSPACE/target/native-deps/lib:$GITHUB_WORKSPACE/target/debug${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" |
| 166 | + Xvfb :99 -screen 0 1920x1080x24 -noreset & |
| 167 | + export DISPLAY=:99 |
| 168 | + sleep 1 |
| 169 | + openbox & |
| 170 | + sleep 1 |
| 171 | + scripts/glass-probe/run.sh "$app" "$out" |
| 172 | + ;; |
| 173 | + esac |
| 174 | +
|
| 175 | + - name: Upload captures |
| 176 | + if: always() |
| 177 | + uses: actions/upload-artifact@v4 |
| 178 | + with: |
| 179 | + name: glass-probe-${{ matrix.settings.slug }} |
| 180 | + path: ${{ runner.temp }}/glass-probe |
| 181 | + retention-days: 7 |
| 182 | + |
| 183 | + # The probed build itself, so the same binary can run on machines with |
| 184 | + # real GPUs (the hosted runners draw on WARP and lavapipe). |
| 185 | + - name: Stage the build |
| 186 | + if: ${{ success() && runner.os != 'macOS' }} |
| 187 | + shell: bash |
| 188 | + run: | |
| 189 | + out="$RUNNER_TEMP/cap-gpui-build" |
| 190 | + mkdir -p "$out" |
| 191 | + bin="$GITHUB_WORKSPACE/apps/desktop-gpui/target/${{ matrix.settings.target }}/debug/cap-gpui" |
| 192 | + if [[ "$RUNNER_OS" == Windows ]]; then |
| 193 | + cp "$bin.exe" "$out/" |
| 194 | + cp "$GITHUB_WORKSPACE"/target/debug/*.dll "$out/" 2>/dev/null || true |
| 195 | + else |
| 196 | + cp "$bin" "$out/" |
| 197 | + cp -r "$GITHUB_WORKSPACE/target/native-deps/lib" "$out/lib" 2>/dev/null || true |
| 198 | + fi |
| 199 | +
|
| 200 | + - name: Upload the build |
| 201 | + if: ${{ success() && runner.os != 'macOS' }} |
| 202 | + uses: actions/upload-artifact@v4 |
| 203 | + with: |
| 204 | + name: cap-gpui-debug-${{ matrix.settings.slug }} |
| 205 | + path: ${{ runner.temp }}/cap-gpui-build |
| 206 | + if-no-files-found: ignore |
| 207 | + retention-days: 3 |
0 commit comments