Skip to content

Cleanup CI #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/actions/build-wasm-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Composite action to build and cache WASM dependencies (slang, spirv-tools)
name: 'Build WASM Deps'
description: 'Build and cache WASM dependencies (slang, spirv-tools) for the project.'
inputs:
build-artifacts-dir:
description: 'Directory to move built artifacts into.'
required: true
default: ./src
runs:
using: 'composite'
steps:
- name: Setup emsdk
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
if [ ! -d "emsdk" ]; then
git clone https://github.com/emscripten-core/emsdk.git
sed -i 's/\r$//' emsdk/emsdk emsdk/emsdk_env.sh
fi

- name: get slang head commit
shell: bash
run: |
if [ ! -d "slang-repo" ]; then
git clone https://github.com/shader-slang/slang.git slang-repo
fi
git -C slang-repo rev-parse HEAD > key.txt

- name: get spirv-tool head commit
shell: bash
run: |
if [ ! -d "spirv-tools" ]; then
git clone https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
pushd spirv-tools
git checkout vulkan-sdk-1.3.290.0
popd
fi
git -C spirv-tools rev-parse HEAD > key-spirv-tool.txt

- name: restore slang-wasm
id: cache_slang
uses: actions/cache/restore@v4
with:
path: |
./slang-wasm.wasm.gz
./slang-wasm.js
./slang-wasm.d.ts
key: ${{ hashFiles('key.txt') }}

- name: restore spirv-tools
id: cache_spirv_tools
uses: actions/cache/restore@v4
with:
path: |
./spirv-tools.wasm
./spirv-tools.js
./spirv-tools.d.ts
key: ${{ hashFiles('key-spirv-tool.txt') }}

- name: slang-wasm build
if: steps.cache_slang.outputs.cache-hit != 'true'
shell: bash
run: |
/bin/bash -x ./build_scripts/slang-wasm-build.sh

- name: save slang-wasm
if: steps.cache_slang.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
./slang-wasm.wasm.gz
./slang-wasm.js
./slang-wasm.d.ts
key: ${{ hashFiles('key.txt') }}

- name: spirv-tools-wasm build
if: steps.cache_spirv_tools.outputs.cache-hit != 'true'
shell: bash
run: |
/bin/bash -x ./build_scripts/spirv-tool-wasm-build.sh

- name: save spirv-tools-wasm
if: steps.cache_spirv_tools.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
./spirv-tools.wasm
./spirv-tools.js
./spirv-tools.d.ts
key: ${{ hashFiles('key-spirv-tool.txt') }}

- name: Move artifacts
shell: bash
run: |
mkdir -p ${{ inputs.build-artifacts-dir }}
mv ./slang-wasm.wasm.gz ./slang-wasm.js ./slang-wasm.d.ts ${{ inputs.build-artifacts-dir }}/
mv ./spirv-tools.wasm ./spirv-tools.js ./spirv-tools.d.ts ${{ inputs.build-artifacts-dir }}/
44 changes: 5 additions & 39 deletions .github/workflows/build-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand what exactly this workflow is doing.
Is this workflow only ran when user manually trigger it? If that is the case, do we really need to Upload export artifact step? Are any other jobs using the artifacts? Or it's just for people to download the artifacts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is designed so that people can get development dependencies without building them on their local computer. I put this as the recommended way to do it due to me having many problems trying to locally build the dependencies when I was starting development. It is only run when users trigger it, and the uploaded artifacts are only for them.

- name: get slang head commit
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
mkdir slang-repo
pushd slang-repo
git clone https://github.com/shader-slang/slang.git
popd
echo "$(git -C slang-repo/slang rev-parse HEAD)" >> key.txt

- name: get spirv-tool head commit
run: |
git clone https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
pushd spirv-tools
git checkout vulkan-sdk-1.3.290.0
popd
echo "$(git -C spirv-tools rev-parse HEAD)" >> key-spirv-tool.txt

- name: slang-wasm build
run: |
sed -i -e 's/\r$//' ./slang-wasm-build.sh
chmod +x ./slang-wasm-build.sh
./slang-wasm-build.sh

- name: spirv-tools-wasm build
run: |
sed -i -e 's/\r$//' ./spirv-tool-wasm-build.sh
chmod +x ./spirv-tool-wasm-build.sh
./spirv-tool-wasm-build.sh

- name: Cleanup workspace, move files, and build
run: |
rm -rf slang-repo
rm -rf emsdk
rm -rf spirv-tools
mkdir dependencies
mv ./slang-wasm.wasm.gz ./slang-wasm.js ./slang-wasm.d.ts ./dependencies/
mv ./spirv-tools.wasm ./spirv-tools.js ./spirv-tools.d.ts ./dependencies/
- name: Build and cache WASM dependencies
uses: ./.github/actions/build-wasm-deps
with:
build-artifacts-dir: ./dependencies

- name: Upload export artifact
uses: actions/upload-artifact@v4
with:
name: site-artifact
name: dependencies
path: ./dependencies/
compression-level: 1
81 changes: 4 additions & 77 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,82 +13,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: get emsdk
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
git clone https://github.com/emscripten-core/emsdk.git
sed -i 's/\r$//' emsdk/emsdk emsdk/emsdk_env.sh

- name: get slang head commit
run: |
git clone https://github.com/shader-slang/slang.git slang-repo
git -C slang-repo rev-parse HEAD > key.txt

- name: get spirv-tool head commit
run: |
git clone https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
pushd spirv-tools
git checkout vulkan-sdk-1.3.290.0
popd
git -C spirv-tools rev-parse HEAD > key-spirv-tool.txt

- name: restore slang-wasm
id: cache_slang
uses: actions/cache/restore@v4
- name: Build and cache WASM dependencies
uses: ./.github/actions/build-wasm-deps
with:
path: |
./slang-wasm.wasm.gz
./slang-wasm.js
./slang-wasm.d.ts
key: ${{hashFiles('key.txt')}}

- name: restore spirv-tools
id: cache_spirv_tools
uses: actions/cache/restore@v4
with:
path: |
./spirv-tools.wasm
./spirv-tools.js
./spirv-tools.d.ts
key: ${{hashFiles('key-spirv-tool.txt')}}

- name: slang-wasm build
if: steps.cache_slang.outputs.cache-hit != 'true'
run: |
sed -i 's/\r$//' ./slang-wasm-build.sh
/bin/bash -x ./slang-wasm-build.sh

- name: save slang-wasm
if: always() && steps.cache_slang.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
./slang-wasm.wasm.gz
./slang-wasm.js
./slang-wasm.d.ts
key: ${{hashFiles('key.txt')}}

- name: spirv-tools-wasm build
if: steps.cache_spirv_tools.outputs.cache-hit != 'true'
run: |
sed -i 's/\r$//' ./spirv-tool-wasm-build.sh
/bin/bash -x ./spirv-tool-wasm-build.sh

- name: save spirv-tools-wasm
if: always() && steps.cache_spirv_tools.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
./spirv-tools.wasm
./spirv-tools.js
./spirv-tools.d.ts
key: ${{hashFiles('key-spirv-tool.txt')}}
build-artifacts-dir: ./src

- name: Build
run: |
cp ./slang-wasm.wasm.gz ./slang-wasm.js ./slang-wasm.d.ts ./src/
cp ./spirv-tools.wasm ./spirv-tools.js ./spirv-tools.d.ts ./src/
npm install
npm run build

Expand All @@ -101,6 +32,7 @@ jobs:

- name: Smoke test
run: |
cp ./src/slang-wasm.wasm.gz ./src/slang-wasm.js ./src/slang-wasm.d.ts ./
pushd emsdk
/bin/sh ./emsdk install latest
/bin/sh ./emsdk activate latest
Expand All @@ -110,8 +42,3 @@ jobs:
cp src/slang-wasm.wasm ./
cp slang-repo/tests/wasm/smoke/smoke-test.js slang-repo/
node slang-repo/smoke-test.js src/slang/rand_float.slang computeMain

- name: Cleanup workspace
run: |
rm -rf slang-repo emsdk spirv-tools
rm ./slang-wasm.wasm.gz ./slang-wasm.js ./slang-wasm.d.ts ./spirv-tools.wasm ./spirv-tools.js ./spirv-tools.d.ts
75 changes: 4 additions & 71 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,80 +29,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: get slang head commit
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
git clone https://github.com/shader-slang/slang.git slang-repo
git -C slang-repo rev-parse HEAD > key.txt

- name: get spirv-tool head commit
run: |
git clone https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
pushd spirv-tools
git checkout vulkan-sdk-1.3.290.0
popd
git -C spirv-tools rev-parse HEAD > key-spirv-tool.txt

- name: restore slang-wasm
id: cache_slang
uses: actions/cache/restore@v4
with:
path: |
./slang-wasm.wasm.gz
./slang-wasm.js
./slang-wasm.d.ts
key: ${{hashFiles('key.txt')}}

- name: restore spirv-tools
id: cache_spirv_tools
uses: actions/cache/restore@v4
with:
path: |
./spirv-tools.wasm
./spirv-tools.js
./spirv-tools.d.ts
key: ${{hashFiles('key-spirv-tool.txt')}}

- name: slang-wasm build
if: steps.cache_slang.outputs.cache-hit != 'true'
run: |
sed -i 's/\r$//' ./slang-wasm-build.sh
/bin/bash -x ./slang-wasm-build.sh

- name: save slang-wasm
if: always() && steps.cache_slang.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
./slang-wasm.wasm.gz
./slang-wasm.js
./slang-wasm.d.ts
key: ${{hashFiles('key.txt')}}

- name: spirv-tools-wasm build
if: steps.cache_spirv_tools.outputs.cache-hit != 'true'
run: |
sed -i 's/\r$//' ./spirv-tool-wasm-build.sh
/bin/bash -x ./spirv-tool-wasm-build.sh

- name: save spirv-tools-wasm
if: always() && steps.cache_spirv_tools.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
- name: Build and cache WASM dependencies
uses: ./.github/actions/build-wasm-deps
with:
path: |
./spirv-tools.wasm
./spirv-tools.js
./spirv-tools.d.ts
key: ${{hashFiles('key-spirv-tool.txt')}}
build-artifacts-dir: ./src

- name: Cleanup workspace, move files, and build
- name: Build
run: |
rm -rf slang-repo
rm -rf emsdk
rm -rf spirv-tools
mv ./slang-wasm.wasm.gz ./slang-wasm.js ./slang-wasm.d.ts ./src/
mv ./spirv-tools.wasm ./spirv-tools.js ./spirv-tools.d.ts ./src/
npm install
npm run build

Expand Down
1 change: 1 addition & 0 deletions build_scripts/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
13 changes: 0 additions & 13 deletions slang-wasm-build.sh → build_scripts/slang-wasm-build.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,9 @@ pushd emsdk
popd

echo "[$(date)] Sync slang repo ..."
if [ -d slang-repo ]
then
echo "Remove stale slang-repo dir"
rm -rf slang-repo
fi

if [ ! -d slang-repo ]
then
echo "[$(date)] Cloning slang repository into slang-repo..."
git clone https://github.com/shader-slang/slang.git slang-repo
if [ $? -ne 0 ]
then
echo "Error: Failed to clone slang repository"
exit 1
fi
echo "[$(date)] Successfully cloned slang repository"
fi

pushd slang-repo
Expand Down
File renamed without changes.