Skip to content

Commit

Permalink
CI: Cache tree-sitter grammars in all jobs
Browse files Browse the repository at this point in the history
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              |
  • Loading branch information
the-mikedavis committed Jan 23, 2025
1 parent 76a8682 commit 7dea2b0
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7dea2b0

Please sign in to comment.