Repository navigation
299 lines (258 loc) · 10.5 KB
/
Copy pathnative.yml
File metadata and controls
299 lines (258 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
name: native
# The window (native/) is its own Go module and its own binary, built with
# cgo: Gio needs it for Wayland, X11 and EGL, and libghostty-vt is a C library
# (docs/native-window.md). It never reaches the lich binary's build, so it gets
# these jobs instead of a step in ci.yml. They run on every change, not only
# native/'s: the smoke runs the window on the backend the change built.
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
native-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: native/go.mod
cache-dependency-path: native/go.sum
# Gio's Linux headers (gioui.org/doc/install), fontconfig for the glyph
# rasterizer, and Mesa's llvmpipe under Xvfb so the headless render tests
# draw on the CPU instead of skipping for want of a GPU.
- name: System packages
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
gcc pkg-config libwayland-dev libx11-dev libx11-xcb-dev libxkbcommon-x11-dev \
libgles2-mesa-dev libegl1-mesa-dev libffi-dev libxcursor-dev libvulkan-dev \
libgl1-mesa-dri libegl-mesa0 xvfb fontconfig fonts-dejavu-core fonts-noto-color-emoji
- name: Pinned Ghostty commit
id: ghostty
run: echo "commit=$(cat GHOSTTY_COMMIT)" >> "$GITHUB_OUTPUT"
- name: Cache libghostty-vt
id: cache
uses: actions/cache@v4
with:
path: ~/libghostty-vt
key: libghostty-vt-${{ runner.os }}-baseline-${{ steps.ghostty.outputs.commit }}
- name: Set up Zig
if: steps.cache.outputs.cache-hit != 'true'
uses: mlugg/setup-zig@v2
with:
version: 0.16.0
- name: Build libghostty-vt
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{ runner.temp }}
run: |
git init ghostty
cd ghostty
git fetch --depth 1 https://github.com/ghostty-org/ghostty "${{ steps.ghostty.outputs.commit }}"
git checkout FETCH_HEAD
zig build -Demit-lib-vt -Doptimize=ReleaseFast -Dcpu=baseline --prefix ~/libghostty-vt
- name: Point pkg-config at libghostty-vt
run: echo "PKG_CONFIG_PATH=$HOME/libghostty-vt/share/pkgconfig" >> "$GITHUB_ENV"
- name: gofmt
run: |
unformatted="$(gofmt -l .)"
if [ -n "$unformatted" ]; then
echo "::error::gofmt: these files need formatting:"
echo "$unformatted"
exit 1
fi
- name: go vet
run: go vet ./...
# The render tests skip where no GPU answers, which on a laptop is a
# shrug and here would be a gate that checks nothing: a skip fails the job.
# -noreset: each headless window holds the only X connection and drops it
# on Release, so Xvfb regenerates about 60 times a run, and an
# eglInitialize that lands mid-reset fails xcb_connect (1 run in 5 did).
- name: go test
env:
LIBGL_ALWAYS_SOFTWARE: "1"
run: |
xvfb-run -a -s "-noreset -screen 0 1280x1024x24" go test -v ./... > test.log 2>&1 || { cat test.log; exit 1; }
grep -E '^(ok|FAIL|---)' test.log
if grep -q 'no headless GPU' test.log; then
echo "::error::render tests skipped: no headless GPU under Xvfb"
grep -B1 'no headless GPU' test.log
exit 1
fi
# The Windows window is cross-built from Linux with Zig as cgo's toolchain
# (native/build-windows.sh), and so are its tests and the backend; the
# windows job below runs them on a real Windows machine.
windows-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: native
steps:
- uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: native/go.mod
cache-dependency-path: native/go.sum
- name: Set up Zig
uses: mlugg/setup-zig@v2
with:
version: 0.16.0
- name: Pinned Ghostty commit
id: ghostty
run: echo "commit=$(cat GHOSTTY_COMMIT)" >> "$GITHUB_OUTPUT"
- name: Cache the Windows libghostty-vt
uses: actions/cache@v4
with:
path: ~/libghostty-vt-windows
key: libghostty-vt-windows-${{ steps.ghostty.outputs.commit }}
- name: Build lich-native.exe
run: LIBGHOSTTY_VT_WINDOWS="$HOME/libghostty-vt-windows" ./build-windows.sh "$RUNNER_TEMP/out/lich-native.exe"
# One test binary per package, at the package's own path, so the windows
# job runs each from its package directory the way go test does. The
# toolchain is build-windows.sh's.
- name: Build the tests for Windows
env:
GOOS: windows
GOARCH: amd64
CGO_ENABLED: "1"
CC: zig cc -target x86_64-windows-gnu
CXX: zig c++ -target x86_64-windows-gnu
CGO_LDFLAGS_ALLOW: '.*\.lib'
run: |
export PKG_CONFIG_PATH="$HOME/libghostty-vt-windows/share/pkgconfig"
for dir in $(go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.Dir}}{{end}}' ./...); do
rel="${dir#"$PWD"/}"
go test -c -o "$RUNNER_TEMP/out/tests/$rel/pkg.test.exe" "./$rel"
done
- name: Build lich.exe
working-directory: .
run: GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o "$RUNNER_TEMP/out/lich.exe" .
- uses: actions/upload-artifact@v7
with:
name: native-windows-build
path: ${{ runner.temp }}/out
retention-days: 1
# Runs on Windows what windows-build made there: the native tests, then the
# window itself once against a real backend, which has to come up and draw.
windows:
needs: windows-build
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: native-windows-build
path: ${{ runner.temp }}/out
# Like the Linux job, a render test that skips for want of a GPU fails
# the job: Windows always has one, WARP's software one at least.
- name: go test
working-directory: native
run: |
out="$(cygpath -u "$RUNNER_TEMP")/out"
status=0
for exe in $(cd "$out/tests" && find . -name pkg.test.exe); do
rel="$(dirname "$exe")"
echo "### $rel" >> test.log
(cd "$rel" && "$out/tests/$exe" -test.v) >> test.log 2>&1 || status=1
done
[ "$status" = 0 ] || { cat test.log; exit 1; }
grep -E '^(### |--- FAIL|--- SKIP|PASS|FAIL)' test.log
if grep -q 'no headless GPU' test.log; then
echo "::error::render tests skipped: no headless GPU"
grep -B1 'no headless GPU' test.log
exit 1
fi
# Runs after a failed go test too: whether the window comes up at all is
# its own answer.
- name: Run the window against the backend
if: success() || failure()
run: |
out="$(cygpath -u "$RUNNER_TEMP")/out"
bash .github/scripts/win-native-smoke.sh "$out/lich.exe" "$out/lich-native.exe"
- name: Upload what the window drew
if: always()
uses: actions/upload-artifact@v7
with:
name: lich-native-windows
path: ${{ runner.temp }}/diag
if-no-files-found: ignore
# Gio's Cocoa and Metal need Apple's SDK, so the macOS window builds on a Mac
# and nowhere else. Apple Silicon only on a PR: release.yml builds Intel too.
# Nobody here has a Mac, so this job also runs the window once against a real
# backend and keeps what it drew.
macos:
runs-on: macos-latest
defaults:
run:
working-directory: native
env:
# The floor Info.plist and the cask promise (INSTALL.md, macOS); cgo's
# clang otherwise targets the runner's own macOS.
MACOSX_DEPLOYMENT_TARGET: "13.0"
steps:
- uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: native/go.mod
cache-dependency-path: native/go.sum
- name: Pinned Ghostty commit
id: ghostty
run: echo "commit=$(cat GHOSTTY_COMMIT)" >> "$GITHUB_OUTPUT"
- name: Cache libghostty-vt
id: cache
uses: actions/cache@v4
with:
path: ~/libghostty-vt
key: libghostty-vt-macos-arm64-${{ steps.ghostty.outputs.commit }}
- name: Set up Zig
if: steps.cache.outputs.cache-hit != 'true'
uses: mlugg/setup-zig@v2
with:
version: 0.16.0
- name: Build libghostty-vt
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{ runner.temp }}
run: |
git init ghostty
cd ghostty
git fetch --depth 1 https://github.com/ghostty-org/ghostty "${{ steps.ghostty.outputs.commit }}"
git checkout FETCH_HEAD
zig build -Demit-lib-vt -Doptimize=ReleaseFast -Dtarget=aarch64-macos.13.0 --prefix ~/libghostty-vt
- name: Point pkg-config at libghostty-vt
run: echo "PKG_CONFIG_PATH=$HOME/libghostty-vt/share/pkgconfig" >> "$GITHUB_ENV"
- name: go vet
run: go vet ./...
# The render tests skip where no GPU answers; the Linux job is the one
# that fails on a skip, this one lists them.
- name: go test
run: |
go test -v ./... > test.log 2>&1 || { cat test.log; exit 1; }
grep -E '^(ok|FAIL|---)' test.log
grep -B1 'no headless GPU' test.log || true
- name: Build lich-native
run: go build -trimpath -ldflags "-s -w" -o "$RUNNER_TEMP/lich-native" ./cmd/lich-native
- name: Check what lich-native asks of a machine
run: bash ../.github/scripts/mac-native-floor.sh "$RUNNER_TEMP/lich-native"
- name: Build the backend
working-directory: .
run: CGO_ENABLED=0 go build -o "$RUNNER_TEMP/lich" .
- name: Run the window against the backend
working-directory: .
run: bash .github/scripts/mac-native-smoke.sh "$RUNNER_TEMP/lich" "$RUNNER_TEMP/lich-native"
- name: Upload what the window drew
if: always()
uses: actions/upload-artifact@v7
with:
name: lich-native-macos
path: ${{ runner.temp }}/diag
if-no-files-found: ignore