From bb3b3ba6150b55c251e05fd205a1da5b8c34ec5f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 17 Mar 2026 16:51:03 -0700 Subject: [PATCH] ci: dynamically discover example directories for build-examples Replace the hardcoded matrix list in the build-examples job with a dynamic list-examples job that discovers all subdirectories under example/ at runtime. This uses ls/jq to produce a JSON array and fromJSON() to feed it into the matrix, so new examples are picked up automatically without updating the workflow. --- .github/workflows/test.yml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 501e2979f..872e41352 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 -d example/*/ | 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