Add Rust CI #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test: | |
| name: Test Rust Shaders - ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| name: Ubuntu | |
| - os: windows-latest | |
| name: Windows | |
| - os: macos-latest | |
| name: macOS-MoltenVK | |
| use_moltenvk: true | |
| - os: macos-latest | |
| name: macOS-SwiftShader | |
| use_swiftshader: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: "recursive" | |
| - name: Install Vulkan SDK | |
| uses: jakoch/[email protected] | |
| with: | |
| vulkan_version: 1.3.268.0 | |
| optional_components: com.lunarg.vulkan.debug | |
| install_runtime: true | |
| cache: true | |
| stripdown: true | |
| - if: ${{ runner.os == 'Linux' }} | |
| name: Install xvfb, llvmpipe and lavapipe | |
| run: | | |
| sudo apt-get update -y -qq | |
| sudo add-apt-repository ppa:kisak/turtle -y | |
| sudo apt-get update | |
| sudo apt install -y xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers | |
| - if: ${{ matrix.use_moltenvk == true }} | |
| name: Setup MoltenVK on macOS | |
| run: | | |
| # MoltenVK should be installed with the Vulkan SDK | |
| # Find and set the ICD path | |
| VULKAN_SDK_VERSION=$(ls -1 $HOME/VulkanSDK | head -n 1) | |
| echo "VK_ICD_FILENAMES=$HOME/VulkanSDK/$VULKAN_SDK_VERSION/macOS/share/vulkan/icd.d/MoltenVK_icd.json" >> $GITHUB_ENV | |
| - if: ${{ matrix.use_swiftshader == true }} | |
| name: Install SwiftShader on macOS | |
| run: | | |
| # Based on https://github.com/GDRETools/gdsdecomp/blob/master/.github/actions/install-swiftshader/action.yml | |
| git clone https://github.com/google/swiftshader.git | |
| cd swiftshader | |
| mkdir build && cd build | |
| cmake -DSWIFTSHADER_BUILD_TESTS=OFF -DSWIFTSHADER_BUILD_SAMPLES=OFF .. | |
| cmake --build . --config Release | |
| sudo mkdir -p /usr/local/share/vulkan/icd.d | |
| sudo cp Darwin/vk_swiftshader_icd.json /usr/local/share/vulkan/icd.d/ | |
| sudo mkdir -p /usr/local/lib | |
| sudo cp Darwin/libvk_swiftshader.dylib /usr/local/lib/ | |
| # Set environment variable for SwiftShader ICD | |
| echo "VK_ICD_FILENAMES=/usr/local/share/vulkan/icd.d/vk_swiftshader_icd.json" >> $GITHUB_ENV | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rust-src, rustc-dev, llvm-tools | |
| - name: Install cargo-gpu | |
| run: cargo install --git https://github.com/rust-gpu/cargo-gpu cargo-gpu | |
| - name: Cache cargo registry | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Compile shaders to SPIR-V | |
| working-directory: shaders/rust | |
| run: python3 compileshaders.py | |
| - name: Verify no uncommitted changes | |
| run: | | |
| # Check if there are any changes to tracked files | |
| if ! git diff --exit-code; then | |
| echo "Error: Generated SPIR-V files differ from checked-in versions" | |
| echo "Please run 'python3 compileshaders.py' locally and commit the changes" | |
| git diff --name-only | |
| exit 1 | |
| fi | |
| # Check for untracked files | |
| if [ -n "$(git ls-files --others --exclude-standard)" ]; then | |
| echo "Error: New untracked files were generated" | |
| echo "Please add these files to git or update .gitignore:" | |
| git ls-files --others --exclude-standard | |
| exit 1 | |
| fi |