Skip to content

Commit bd26ad4

Browse files
committed
github actions: Build and cache tint-extract separately
Normally, clap would fetch and build tint-extract if "WebGPU" is amoung the specified renderers, but in a github action this wastes a lot of time. Instead, build it separately outside of main build stage and cache the result to avoid rebuilds in subsequent workflow runs. Signed-off-by: Alexander Shishkin <alex@ash.works>
1 parent 664eeb4 commit bd26ad4

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

.github/workflows/www-build.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,48 @@ jobs:
2020
run: |
2121
sudo apt-get update
2222
sudo apt-get install -y glslc spirv-cross
23+
- name: tint-rev
24+
id: tint-rev
25+
run: |
26+
url=$(jq -r '.[0].source.url' deps/bootstrap-wgpu.json)
27+
rev=$(jq -r '.[0].source.revision' deps/bootstrap-wgpu.json)
28+
if [[ "$rev" =~ ^[0-9a-f]{40}$ ]]; then
29+
sha=$rev
30+
else
31+
sha=$(git ls-remote "$url" "$rev" | cut -f1)
32+
fi
33+
if [[ -z "$sha" ]]; then
34+
echo "failed to resolve tint-extract revision '$rev' at $url" >&2
35+
exit 1
36+
fi
37+
echo "url=$url" >> "$GITHUB_OUTPUT"
38+
echo "sha=$sha" >> "$GITHUB_OUTPUT"
39+
- name: cache-tint
40+
id: cache-tint
41+
uses: actions/cache@v4
42+
with:
43+
path: ${{ github.workspace }}/tint-build
44+
key: tint-${{ runner.os }}-${{ steps.tint-rev.outputs.sha }}
45+
- name: build-tint
46+
if: steps.cache-tint.outputs.cache-hit != 'true'
47+
run: |
48+
src="${{ github.workspace }}/tint-src"
49+
build="${{ github.workspace }}/tint-build"
50+
git clone --recursive --filter=blob:none "${{ steps.tint-rev.outputs.url }}" "$src"
51+
git -C "$src" checkout "${{ steps.tint-rev.outputs.sha }}"
52+
git -C "$src" submodule update --init --recursive
53+
cmake -S "$src" -B "$build" -DCMAKE_BUILD_TYPE=Release
54+
cmake --build "$build" --parallel 4
2355
- name: configure
56+
env:
57+
CLAP_TINT_BIN: ${{ github.workspace }}/tint-build/tint
2458
run: |
2559
cd ${{ github.workspace }}
2660
. ./emsdk/emsdk_env.sh
2761
export WWW_INSTALL_DIR="${{ github.workspace }}/www/${GITHUB_REF##*/}"
28-
cmake --preset emrel -B build/emrel
29-
cmake --preset emtest -B build/emtest
30-
cmake --preset emdebug -B build/emdebug
62+
cmake --preset emrel -B build/emrel -DCLAP_TINT_BIN="$CLAP_TINT_BIN"
63+
cmake --preset emtest -B build/emtest -DCLAP_TINT_BIN="$CLAP_TINT_BIN"
64+
cmake --preset emdebug -B build/emdebug -DCLAP_TINT_BIN="$CLAP_TINT_BIN"
3165
- name: build
3266
run: |
3367
cd ${{ github.workspace }}

0 commit comments

Comments
 (0)