Example/regression (#1150) #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '**.rs' | |
- '**.sh' | |
- '**.ps1' | |
- '**.yml' | |
- '**.toml' | |
- '!**.md' | |
- '!LICENSE-APACHE' | |
- '!LICENSE-MIT' | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- '**.rs' | |
- '**.sh' | |
- '**.ps1' | |
- '**.yml' | |
- '**.toml' | |
- '!**.md' | |
- '!LICENSE-APACHE' | |
- '!LICENSE-MIT' | |
env: | |
# | |
# Dependency versioning | |
# from wgpu repo: https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml | |
# | |
# Sourced from https://vulkan.lunarg.com/sdk/home#linux | |
VULKAN_SDK_VERSION: "1.3.268" | |
# Sourced from https://www.nuget.org/packages/Microsoft.Direct3D.WARP | |
WARP_VERSION: "1.0.8" | |
# Sourced from https://github.com/microsoft/DirectXShaderCompiler/releases | |
# | |
# Must also be changed in shaders.yaml | |
DXC_RELEASE: "v1.7.2308" | |
DXC_FILENAME: "dxc_2023_08_14.zip" | |
# Sourced from https://archive.mesa3d.org/. Bumping this requires | |
# updating the mesa build in https://github.com/gfx-rs/ci-build and creating a new release. | |
MESA_VERSION: "23.3.1" | |
# Corresponds to https://github.com/gfx-rs/ci-build/releases | |
CI_BINARY_BUILD: "build18" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
tests: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-13, ubuntu-22.04, windows-2022] | |
rust: [stable, 1.71.0] | |
test: ['std', 'no-std', 'examples'] | |
include: | |
- cache: stable | |
rust: stable | |
- cache: 1-71-0 | |
rust: 1.71.0 | |
- os: ubuntu-22.04 | |
coverage-flags: COVERAGE=1 | |
rust: stable | |
test: std | |
- os: macos-13 | |
rust: stable | |
test: std | |
- os: windows-2022 | |
wgpu-flags: "DISABLE_WGPU=1" | |
# not used yet, as wgpu tests are disabled on windows for now | |
# see issue: https://github.com/tracel-ai/burn/issues/1062 | |
# auto-graphics-backend-flags: "AUTO_GRAPHICS_BACKEND=dx12";' | |
exclude: | |
# only need to check this once | |
- rust: 1.71.0 | |
test: 'examples' | |
# Do not run no-std tests on macos | |
- os: macos-13 | |
test: 'no-std' | |
# Do not run no-std tests on Windows | |
- os: windows-2022 | |
test: 'no-std' | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: install rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
components: rustfmt, clippy | |
toolchain: ${{ matrix.rust }} | |
- name: caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ runner.os }}-${{ matrix.cache }}-${{ matrix.test}}-${{ hashFiles('**/Cargo.toml') }} | |
prefix-key: "v5-rust" | |
- name: free disk space | |
if: runner.os == 'Linux' | |
run: | | |
df -h | |
sudo swapoff -a | |
sudo rm -f /swapfile | |
sudo apt clean | |
df -h | |
cargo clean --package burn-tch | |
- name: install llvmpipe and lavapipe | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update -y -qq | |
sudo add-apt-repository ppa:kisak/kisak-mesa -y | |
sudo apt-get update | |
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers | |
- name: Run cargo clippy for stable version | |
if: runner.os == 'Linux' && matrix.rust == 'stable' && matrix.test == 'std' | |
uses: giraffate/clippy-action@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# Run clippy for each workspace, targets, and featrues, considering | |
# warnings as errors | |
clippy_flags: --all-targets -- -Dwarnings | |
# Do not filter results | |
filter_mode: nofilter | |
# Report clippy annotations as snippets | |
reporter: github-pr-check | |
- name: Install grcov | |
if: runner.os == 'Linux' && matrix.rust == 'stable' && matrix.test == 'std' | |
env: | |
GRCOV_LINK: https://github.com/mozilla/grcov/releases/download | |
GRCOV_VERSION: v0.8.18 | |
run: | | |
curl -L "$GRCOV_LINK/$GRCOV_VERSION/grcov-x86_64-unknown-linux-musl.tar.bz2" | | |
tar xj -C $HOME/.cargo/bin | |
# ----------------------------------------------------------------------------------- | |
# BEGIN -- Windows steps disabled as long as DISABLE_WGPU=1 (wgpu tests are disabled) | |
# ----------------------------------------------------------------------------------- | |
# - name: (windows) install dxc | |
# # from wgpu repo: https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# run: | | |
# set -e | |
# curl.exe -L --retry 5 https://github.com/microsoft/DirectXShaderCompiler/releases/download/$DXC_RELEASE/$DXC_FILENAME -o dxc.zip | |
# 7z.exe e dxc.zip -odxc bin/x64/{dxc.exe,dxcompiler.dll,dxil.dll} | |
# # We need to use cygpath to convert PWD to a windows path as we're using bash. | |
# cygpath --windows "$PWD/dxc" >> "$GITHUB_PATH" | |
# - name: (windows) install warp | |
# # from wgpu repo: https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# run: | | |
# set -e | |
# # Make sure dxc is in path. | |
# dxc --version | |
# curl.exe -L --retry 5 https://www.nuget.org/api/v2/package/Microsoft.Direct3D.WARP/$WARP_VERSION -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 | |
# # from wgpu repo: https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml | |
# if: runner.os == 'Windows' | |
# shell: bash | |
# run: | | |
# set -e | |
# curl.exe -L --retry 5 https://github.com/pal1000/mesa-dist-win/releases/download/$MESA_VERSION/mesa3d-$MESA_VERSION-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 | |
# # We need to use cygpath to convert PWD to a windows path as we're using bash. | |
# echo "VK_DRIVER_FILES=`cygpath --windows $PWD/mesa/lvp_icd.x86_64.json`" >> "$GITHUB_ENV" | |
# echo "GALLIUM_DRIVER=llvmpipe" >> "$GITHUB_ENV" | |
# ----------------------------------------------------------------------------------- | |
# END -- Windows steps disabled as long as DISABLE_WGPU=1 (wgpu tests are disabled) | |
# ----------------------------------------------------------------------------------- | |
- name: (linux) install vulkan sdk | |
# from wgpu repo: https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml | |
if: runner.os == 'Linux' | |
shell: bash | |
run: | | |
set -e | |
sudo apt-get update -y -qq | |
# vulkan sdk | |
wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - | |
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-$VULKAN_SDK_VERSION-jammy.list https://packages.lunarg.com/vulkan/$VULKAN_SDK_VERSION/lunarg-vulkan-$VULKAN_SDK_VERSION-jammy.list | |
sudo apt-get update | |
sudo apt install -y vulkan-sdk | |
- name: (linux) install mesa | |
# from wgpu repo: https://github.com/gfx-rs/wgpu/blob/trunk/.github/workflows/ci.yml | |
if: runner.os == 'Linux' | |
shell: bash | |
run: | | |
set -e | |
curl -L --retry 5 https://github.com/gfx-rs/ci-build/releases/download/$CI_BINARY_BUILD/mesa-$MESA_VERSION-linux-x86_64.tar.xz -o mesa.tar.xz | |
mkdir mesa | |
tar xpf mesa.tar.xz -C mesa | |
# The ICD provided by the mesa build is hardcoded to the build environment. | |
# | |
# We write out our own ICD file to point to the mesa vulkan | |
cat <<- EOF > icd.json | |
{ | |
"ICD": { | |
"api_version": "1.1.255", | |
"library_path": "$PWD/mesa/lib/x86_64-linux-gnu/libvulkan_lvp.so" | |
}, | |
"file_format_version": "1.0.0" | |
} | |
EOF | |
echo "VK_DRIVER_FILES=$PWD/icd.json" >> "$GITHUB_ENV" | |
echo "LD_LIBRARY_PATH=$PWD/mesa/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH" >> "$GITHUB_ENV" | |
echo "LIBGL_DRIVERS_PATH=$PWD/mesa/lib/x86_64-linux-gnu/dri" >> "$GITHUB_ENV" | |
- name: run checks & tests | |
shell: bash | |
run: ${{ matrix.coverage-flags }} ${{ matrix.wgpu-flags }} cargo xtask run-checks ${{ matrix.test }} | |
- name: Codecov upload | |
if: runner.os == 'Linux' && matrix.rust == 'stable' && matrix.test == 'std' | |
uses: codecov/codecov-action@v3 | |
with: | |
files: lcov.info | |
check-typos: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: caching | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ runner.os }}-typos-${{ hashFiles('**/Cargo.toml') }} | |
prefix-key: "v5-rust" | |
- name: Install typos | |
env: | |
TYPOS_LINK: https://github.com/crate-ci/typos/releases/download | |
TYPOS_VERSION: v1.16.20 | |
run: | | |
curl -L "$TYPOS_LINK/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz" | | |
tar xz -C $HOME/.cargo/bin | |
- name: run spelling checks using typos | |
run: cargo xtask run-checks typos |