Skip to content

Commit

Permalink
Unify CI and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Jul 4, 2021
1 parent e2bcb72 commit ab41b5f
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 166 deletions.
273 changes: 135 additions & 138 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,173 +8,170 @@ on:
branches-ignore: [staging.tmp]

jobs:
ios_build:
name: iOS Stable
runs-on: macos-10.15
env:
TARGET: aarch64-apple-ios
steps:
- uses: actions/checkout@v2
- run: rustup component add clippy
- run: rustup target add ${{ env.TARGET }}
- run: cargo clippy --target ${{ env.TARGET }}

android_build:
name: Android Stable
runs-on: ubuntu-latest
env:
TARGET: aarch64-linux-android
PKG_CONFIG_ALLOW_CROSS: 1
steps:
- uses: actions/checkout@v2
- run: echo "$ANDROID_HOME/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
- run: rustup component add clippy
- run: rustup target add ${{ env.TARGET }}
- run: cargo clippy --target ${{ env.TARGET }}
- name: Additional core features
run: cargo check --manifest-path wgpu-core/Cargo.toml --features trace --target ${{ env.TARGET }}

wasm:
name: Web Assembly
runs-on: ubuntu-latest
env:
RUSTFLAGS: --cfg=web_sys_unstable_apis
steps:
- uses: actions/checkout@v2
- run: rustup target add wasm32-unknown-unknown
- name: Check WebGPU
run: cargo check --package wgpu --examples --target=wasm32-unknown-unknown
# disable until hal/Gles backend is setup
# - name: Check WebGL
# run: cargo check --all-targets --target=wasm32-unknown-unknown --features webgl

build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-10.15, ubuntu-20.04, windows-2019]
channel: [stable, nightly]
include:
- name: MacOS Stable
# Windows
- name: Windows x86_64
os: windows-2019
channel: stable
target: x86_64-pc-windows-msvc
kind: compile

# MacOS

# Mac has no software runners, so don't run tests
- name: MacOS x86_64
os: macos-10.15
prepare_command:
clippy_params:
additional_core_features:
additional_player_features: winit
wrapper_features: trace
- name: MacOS Nightly
channel: stable
target: x86_64-apple-darwin
kind: compile


# IOS
- name: IOS Nightly x86_64
os: macos-10.15
channel: nightly
prepare_command:
clippy_params:
additional_core_features:
additional_player_features:
wrapper_features:
- name: Ubuntu Stable
channel: stable
target: aarch64-apple-ios
kind: compile


# Linux
- name: Linux x86_64
os: ubuntu-20.04
channel: stable
prepare_command:
clippy_params: --examples --all
additional_core_features: trace,serial-pass
additional_player_features: winit
wrapper_features: spirv,replay
- name: Ubuntu Nightly
target: x86_64-unknown-linux-gnu
kind: test

- name: Linux Nightly x86_64
os: ubuntu-20.04
channel: nightly
prepare_command: |
echo "Installing Vulkan"
sudo apt-get update -y -qq
sudo add-apt-repository ppa:ubuntu-x-swat/updates -y
sudo apt-get update
sudo apt install -y libxcb-xfixes0-dev mesa-vulkan-drivers
clippy_params:
additional_core_features: serial-pass
additional_player_features:
wrapper_features:
- name: Windows Stable
os: windows-2019
target: x86_64-unknown-linux-gnu
kind: compile


# Android
- name: Android aarch64
os: ubuntu-20.04
channel: stable
prepare_command: rustup default stable-msvc
clippy_params:
additional_core_features:
additional_player_features:
wrapper_features:
- name: Windows Nightly
os: windows-2019
channel: nightly
prepare_command: rustup default nightly-msvc
clippy_params:
additional_core_features:
additional_player_features:
wrapper_features:
target: aarch64-linux-android
kind: compile


# WebGPU/WebGL
- name: WebAssembly
os: ubuntu-20.04
channel: stable
target: wasm32-unknown-unknown
kind: webgl

name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}

env:
PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work
RUSTFLAGS: --cfg=web_sys_unstable_apis

steps:
- uses: actions/checkout@v2
- name: Install latest nightly
- name: checkout repo
uses: actions/checkout@v2

- name: install rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.channel }}
target: ${{ matrix.target }}
override: true
profile: minimal
components: clippy

- if: matrix.clippy_params != ''
run: rustup component add clippy
- name: add android apk to path
if: matrix.os == 'ubuntu-20.04' && matrix.target == 'aarch64-linux-android'
run: |
echo "$ANDROID_HOME/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
# prepare #
- if: matrix.prepare_command != ''
run: ${{ matrix.prepare_command }}
- name: install llvmpipe and lavapipe
if: matrix.os == 'ubuntu-20.04' && matrix.kind == 'test'
run: |
echo "Installing Vulkan"
sudo apt-get update -y -qq
sudo add-apt-repository ppa:ubuntu-x-swat/updates -y
sudo apt-get update
sudo apt install -y libxcb-xfixes0-dev mesa-vulkan-drivers
# regular build #
- name: load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.name }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.name }}-cargo-
# build
- if: matrix.additional_core_features != ''
run: cargo check --manifest-path wgpu-core/Cargo.toml --features ${{ matrix.additional_core_features }}
# This is separate for now because webgl isn't hooked up so we can't compile wgpu-core for wasm
- name: check web
if: matrix.kind == 'webgl'
run: |
cargo clippy --target ${{ matrix.target }} -p wgpu -- -D warnings
- if: matrix.additional_player_features != ''
run: cargo check --manifest-path player/Cargo.toml --features ${{ matrix.additional_player_features }}
- run: cargo check --manifest-path wgpu/Cargo.toml --examples --features ${{ matrix.wrapper_features }},

# clippy
- if: matrix.clippy_params != ''
run: cargo clippy ${{ matrix.clippy_params }}
- name: check native stable (fatal warnings)
if: (matrix.kind == 'compile' || matrix.kind == 'test') && matrix.channel == 'stable'
run: |
# check with no features
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player -- -D warnings
- if: matrix.channel == 'nightly'
run: cargo test -p wgpu-core -- --nocapture
- if: matrix.channel == 'nightly'
run: cargo run --bin wgpu-info -- cargo test -p wgpu -- --nocapture --test-threads=1 # GLES is currently non-multithreadable
# check with all features
# explicitly don't mention wgpu-hal so that --all-features don't apply to it
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --examples --tests --all-features -- -D warnings
- name: check native nightly (non-fatal warnings)
if: (matrix.kind == 'compile' || matrix.kind == 'test') && matrix.channel != 'stable'
run: |
# check with no features
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player
docs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
continue-on-error: true
- name: cargo doc
run: cargo --version; cargo doc --no-deps
continue-on-error: true

lint:
name: Clippy
# check with all features
# explicitly don't mention wgpu-hal so that --all-features don't apply to it
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-core -p wgpu-info -p player --examples --tests --all-features
- name: build tests
if: matrix.kind == 'test'
run: |
cargo build --target ${{ matrix.target }} --bin wgpu-info
cargo build --target ${{ matrix.target }} --tests -p player
cargo build --target ${{ matrix.target }} --examples --tests -p wgpu
# - name: tests
# if: matrix.kind == 'test'
# run: |
# # run wgpu-info
# cargo run --target ${{ matrix.target }} --bin wgpu-info

# # run player tests
# cargo test --target ${{ matrix.target }} -p player -- --nocapture

# # run coretests
# cargo run --target ${{ matrix.target }} --bin wgpu-info -- cargo test --target ${{ matrix.target }} -p wgpu -- --nocapture --test-threads=1 # GLES is currently non-multithreadable

fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: checkout repo
uses: actions/checkout@v2

- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
components: rustfmt

- name: run rustfmt
run: |
cargo fmt -- --check
18 changes: 8 additions & 10 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
status = [
"iOS Stable",
"MacOS Stable",
"MacOS Nightly",
"Android Stable",
"Ubuntu Stable",
"Ubuntu Nightly",
"Windows Stable",
"Windows Nightly",
"Web Assembly",
#"Clippy",
"Windows x86_64",
"MacOS x86_64",
"IOS x86_64",
"Linux x86_64",
"Linux Nightly x86_64",
"Android aarch64",
"WebAssembly",
"Format",
]
9 changes: 9 additions & 0 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ fn check_limits(requested: &wgt::Limits, allowed: &wgt::Limits) -> Vec<FailedLim
failed
}

#[test]
fn downlevel_default_limits_less_than_default_limits() {
let res = check_limits(&wgt::Limits::downlevel_defaults(), &wgt::Limits::default());
assert(
res.is_empty(),
"Downlevel limits are greater than default limits",
)
}

pub struct Instance {
#[allow(dead_code)]
name: String,
Expand Down
12 changes: 6 additions & 6 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ impl super::Adapter {
gl.get_parameter_i32(glow::MAX_VERTEX_UNIFORM_BLOCKS)
.min(gl.get_parameter_i32(glow::MAX_FRAGMENT_UNIFORM_BLOCKS)) as u32;
let max_storage_buffers_per_shader_stage = if vertex_shader_storage_blocks > 0 {
vertex_shader_storage_blocks.min(fragment_shader_storage_blocks) as u32
vertex_shader_storage_blocks.min(fragment_shader_storage_blocks)
} else {
fragment_shader_storage_blocks
};
} as u32;

let max_storage_textures_per_shader_stage =
gl.get_parameter_i32(glow::MAX_FRAGMENT_IMAGE_UNIFORMS) as u32;
Expand All @@ -253,10 +253,10 @@ impl super::Adapter {
max_uniform_buffer_binding_size: gl.get_parameter_i32(glow::MAX_UNIFORM_BLOCK_SIZE)
as u32,
max_storage_buffer_binding_size: if ver >= (3, 1) {
gl.get_parameter_i32(glow::MAX_SHADER_STORAGE_BLOCK_SIZE) as u32
gl.get_parameter_i32(glow::MAX_SHADER_STORAGE_BLOCK_SIZE)
} else {
0
},
} as u32,
max_vertex_buffers: gl.get_parameter_i32(glow::MAX_VERTEX_ATTRIB_BINDINGS) as u32,
max_vertex_attributes: (gl.get_parameter_i32(glow::MAX_VERTEX_ATTRIBS) as u32)
.min(super::MAX_VERTEX_ATTRIBUTES as u32),
Expand All @@ -280,7 +280,7 @@ impl super::Adapter {
ver >= (3, 1),
);

let downlevel_limits = wgt::DownlevelLimits {};
let downlevel_defaults = wgt::DownlevelLimits {};

Some(crate::ExposedAdapter {
adapter: super::Adapter {
Expand All @@ -296,7 +296,7 @@ impl super::Adapter {
limits,
downlevel: wgt::DownlevelCapabilities {
flags: downlevel_flags,
limits: downlevel_limits,
limits: downlevel_defaults,
shader_model: wgt::ShaderModel::Sm5,
},
alignments: crate::Alignments {
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,9 @@ impl crate::Instance<super::Api> for Instance {
) -> Result<Surface, crate::InstanceError> {
use raw_window_handle::RawWindowHandle as Rwh;

#[cfg_attr(target_os = "android", allow(unused_mut))]
let mut inner = self.inner.lock();
#[cfg_attr(target_os = "android", allow(unused_mut))]
let mut wl_window = None;
#[cfg(not(any(target_os = "android", target_os = "macos")))]
let (mut temp_xlib_handle, mut temp_xcb_handle);
Expand Down
Loading

0 comments on commit ab41b5f

Please sign in to comment.