wgpu/.github/workflows/ci.yml

511 lines
14 KiB
YAML
Raw Normal View History

2020-04-22 13:03:26 +00:00
name: CI
on:
push:
2022-10-15 02:55:36 +00:00
branches: ["*"]
tags: [v0.*]
2020-04-22 13:03:26 +00:00
pull_request:
2023-02-09 00:52:25 +00:00
merge_group:
2020-04-22 13:03:26 +00:00
2021-09-14 01:27:50 +00:00
env:
2023-02-09 15:33:53 +00:00
CARGO_INCREMENTAL: false
CARGO_TERM_COLOR: always
RUST_LOG: info
2023-02-09 15:33:53 +00:00
RUST_BACKTRACE: full
# This is the MSRV used by `wgpu` itself and all surrounding infrastructure.
REPO_MSRV: "1.70"
# This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates,
# to ensure that they can be used with firefox.
CORE_MSRV: "1.65"
2022-10-15 02:55:36 +00:00
PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work
RUSTFLAGS: --cfg=web_sys_unstable_apis -D warnings
RUSTDOCFLAGS: -Dwarnings
CACHE_SUFFIX: c # cache busting
2021-09-14 01:27:50 +00:00
2021-12-03 16:43:22 +00:00
# We distinguish the following kinds of builds:
2022-10-15 02:55:36 +00:00
# - native: build for the same target as we compile on
2021-12-03 16:43:22 +00:00
# - web: build for the Web
2022-01-25 10:35:45 +00:00
# - em: build for the Emscripten
2021-12-03 16:43:22 +00:00
2022-10-15 02:55:36 +00:00
# For build time and size optimization we disable debug
# entirely on clippy jobs and reduce it to line-numbers
# only for ones where we run tests.
#
# Additionally, we disable incremental builds entirely
2022-10-15 02:55:36 +00:00
# as our caching system doesn't actually cache our crates.
# It adds overhead to the build and another point of failure.
2020-04-22 13:03:26 +00:00
jobs:
check:
2020-04-22 13:03:26 +00:00
strategy:
fail-fast: false
matrix:
include:
2021-07-04 02:10:10 +00:00
# Windows
- name: Windows x86_64
2022-10-15 02:55:36 +00:00
os: windows-2022
2021-09-14 01:27:50 +00:00
target: x86_64-pc-windows-msvc
2022-10-15 02:55:36 +00:00
kind: native
2021-07-04 02:10:10 +00:00
# MacOS
- name: MacOS x86_64
2022-10-15 02:55:36 +00:00
os: macos-12
2021-07-04 02:10:10 +00:00
target: x86_64-apple-darwin
2022-10-15 02:55:36 +00:00
kind: native
- name: MacOS aarch64
2022-10-15 02:55:36 +00:00
os: macos-12
target: aarch64-apple-darwin
2022-10-15 02:55:36 +00:00
kind: native
2021-07-04 02:10:10 +00:00
# IOS
- name: IOS aarch64
2022-10-15 02:55:36 +00:00
os: macos-12
2021-07-04 02:10:10 +00:00
target: aarch64-apple-ios
2022-10-15 02:55:36 +00:00
kind: native
2021-07-04 02:10:10 +00:00
# Linux
- name: Linux x86_64
2022-10-15 02:55:36 +00:00
os: ubuntu-22.04
2021-07-04 02:10:10 +00:00
target: x86_64-unknown-linux-gnu
2022-10-15 02:55:36 +00:00
kind: native
2021-07-04 02:10:10 +00:00
- name: Linux aarch64
2022-10-15 02:55:36 +00:00
os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
2022-10-15 02:55:36 +00:00
kind: native
2021-07-04 02:10:10 +00:00
# Android
- name: Android aarch64
2022-10-15 02:55:36 +00:00
os: ubuntu-22.04
2021-07-04 02:10:10 +00:00
target: aarch64-linux-android
2022-10-15 02:55:36 +00:00
kind: native
2021-07-04 02:10:10 +00:00
# WebGPU/WebGL
- name: WebAssembly
2022-10-15 02:55:36 +00:00
os: ubuntu-22.04
2021-07-04 02:10:10 +00:00
target: wasm32-unknown-unknown
2021-12-03 16:43:22 +00:00
kind: web
2021-07-04 02:10:10 +00:00
2022-01-25 10:35:45 +00:00
- name: Emscripten
2022-10-15 02:55:36 +00:00
os: ubuntu-22.04
2022-01-25 10:35:45 +00:00
target: wasm32-unknown-emscripten
kind: em
2022-10-15 02:55:36 +00:00
name: Clippy ${{ matrix.name }}
2021-07-04 02:10:10 +00:00
runs-on: ${{ matrix.os }}
2020-04-22 13:03:26 +00:00
steps:
2021-07-04 02:10:10 +00:00
- name: checkout repo
uses: actions/checkout@v4
2021-07-04 02:10:10 +00:00
- name: Install Repo MSRV toolchain
2023-02-09 15:33:53 +00:00
run: |
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }}
rustup override set ${{ env.REPO_MSRV }}
cargo -V
2021-07-03 06:24:38 +00:00
2022-10-15 02:55:36 +00:00
- name: disable debug
shell: bash
run: |
mkdir -p .cargo
echo """
[profile.dev]
debug = false" >> .cargo/config.toml
2021-12-03 15:37:26 +00:00
2021-09-14 01:27:50 +00:00
- name: caching
2022-10-15 02:55:36 +00:00
uses: Swatinem/rust-cache@v2
2021-09-14 01:27:50 +00:00
with:
2022-10-15 02:55:36 +00:00
key: clippy-${{ matrix.target }}-${{ matrix.kind }}-${{ env.CACHE_SUFFIX }}
- name: (linux aarch64) install aarch64-linux-gnu g++
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
set -e
sudo apt-get update -y -qq
sudo apt-get install g++-aarch64-linux-gnu
- name: (android) add android apk to path
2022-10-15 02:55:36 +00:00
if: matrix.target == 'aarch64-linux-android'
2021-07-04 02:10:10 +00:00
run: |
# clang++ will be detected correctly by CC from path
echo "$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
# the android sdk doesn't use the conventional name for ar, so explicitly set it.
echo "AR_aarch64_linux_android=llvm-ar" >> "$GITHUB_ENV"
2021-07-03 06:24:38 +00:00
2021-07-04 02:10:10 +00:00
- name: check web
2021-12-03 16:43:22 +00:00
if: matrix.kind == 'web'
2022-10-15 02:55:36 +00:00
shell: bash
2021-07-04 02:10:10 +00:00
run: |
2022-10-15 02:55:36 +00:00
set -e
2022-10-15 02:55:36 +00:00
# build for WebGPU
cargo clippy --target ${{ matrix.target }} --tests --features glsl,spirv,fragile-send-sync-non-atomic-wasm
cargo clippy --target ${{ matrix.target }} --tests --features glsl,spirv
cargo doc --target ${{ matrix.target }} --no-deps --features glsl,spirv
2021-07-13 03:15:47 +00:00
# all features
cargo clippy --target ${{ matrix.target }} --tests --all-features
cargo doc --target ${{ matrix.target }} --no-deps --all-features
2022-01-25 10:35:45 +00:00
- name: check em
if: matrix.kind == 'em'
2022-10-15 02:55:36 +00:00
shell: bash
2022-01-25 10:35:45 +00:00
run: |
2022-10-15 02:55:36 +00:00
set -e
# build for Emscripten
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-hal --no-default-features
# Don't check samples since we use winit in our samples which has dropped support for Emscripten.
2022-01-25 10:35:45 +00:00
# all features
cargo clippy --target ${{ matrix.target }} -p wgpu-hal --all-features
cargo clippy --target ${{ matrix.target }} -p wgpu --all-features
2021-09-14 01:27:50 +00:00
- name: check native
2022-10-15 02:55:36 +00:00
if: matrix.kind == 'native'
shell: bash
2021-07-04 02:10:10 +00:00
run: |
2022-10-15 02:55:36 +00:00
set -e
2021-07-04 02:10:10 +00:00
# check with no features
cargo clippy --target ${{ matrix.target }} --no-default-features
2021-07-03 06:24:38 +00:00
# Check with all features.
cargo clippy --target ${{ matrix.target }} --tests --all-features
2021-06-22 05:38:41 +00:00
2021-07-13 03:15:47 +00:00
# build docs
cargo doc --target ${{ matrix.target }} --all-features --no-deps
2021-07-13 03:15:47 +00:00
# We run minimal checks on the MSRV of the core crates, ensuring that
# its dependency tree does not cause issues for firefox.
#
# We don't test all platforms, just ones with different dependency stacks.
check-core-msrv:
strategy:
fail-fast: false
matrix:
include:
# Windows
- name: Windows x86_64
os: windows-2022
target: x86_64-pc-windows-msvc
# MacOS
- name: MacOS x86_64
os: macos-12
target: x86_64-apple-darwin
# Linux
- name: Linux x86_64
os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
name: MSRV Check ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: Install Core MSRV toolchain
run: |
rustup toolchain install ${{ env.CORE_MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }}
rustup override set ${{ env.CORE_MSRV }}
cargo -V
- name: disable debug
shell: bash
run: |
mkdir -p .cargo
echo """
[profile.dev]
debug = false" >> .cargo/config.toml
- name: caching
uses: Swatinem/rust-cache@v2
with:
key: msrv-check-${{ matrix.target }}-${{ env.CACHE_SUFFIX }}
- name: check native
shell: bash
run: |
set -e
# check wgpu-core with all features. This will also get wgpu-hal and wgpu-types.
cargo check --target ${{ matrix.target }} --all-features -p wgpu-core
wasm-test:
name: Test WebAssembly
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: Install Repo MSRV toolchain
run: |
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy --target wasm32-unknown-unknown
rustup override set ${{ env.REPO_MSRV }}
cargo -V
- name: Install wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- name: execute tests
run: |
cd wgpu
wasm-pack test --headless --chrome --features webgl --workspace
2022-10-15 02:55:36 +00:00
gpu-test:
strategy:
fail-fast: false
matrix:
include:
# Windows
- name: Windows x86_64
os: windows-2022
# Mac
- name: Mac aarch64
os: [self-hosted, macOS]
2022-10-15 02:55:36 +00:00
# Linux
- name: Linux x86_64
os: ubuntu-22.04
2022-10-15 02:55:36 +00:00
name: Test ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- name: checkout repo
uses: actions/checkout@v4
2022-10-15 02:55:36 +00:00
- name: Install Repo MSRV toolchain
run: |
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal -c llvm-tools
cargo -V
2023-02-09 15:33:53 +00:00
- name: Install cargo-nextest and cargo-llvm-cov
uses: taiki-e/install-action@v2
2022-10-15 02:55:36 +00:00
with:
2023-02-09 15:33:53 +00:00
tool: cargo-nextest,cargo-llvm-cov
- name: (windows) install warp
if: matrix.os == 'windows-2022'
shell: bash
2021-07-28 04:19:59 +00:00
run: |
set -e
curl.exe -L https://www.nuget.org/api/v2/package/Microsoft.Direct3D.WARP/1.0.7.1 -o warp.zip
7z.exe e warp.zip -owarp build/native/amd64/d3d10warp.dll
mkdir -p target/llvm-cov-target/debug/deps
cp -v warp/d3d10warp.dll target/llvm-cov-target/debug/
cp -v warp/d3d10warp.dll target/llvm-cov-target/debug/deps
- name: (windows) install mesa
if: matrix.os == 'windows-2022'
shell: bash
run: |
set -e
curl.exe -L https://github.com/pal1000/mesa-dist-win/releases/download/23.2.1/mesa3d-23.2.1-release-msvc.7z -o mesa.7z
7z.exe e mesa.7z -omesa x64/{opengl32.dll,libgallium_wgl.dll,libglapi.dll,vulkan_lvp.dll,lvp_icd.x86_64.json}
cp -v mesa/* target/llvm-cov-target/debug/
cp -v mesa/* target/llvm-cov-target/debug/deps
echo "VK_DRIVER_FILES=$PWD/mesa/lvp_icd.x86_64.json" >> "$GITHUB_ENV"
echo "GALLIUM_DRIVER=llvmpipe" >> "$GITHUB_ENV"
- name: (linux) install llvmpipe, lavapipe, vulkan sdk
2022-10-15 02:55:36 +00:00
if: matrix.os == 'ubuntu-22.04'
shell: bash
run: |
set -e
2022-10-15 02:55:36 +00:00
sudo apt-get update -y -qq
# vulkan sdk
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
2022-10-26 23:37:25 +00:00
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
2022-10-15 02:55:36 +00:00
2023-10-19 16:06:42 +00:00
sudo add-apt-repository ppa:kisak/kisak-mesa
2022-10-15 02:55:36 +00:00
sudo apt-get update
2023-10-19 16:06:42 +00:00
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev vulkan-sdk mesa-vulkan-drivers
2022-10-15 02:55:36 +00:00
- name: disable debug
shell: bash
run: |
mkdir -p .cargo
echo """
[profile.dev]
debug = 1" >> .cargo/config.toml
- name: caching
uses: Swatinem/rust-cache@v2
if: matrix.os[0] != 'self-hosted'
2022-10-15 02:55:36 +00:00
with:
key: test-${{ matrix.os }}-${{ env.CACHE_SUFFIX }}
workspaces: |
. -> target
xtask -> xtask/target
- name: run wgpu-info
shell: bash
run: |
echo "$PATH"
export RUST_LOG=trace
# This needs to match the command in xtask/tests.rs
cargo llvm-cov --no-cfg-coverage --no-report run --bin wgpu-info
2022-10-15 02:55:36 +00:00
- name: run tests
shell: bash
run: |
set -e
2023-10-19 16:06:42 +00:00
cargo xtask test --llvm-cov
2021-09-03 17:53:10 +00:00
- uses: actions/upload-artifact@v3
if: always() # We want artifacts even if the tests fail.
with:
name: comparison-images
path: |
**/*-actual.png
**/*-difference.png
2022-10-15 02:55:36 +00:00
- name: generate coverage report
shell: bash
run: |
set -e
cargo llvm-cov report --lcov --output-path lcov.info
- name: upload coverage report to codecov
uses: codecov/codecov-action@v3
with:
files: lcov.info
2022-10-15 02:55:36 +00:00
doctest:
name: Doctest
2023-02-09 15:33:53 +00:00
runs-on: ubuntu-latest
2022-10-15 02:55:36 +00:00
steps:
- name: checkout repo
uses: actions/checkout@v4
2022-10-15 02:55:36 +00:00
- name: Install Repo MSRV toolchain
run: |
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component rustfmt
rustup override set ${{ env.REPO_MSRV }}
cargo -V
2022-10-15 02:55:36 +00:00
- name: disable debug
shell: bash
run: |
mkdir -p .cargo
echo """
[profile.dev]
debug = 1" >> .cargo/config.toml
- name: caching
uses: Swatinem/rust-cache@v2
with:
key: doctests-${{ env.CACHE_SUFFIX }}
2022-10-15 02:55:36 +00:00
- name: run doctests
shell: bash
run: |
set -e
cargo test --doc
2022-10-15 02:55:36 +00:00
2021-07-04 02:10:10 +00:00
fmt:
name: Format
2021-03-12 17:39:04 +00:00
runs-on: ubuntu-latest
steps:
2021-07-04 02:10:10 +00:00
- name: checkout repo
uses: actions/checkout@v4
2021-07-04 02:10:10 +00:00
- name: Install Repo MSRV toolchain
run: |
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component rustfmt
rustup override set ${{ env.REPO_MSRV }}
cargo -V
2021-07-04 02:10:10 +00:00
- name: run rustfmt
run: |
cargo fmt -- --check
2023-10-19 16:06:42 +00:00
cargo fmt --manifest-path xtask/Cargo.toml -- --check
2021-09-28 15:25:33 +00:00
check-cts-runner:
2022-10-15 02:55:36 +00:00
name: Clippy cts_runner
2021-09-28 15:25:33 +00:00
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
2021-09-28 15:25:33 +00:00
2023-02-09 15:33:53 +00:00
- name: Install MSRV toolchain
run: |
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy
rustup override set ${{ env.REPO_MSRV }}
cargo -V
2022-10-15 02:55:36 +00:00
- name: disable debug
shell: bash
run: |
mkdir -p .cargo
echo """
[profile.dev]
debug = 1" >> .cargo/config.toml
- name: caching
uses: Swatinem/rust-cache@v2
with:
key: cts-runner-${{ env.CACHE_SUFFIX }}
2021-09-28 15:25:33 +00:00
- name: build Deno
run: |
2022-10-15 02:55:36 +00:00
cargo clippy --manifest-path cts_runner/Cargo.toml
2022-11-30 21:46:58 +00:00
# Separate job so that new advisories don't block CI.
#
# This job is not required to pass for PRs to be merged.
2022-11-30 21:46:58 +00:00
cargo-deny-check-advisories:
name: "cargo-deny advisories"
2022-11-30 21:46:58 +00:00
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
2022-11-30 21:46:58 +00:00
- name: Run `cargo deny check`
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check advisories
arguments: --all-features --workspace
rust-version: ${{ env.REPO_MSRV }}
2022-11-30 21:46:58 +00:00
cargo-deny-check-rest:
name: "cargo-deny"
2022-11-30 21:46:58 +00:00
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
2022-11-30 21:46:58 +00:00
- name: Run `cargo deny check`
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check bans licenses sources
arguments: --all-features --workspace
rust-version: ${{ env.REPO_MSRV }}