Unnamed repository; edit this file 'description' to name the repository.
CI: Cache tree-sitter grammars in all jobs
This change adds tree-sitter grammar caching to Check, Lints and Docs jobs which all previously downloaded grammars in the `helix-term` build script fresh per job. This should increase reliability and mitigate the effects of an ongoing SourceHut outage (<https://status.sr.ht/issues/2025-01-23-git.sr.ht-ddos/>). This is also a nice speed boost for these jobs: | Job name | Example time before | Example time after | |--- |--- |--- | | Check | 2m20s | 47s | | Lints | 2m56s | 1m10s | | Docs | 4m56s | 2m35s |
Michael Davis 2025-01-23
parent 76a8682 · commit 7dea2b0
-rw-r--r--.github/workflows/build.yml29
1 files changed, 26 insertions, 3 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 21bb51b2..f712a531 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,6 +10,8 @@ on:
env:
MSRV: "1.76"
+ # This key can be changed to bust the cache of tree-sitter grammars.
+ GRAMMAR_CACHE_VERSION: ""
jobs:
check:
@@ -29,6 +31,13 @@ jobs:
with:
shared-key: "build"
+ - name: Cache tree-sitter grammars
+ uses: actions/cache@v4
+ with:
+ path: runtime/grammars
+ key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
+
- name: Run cargo check
run: cargo check
@@ -52,12 +61,12 @@ jobs:
with:
shared-key: "build"
- - name: Cache test tree-sitter grammar
+ - name: Cache tree-sitter grammars
uses: actions/cache@v4
with:
path: runtime/grammars
- key: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
- restore-keys: ${{ runner.os }}-stable-v${{ env.CACHE_VERSION }}-tree-sitter-grammars-
+ key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
- name: Run cargo test
run: cargo test --workspace
@@ -87,6 +96,13 @@ jobs:
with:
shared-key: "build"
+ - name: Cache tree-sitter grammars
+ uses: actions/cache@v4
+ with:
+ path: runtime/grammars
+ key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
+
- name: Run cargo fmt
run: cargo fmt --all --check
@@ -115,6 +131,13 @@ jobs:
with:
shared-key: "build"
+ - name: Cache tree-sitter grammars
+ uses: actions/cache@v4
+ with:
+ path: runtime/grammars
+ key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
+
- name: Validate queries
run: cargo xtask query-check