Skip to content

Commit 966a79b

Browse files
committed
fix CI
1 parent 48c612a commit 966a79b

File tree

1 file changed

+101
-17
lines changed

1 file changed

+101
-17
lines changed

.github/workflows/ci.yaml

Lines changed: 101 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,75 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
env:
1010
CARGO_TERM_COLOR: always
1111
RUSTFLAGS: --deny warnings
1212
RUSTDOCFLAGS: --deny warnings
13+
SLANG_TAG: 2025.18.2
1314

1415
jobs:
16+
# Check formatting.
17+
format:
18+
name: Format
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Install Rust toolchain
26+
uses: dtolnay/rust-toolchain@stable
27+
with:
28+
components: rustfmt
29+
30+
- name: Run cargo fmt
31+
run: cargo fmt --all -- --check
32+
setup-slang:
33+
strategy:
34+
matrix:
35+
os: [ubuntu-latest]
36+
runs-on: ${{ matrix.os }}
37+
outputs:
38+
slang-dir: ${{ steps.setup.outputs.slang-dir }} # Pass SLANG_DIR to dependent jobs
39+
slang-cache-key: ${{ steps.setup.outputs.slang-cache-key }} # Pass SLANG_DIR to dependent jobs
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
44+
- name: Cache Slang
45+
id: cache-slang
46+
uses: actions/cache/restore@v4 # Restore first
47+
with:
48+
path: |
49+
~/.cache/slang # Matches script's default OUTPUT_DIR
50+
key: slang-v$SLANG_TAG-${{ runner.os }}-${{ runner.arch }}
51+
52+
- name: Setup Slang
53+
id: setup
54+
run: |
55+
echo "version=$SLANG_TAG" >> $GITHUB_OUTPUT # Output for cache key
56+
SLANG_DIR=$(./download_slang.sh --version $SLANG_TAG | grep '^SLANG_DIR=' | cut -d'=' -f2-)
57+
echo "slang-dir=$SLANG_DIR" >> $GITHUB_OUTPUT # Output for dependents
58+
echo "slang-cache-key=slang-v$SLANG_TAG-${{ runner.os }}-${{ runner.arch }}" >> $GITHUB_OUTPUT
59+
echo "SLANG_DIR=$SLANG_DIR" >> $GITHUB_ENV # For this job if needed
60+
61+
- name: Save Slang Cache
62+
if: steps.cache-slang.outputs.cache-hit != 'true' # Only save on miss
63+
uses: actions/cache/save@v4
64+
with:
65+
path: ~/.cache/slang
66+
key: ${{ steps.setup.outputs.slang-cache-key }}
1567
# Run clippy lints.
1668
clippy:
69+
needs: setup-slang # Depends on setup-slang
1770
name: Clippy
1871
runs-on: ubuntu-latest
72+
env:
73+
SLANG_DIR: ${{ needs.setup-slang.outputs.slang-dir }}
1974
timeout-minutes: 30
2075
steps:
2176
- name: Checkout repository
@@ -27,38 +82,61 @@ jobs:
2782
components: clippy
2883

2984
- name: Install dependencies
30-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
85+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev
86+
87+
- name: Retrieve Cache for Slang
88+
uses: actions/cache/restore@v4
89+
with:
90+
path: ~/.cache/slang
91+
key: ${{ needs.setup-slang.outputs.slang-cache-key }}
3192

3293
- name: Populate target directory from cache
3394
uses: Leafwing-Studios/cargo-cache@v2
3495
with:
3596
sweep-cache: true
3697

3798
- name: Run clippy lints
38-
run: cargo clippy --locked --workspace --all-targets --all-features -- --deny warnings
99+
run: SLANG_DIR=$SLANG_DIR cargo clippy --locked --workspace --all-targets -- --deny warnings
39100

40-
# Check formatting.
41-
format:
42-
name: Format
101+
# Check documentation.
102+
doc:
103+
needs: setup-slang # Depends on setup-slang
104+
name: Docs
43105
runs-on: ubuntu-latest
44106
timeout-minutes: 30
107+
env:
108+
SLANG_DIR: ${{ needs.setup-slang.outputs.slang-dir }}
45109
steps:
46110
- name: Checkout repository
47111
uses: actions/checkout@v4
48112

49113
- name: Install Rust toolchain
50114
uses: dtolnay/rust-toolchain@stable
115+
116+
- name: Install dependencies
117+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev
118+
119+
- name: Retrieve Cache for Slang
120+
uses: actions/cache/restore@v4
51121
with:
52-
components: rustfmt
122+
path: ~/.cache/slang
123+
key: ${{ needs.setup-slang.outputs.slang-cache-key }}
53124

54-
- name: Run cargo fmt
55-
run: cargo fmt --all -- --check
125+
- name: Populate target directory from cache
126+
uses: Leafwing-Studios/cargo-cache@v2
127+
with:
128+
sweep-cache: true
56129

57-
# Check documentation.
58-
doc:
59-
name: Docs
130+
- name: Check documentation
131+
run: SLANG_DIR=$SLANG_DIR cargo doc --locked --workspace --document-private-items --no-deps
132+
# Testing.
133+
test:
134+
needs: setup-slang # Depends on setup-slang
135+
name: Tests
60136
runs-on: ubuntu-latest
61137
timeout-minutes: 30
138+
env:
139+
SLANG_DIR: ${{ needs.setup-slang.outputs.slang-dir }}
62140
steps:
63141
- name: Checkout repository
64142
uses: actions/checkout@v4
@@ -67,12 +145,18 @@ jobs:
67145
uses: dtolnay/rust-toolchain@stable
68146

69147
- name: Install dependencies
70-
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
148+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev
149+
150+
- name: Retrieve Cache for Slang
151+
uses: actions/cache/restore@v4
152+
with:
153+
path: ~/.cache/slang
154+
key: ${{ needs.setup-slang.outputs.slang-cache-key }}
71155

72156
- name: Populate target directory from cache
73157
uses: Leafwing-Studios/cargo-cache@v2
74158
with:
75159
sweep-cache: true
76-
77-
- name: Check documentation
78-
run: cargo doc --locked --workspace --all-features --document-private-items --no-deps
160+
- name: Run Cargo Tests
161+
run: |
162+
SLANG_DIR=$SLANG_DIR cargo test --verbose

0 commit comments

Comments
 (0)