From 682e4b769f585360b7aed8647c95ee07091e2673 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 16 Jun 2022 16:00:13 -0700 Subject: [PATCH] Shader compilation in GitHub Actions This patch sets up very basic CI (right now just cargo fmt) but more importantly compiles shaders in a GitHub Action. Any PR to branches other than main will run shader compilation. Any push to the dev branch will run shader compilation and then merge to main. Closes #177 --- .github/actions/shader/action.yml | 22 ++++++++++++++++++ .github/workflows/ci.yml | 27 ++++++++++++++++++++++ .github/workflows/push-shader.yml | 37 +++++++++++++++++++++++++++++++ .github/workflows/shader.yml | 13 +++++++++++ 4 files changed, 99 insertions(+) create mode 100644 .github/actions/shader/action.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/push-shader.yml create mode 100644 .github/workflows/shader.yml diff --git a/.github/actions/shader/action.yml b/.github/actions/shader/action.yml new file mode 100644 index 0000000..e656395 --- /dev/null +++ b/.github/actions/shader/action.yml @@ -0,0 +1,22 @@ +name: compile shaders + +runs: + using: 'composite' + steps: + - uses: seanmiddleditch/gha-setup-ninja@master + + - name: setup SPIRV tools + # consider install-vulkan-sdk instead + uses: humbletim/setup-vulkan-sdk@v1.2.0 + with: + vulkan-query-version: 1.3.204.0 + vulkan-components: Glslang, SPIRV-Cross + vulkan-use-cache: true + + - name: install DXC + uses: napokue/setup-dxc@v1.0.0 + + - name: run shader compilers + run: ninja + shell: pwsh + working-directory: piet-gpu/shader diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0996920 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +on: + push: + branches: + - main + - dev + pull_request: + +jobs: + rustfmt: + runs-on: ubuntu-latest + name: cargo fmt + steps: + - uses: actions/checkout@v2 + + - name: install stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + components: rustfmt + override: true + + - name: cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check diff --git a/.github/workflows/push-shader.yml b/.github/workflows/push-shader.yml new file mode 100644 index 0000000..bf16952 --- /dev/null +++ b/.github/workflows/push-shader.yml @@ -0,0 +1,37 @@ +on: + push: + branches: + - dev + +jobs: + push-shaders: + runs-on: windows-latest + name: compile shaders and push to main + steps: + - uses: actions/checkout@v3 + with: + # need history to make the merge work + # possibly we can optimize this and set + # allow-unrelated-histories on merge + fetch-depth: 0 + - name: prepare repo for compilation + run: | + git fetch origin main + git switch main + git merge dev -m "merge from dev branch" + git rm -r --ignore-unmatch piet-gpu/shader/gen + mkdir piet-gpu/shader/gen + - uses: ./.github/actions/shader + - name: commit + id: commit + continue-on-error: true + run: | + git add piet-gpu/shader/gen + git config user.name "Commit by GitHub Action" + git config user.email "nobody@example.com" + git commit -m "commit compiled shaders" + - name: push + if: steps.commit.outcome == 'success' + run: | + git show-ref + git push origin main diff --git a/.github/workflows/shader.yml b/.github/workflows/shader.yml new file mode 100644 index 0000000..205cd47 --- /dev/null +++ b/.github/workflows/shader.yml @@ -0,0 +1,13 @@ +on: + pull_request: + branches-ignore: + - main + +jobs: + push-shaders: + runs-on: windows-latest + name: compile shaders + steps: + - uses: actions/checkout@v3 + - run: mkdir piet-gpu/shader/gen + - uses: ./.github/actions/shader