Reduce CI times (#637)

* Reduce CI times

* Reduce RUSTUP_UNPACK_RAM

* Set RUSTUP_IO_THREADS=1

* Include https://github.com/EmbarkStudios/ash-molten/pull/57 This fixes github API rate limit errors

* Inline test.sh to show timings for each step and generally have a less-jank UI
This commit is contained in:
Ashley Hauck 2021-05-31 11:17:34 +02:00 committed by GitHub
parent 6019f391ec
commit fcf6ee76c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 76 deletions

View File

@ -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 --"

View File

@ -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
@ -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' }}
@ -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

View File

@ -1,54 +0,0 @@
#!/usr/bin/env bash
set -e
if [[ -z "${CI}" ]]; then
FEAT="use-compiled-tools"
else
FEAT="use-installed-tools"
fi
os=$1
function cargo_test() {
echo ::group::"$1 build"
cargo test \
--manifest-path "$1/Cargo.toml" \
--no-default-features \
--features "$FEAT" \
--no-run
echo ::endgroup::
echo ::group::"$1 test"
cargo test \
--manifest-path "$1/Cargo.toml" \
--no-default-features \
--features "$FEAT"
echo ::endgroup::
}
function cargo_test_no_features() {
echo ::group::"$1 build"
cargo test --manifest-path "$1/Cargo.toml" --no-run
echo ::endgroup::
echo ::group::"$1 test"
cargo test --manifest-path "$1/Cargo.toml"
echo ::endgroup::
}
# Core crates
cargo_test crates/rustc_codegen_spirv
# Examples
# See: https://github.com/EmbarkStudios/rust-gpu/issues/84
if [[ "$os" != "macOS" ]]; then
cargo_test examples/runners/ash
fi
cargo_test examples/runners/wgpu
cargo_test_no_features examples/runners/cpu
cargo_test_no_features examples/shaders/sky-shader
cargo_test_no_features examples/shaders/simplest-shader
cargo compiletest --target-env vulkan1.1,spv1.3

3
Cargo.lock generated
View File

@ -93,8 +93,7 @@ dependencies = [
[[package]]
name = "ash-molten"
version = "0.9.0+1.1.2-f28ab1c"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c4d72ca0f3c4037e64e0ee622907177b6594a6bce03efbeb91fcca6e9bd900a"
source = "git+https://github.com/EmbarkStudios/ash-molten.git?rev=fea270b0c9186b8a45e62215314204f4c16a57b6#fea270b0c9186b8a45e62215314204f4c16a57b6"
dependencies = [
"anyhow",
"ash 0.32.1",

View File

@ -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"] }

View File

@ -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());

View File

@ -5,11 +5,13 @@ 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);
}
@ -17,17 +19,18 @@ fn build_shader(
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],
)?;