Skip to content

Commit

Permalink
Reduce CI times (#637)
Browse files Browse the repository at this point in the history
* Reduce CI times

* Reduce RUSTUP_UNPACK_RAM

* Set RUSTUP_IO_THREADS=1

* Include EmbarkStudios/ash-molten#57 This fixes github API rate limit errors

* Inline test.sh to show timings for each step and generally have a less-jank UI
  • Loading branch information
khyperia committed May 31, 2021
1 parent 6019f39 commit fcf6ee7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 76 deletions.
5 changes: 0 additions & 5 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
[build]
# Currently there's an issue where the Example CPU runner fails without
# `-C prefer-dynamic`.
rustflags = "-C prefer-dynamic"

[alias]
compiletest = "run --release -p compiletests --"
36 changes: 32 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jobs:
runs-on: ${{ matrix.os }}
env:
spirv_tools_version: "20200928"
RUSTUP_UNPACK_RAM: "104857600"
RUSTUP_UNPACK_RAM: "26214400"
RUSTUP_IO_THREADS: "1"
steps:
- uses: actions/checkout@v2
# Ubuntu does have `brew install spirv-tools`, but it installs from
Expand Down Expand Up @@ -51,14 +52,38 @@ jobs:
- if: ${{ runner.os == 'Windows' }}
# Runs separately to add spir-v tools to Powershell's Path.
run: echo "$HOME/spirv-tools/install/bin" >> $env:GITHUB_PATH
# cargo version is a random command that forces the installation of rust-toolchain
- name: install rust-toolchain
run: cargo version
# Fetch dependencies in a separate step to clearly show how long each part
# of the testing takes
- name: cargo fetch --locked
run: cargo fetch --locked --target ${{ matrix.target }}
- name: Run tests

# Core crates
# Compiled in --release because cargo compiletest would otherwise compile in release again.
- name: rustc_codegen_spirv build
if: ${{ matrix.target != 'aarch64-linux-android' }}
shell: bash
run: .github/workflows/test.sh ${{ runner.os }}
run: cargo test -p rustc_codegen_spirv --release --no-default-features --features "use-installed-tools" --no-run

- name: rustc_codegen_spirv test
if: ${{ matrix.target != 'aarch64-linux-android' }}
run: cargo test -p rustc_codegen_spirv --release --no-default-features --features "use-installed-tools"

- name: compiletest
if: ${{ matrix.target != 'aarch64-linux-android' }}
run: cargo run -p compiletests --release --no-default-features --features "use-installed-tools" -- --target-env vulkan1.1,spv1.3

# Examples
- name: cargo check examples
if: ${{ matrix.target != 'aarch64-linux-android' }}
run: cargo check -p example-runner-ash -p example-runner-wgpu -p example-runner-cpu -p compute-shader -p mouse-shader -p simplest-shader -p sky-shader --no-default-features --features "use-installed-tools"

- name: build example shaders
if: ${{ matrix.target != 'aarch64-linux-android' }}
env:
OUT_DIR: "target/tmp"
run: cargo run -p example-runner-wgpu-builder --release --no-default-features --features "use-installed-tools"

- name: Build WGPU Example for Android
if: ${{ matrix.target == 'aarch64-linux-android' }}
Expand Down Expand Up @@ -95,6 +120,9 @@ jobs:
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
- name: Install rustup components
run: rustup component add rustfmt clippy
# cargo version is a random command that forces the installation of rust-toolchain
- name: install rust-toolchain
run: cargo version
- name: cargo fetch --locked
run: cargo fetch --locked
- name: Rustfmt
Expand Down
54 changes: 0 additions & 54 deletions .github/workflows/test.sh

This file was deleted.

3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/runners/ash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ shared = { path = "../../shaders/shared" }
spirv-builder = { path = "../../../crates/spirv-builder", default-features = false }

[target.'cfg(target_os = "macos")'.dependencies]
ash-molten = { version = "0.9", features = ["pre-built"] }
ash-molten = { git = "https://github.com/EmbarkStudios/ash-molten.git", rev = "fea270b0c9186b8a45e62215314204f4c16a57b6", features = ["pre-built"] }
5 changes: 1 addition & 4 deletions examples/runners/wgpu/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ use std::path::PathBuf;
fn main() -> Result<(), Box<dyn Error>> {
let target_os = std::env::var("CARGO_CFG_TARGET_OS")?;
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH")?;
// Always build on CI to make sure the shaders can still build
let is_on_ci = std::env::var("CI");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS");
println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH");
println!("cargo:rerun-if-env-changed=CI");
// While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in
// build.rs. So, export it to crate compilation as well.
let profile = env::var("PROFILE").unwrap();
println!("cargo:rustc-env=PROFILE={}", profile);
if target_os != "android" && target_arch != "wasm32" && is_on_ci.is_err() {
if target_os != "android" && target_arch != "wasm32" {
return Ok(());
}
let mut dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
Expand Down
15 changes: 9 additions & 6 deletions examples/runners/wgpu/builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,32 @@ use std::fs;
use std::path::Path;

fn build_shader(
path_to_create: &str,
path_to_crate: &str,
codegen_names: bool,
caps: &[Capability],
) -> Result<(), Box<dyn Error>> {
let mut builder = SpirvBuilder::new(path_to_create, "spirv-unknown-vulkan1.0");
let builder_dir = &Path::new(env!("CARGO_MANIFEST_DIR"));
let path_to_crate = builder_dir.join(path_to_crate);
let mut builder = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.0");
for &cap in caps {
builder = builder.capability(cap);
}
let result = builder.build()?;
if codegen_names {
let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("entry_points.rs");
fs::create_dir_all(&out_dir).unwrap();
fs::write(&dest_path, result.codegen_entry_point_strings()).unwrap();
}
Ok(())
}

fn main() -> Result<(), Box<dyn Error>> {
build_shader("../../shaders/sky-shader", true, &[])?;
build_shader("../../shaders/simplest-shader", false, &[])?;
build_shader("../../shaders/compute-shader", false, &[])?;
build_shader("../../../shaders/sky-shader", true, &[])?;
build_shader("../../../shaders/simplest-shader", false, &[])?;
build_shader("../../../shaders/compute-shader", false, &[])?;
build_shader(
"../../shaders/mouse-shader",
"../../../shaders/mouse-shader",
false,
&[Capability::Int8, Capability::Int16, Capability::Int64],
)?;
Expand Down

0 comments on commit fcf6ee7

Please sign in to comment.