Ensure all examples in libghostty C docs build and run in CI (#11609)

This moves all our examples away from embedded source to `@snippet` and
files so that we can use our CI to actually run the builds and keep them
working.

Note: I used AI to extract the examples, and it did some weird merging
stuff. It all works but I want to make sure all these examples are still
human friendly so I need to go back and review all that. I clicked
through the web docs and they look good, just need to verify the GitHub
flow.
This commit is contained in:
Mitchell Hashimoto
2026-03-18 08:34:35 -07:00
committed by GitHub
35 changed files with 576 additions and 406 deletions

View File

@@ -167,23 +167,30 @@ jobs:
- name: Build Benchmarks
run: nix develop -c zig build -Demit-bench
list-examples:
if: github.repository == 'ghostty-org/ghostty' && needs.skip.outputs.skip != 'true'
needs: skip
runs-on: namespace-profile-ghostty-xsm
outputs:
dirs: ${{ steps.list.outputs.dirs }}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- id: list
name: List example directories
run: |
dirs=$(ls example/*/build.zig.zon 2>/dev/null | xargs -n1 dirname | xargs -n1 basename | jq -R -s -c 'split("\n") | map(select(. != ""))')
echo "$dirs" | jq .
echo "dirs=$dirs" >> "$GITHUB_OUTPUT"
build-examples:
strategy:
fail-fast: false
matrix:
dir:
[
c-vt,
c-vt-key-encode,
c-vt-paste,
c-vt-sgr,
zig-formatter,
zig-vt,
zig-vt-stream,
]
dir: ${{ fromJSON(needs.list-examples.outputs.dirs) }}
name: Example ${{ matrix.dir }}
runs-on: namespace-profile-ghostty-sm
needs: test
runs-on: namespace-profile-ghostty-xsm
needs: [test, list-examples]
env:
ZIG_LOCAL_CACHE_DIR: /zig/local-cache
ZIG_GLOBAL_CACHE_DIR: /zig/global-cache