2020-05-18 08:56:05 +00:00
|
|
|
name: Test Rust
|
2020-05-09 12:59:27 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-05-08 02:30:56 +00:00
|
|
|
branches: [master]
|
2020-05-09 12:59:27 +00:00
|
|
|
pull_request:
|
2021-05-08 02:30:56 +00:00
|
|
|
branches: [master]
|
2020-05-09 12:59:27 +00:00
|
|
|
|
2023-01-16 01:57:10 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-05-09 12:59:27 +00:00
|
|
|
jobs:
|
2021-08-25 19:03:43 +00:00
|
|
|
changes:
|
|
|
|
name: Paths filter
|
2022-08-17 15:56:24 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2021-08-25 19:03:43 +00:00
|
|
|
outputs:
|
2023-08-26 10:58:31 +00:00
|
|
|
should_run: ${{ steps.filter.outputs.src }}
|
2021-08-25 19:03:43 +00:00
|
|
|
steps:
|
2023-10-01 01:04:37 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-08-25 21:09:14 +00:00
|
|
|
|
2024-01-30 02:37:15 +00:00
|
|
|
- uses: AurorNZ/paths-filter@v4
|
2021-08-25 19:03:43 +00:00
|
|
|
id: filter
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
src:
|
2023-08-26 10:58:31 +00:00
|
|
|
- '!web/package.json'
|
|
|
|
- '!web/package-lock.json'
|
|
|
|
- '!web/packages/**'
|
|
|
|
- '!**/*.md'
|
2021-08-25 19:03:43 +00:00
|
|
|
|
2020-05-09 12:59:27 +00:00
|
|
|
build:
|
2021-08-25 19:03:43 +00:00
|
|
|
needs: changes
|
2024-03-25 23:26:07 +00:00
|
|
|
if: needs.changes.outputs.should_run == 'true'
|
2021-08-25 19:18:31 +00:00
|
|
|
name: Test Rust ${{ matrix.rust_version }} / ${{ matrix.os }}
|
|
|
|
runs-on: ${{ matrix.os }}
|
2021-08-21 21:45:43 +00:00
|
|
|
continue-on-error: ${{ matrix.rust_version == 'nightly' || matrix.rust_version == 'beta' }}
|
2020-05-09 12:59:27 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2024-06-19 18:55:13 +00:00
|
|
|
rust_version: [stable]
|
2024-01-30 20:26:59 +00:00
|
|
|
os: [ubuntu-22.04, windows-latest, macos-14]
|
2021-08-21 14:44:24 +00:00
|
|
|
include:
|
2021-08-25 21:14:56 +00:00
|
|
|
- rust_version: nightly
|
2022-08-17 15:56:24 +00:00
|
|
|
os: ubuntu-22.04
|
2021-09-06 15:05:52 +00:00
|
|
|
- rust_version: beta
|
2022-08-17 15:56:24 +00:00
|
|
|
os: ubuntu-22.04
|
2020-05-09 12:59:27 +00:00
|
|
|
|
|
|
|
steps:
|
2023-10-01 01:04:37 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-05-08 02:30:56 +00:00
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
2022-12-01 21:24:04 +00:00
|
|
|
uses: dtolnay/rust-toolchain@stable
|
2021-05-08 02:30:56 +00:00
|
|
|
with:
|
|
|
|
toolchain: ${{ matrix.rust_version }}
|
|
|
|
|
|
|
|
- name: Install Linux dependencies
|
2022-01-29 20:21:42 +00:00
|
|
|
if: runner.os == 'Linux'
|
2023-01-11 21:01:10 +00:00
|
|
|
run: |
|
2024-02-15 22:58:31 +00:00
|
|
|
sudo add-apt-repository ppa:kisak/kisak-mesa -y
|
2023-01-11 21:01:10 +00:00
|
|
|
sudo apt-get update
|
2024-01-01 20:16:27 +00:00
|
|
|
sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev mesa-vulkan-drivers libpango1.0-dev libudev-dev
|
2021-05-08 02:30:56 +00:00
|
|
|
|
2024-05-20 21:00:07 +00:00
|
|
|
# Needed after: https://github.com/rust-lang/rust/pull/124129
|
2024-06-11 15:46:38 +00:00
|
|
|
# See also: https://github.com/dtolnay/linkme/issues/94
|
|
|
|
# Additionally: https://lld.llvm.org/ELF/start-stop-gc
|
|
|
|
- name: Disable linker start-stop-gc
|
|
|
|
# Note: We also use `rust-lld` on Windows, see `config.toml`.
|
|
|
|
if: runner.os != 'macOS'
|
2024-06-12 15:06:07 +00:00
|
|
|
run: echo RUSTFLAGS=${RUSTFLAGS}\ --cfg=web_sys_unstable_apis\ -Clink-args=-znostart-stop-gc >> $GITHUB_ENV
|
2024-05-20 21:00:07 +00:00
|
|
|
|
2022-08-26 18:38:58 +00:00
|
|
|
- name: Cache Cargo output
|
2022-12-01 22:02:44 +00:00
|
|
|
uses: Swatinem/rust-cache@v2
|
2022-08-26 18:38:58 +00:00
|
|
|
with:
|
|
|
|
shared-key: "desktop"
|
2023-09-06 20:56:24 +00:00
|
|
|
save-if: ${{ github.ref == 'refs/heads/master' }}
|
2022-08-26 18:38:58 +00:00
|
|
|
|
2023-12-18 21:19:47 +00:00
|
|
|
- name: Install cargo nextest
|
|
|
|
uses: taiki-e/install-action@v2
|
|
|
|
with:
|
|
|
|
tool: cargo-nextest
|
|
|
|
|
2021-02-20 18:10:04 +00:00
|
|
|
- name: Run tests with image tests
|
2023-10-15 11:32:34 +00:00
|
|
|
if: runner.os != 'macOS'
|
2023-12-30 23:26:32 +00:00
|
|
|
# TODO: Disallow retries in general once we can allow only after SIGABRT.
|
|
|
|
# See: https://github.com/nextest-rs/nextest/issues/1172
|
2024-02-16 14:57:43 +00:00
|
|
|
run: cargo nextest run --cargo-profile ci --workspace --locked --no-fail-fast --retries 2 -j 4 --features imgtests,lzma,jpegxr
|
2021-08-22 18:42:48 +00:00
|
|
|
env:
|
2024-02-27 13:13:20 +00:00
|
|
|
# This is to counteract the disabling by rust-cache.
|
|
|
|
# See: https://github.com/Swatinem/rust-cache/issues/43
|
|
|
|
CARGO_INCREMENTAL: '1'
|
2024-02-27 13:11:30 +00:00
|
|
|
# Supposedly makes "Updating crates.io index" faster on Windows.
|
|
|
|
# See: https://github.com/rust-lang/cargo/issues/9167
|
|
|
|
CARGO_NET_GIT_FETCH_WITH_CLI: 'true'
|
2024-05-16 14:14:31 +00:00
|
|
|
# Workaround for: https://github.com/nextest-rs/nextest/issues/1493
|
|
|
|
# See also: https://github.com/rust-lang/rustup/issues/3825
|
|
|
|
RUSTUP_WINDOWS_PATH_ADD_BIN: '1'
|
2021-08-25 21:14:56 +00:00
|
|
|
XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing
|
2021-02-20 18:10:04 +00:00
|
|
|
|
2023-10-15 11:32:34 +00:00
|
|
|
- name: Run tests without image tests
|
|
|
|
if: runner.os == 'macOS'
|
2024-02-16 14:57:43 +00:00
|
|
|
run: cargo nextest run --cargo-profile ci --workspace --locked --no-fail-fast -j 4 --features lzma,jpegxr
|
2023-10-15 11:32:34 +00:00
|
|
|
env:
|
|
|
|
XDG_RUNTIME_DIR: '' # dummy value, just to silence warnings about it missing
|
|
|
|
|
2021-02-20 18:10:04 +00:00
|
|
|
- name: Upload images
|
2021-08-25 19:15:02 +00:00
|
|
|
if: failure()
|
2024-02-01 18:29:02 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2021-02-20 18:10:04 +00:00
|
|
|
with:
|
2024-02-15 22:18:43 +00:00
|
|
|
name: swf_images_${{ matrix.rust_version }}_${{ matrix.os }}
|
2023-01-28 12:49:31 +00:00
|
|
|
path: |
|
2023-08-06 21:30:26 +00:00
|
|
|
tests*/**/*.actual*.png
|
|
|
|
tests*/**/*.difference*.png
|
2021-09-21 19:01:51 +00:00
|
|
|
|
2024-02-06 03:18:23 +00:00
|
|
|
lints:
|
|
|
|
needs: changes
|
2024-03-25 23:26:07 +00:00
|
|
|
if: needs.changes.outputs.should_run == 'true'
|
2024-02-06 03:18:23 +00:00
|
|
|
name: Lints with Rust ${{ matrix.rust_version }}
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
continue-on-error: ${{ matrix.rust_version == 'nightly' || matrix.rust_version == 'beta' }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
rust_version: [stable, beta, nightly]
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: ${{ matrix.rust_version }}
|
|
|
|
components: rustfmt, clippy
|
|
|
|
|
|
|
|
- name: Install Linux dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
2024-01-01 20:16:27 +00:00
|
|
|
sudo apt install -y libasound2-dev libxcb-shape0-dev libxcb-xfixes0-dev libgtk-3-dev mesa-vulkan-drivers libpango1.0-dev libudev-dev
|
2024-02-06 03:18:23 +00:00
|
|
|
|
|
|
|
- name: Check formatting
|
|
|
|
run: cargo fmt --all -- --check
|
|
|
|
|
2024-04-04 21:22:36 +00:00
|
|
|
- name: Check clippy (with tests)
|
2024-02-06 03:18:23 +00:00
|
|
|
# Don't fail the build for clippy on nightly, since we get a lot of false-positives
|
|
|
|
run: cargo clippy --all --all-features --tests ${{ (matrix.rust_version != 'nightly' && '-- -D warnings') || '' }}
|
|
|
|
|
2024-04-04 21:22:36 +00:00
|
|
|
- name: Check clippy (without tests)
|
|
|
|
# Don't fail the build for clippy on nightly, since we get a lot of false-positives
|
|
|
|
run: cargo clippy --all --all-features ${{ (matrix.rust_version != 'nightly' && '-- -D warnings') || '' }}
|
|
|
|
|
2024-02-06 03:18:23 +00:00
|
|
|
- name: Check documentation
|
|
|
|
run: cargo doc --no-deps --all-features
|
|
|
|
env:
|
|
|
|
RUSTDOCFLAGS: -D warnings
|
|
|
|
|
2024-03-25 23:26:07 +00:00
|
|
|
dependencies:
|
|
|
|
needs: changes
|
|
|
|
if: needs.changes.outputs.should_run == 'true'
|
|
|
|
name: Check dependencies
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
|
|
|
|
- name: Check licenses, duplicates, and advisories
|
|
|
|
uses: EmbarkStudios/cargo-deny-action@v1
|
|
|
|
|
2024-03-25 23:51:29 +00:00
|
|
|
- name: Check unused dependencies
|
|
|
|
uses: bnjbvr/cargo-machete@main
|
|
|
|
# So the previous step failing doesn't prevent this one from running.
|
|
|
|
if: always()
|
|
|
|
|
2021-09-21 19:01:51 +00:00
|
|
|
check-required:
|
|
|
|
needs: changes
|
2023-08-26 10:58:31 +00:00
|
|
|
if: needs.changes.outputs.should_run == 'false'
|
2021-09-21 19:01:51 +00:00
|
|
|
name: Test Rust ${{ matrix.rust_version }} / ${{ matrix.os }}
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-06-19 18:55:13 +00:00
|
|
|
rust_version: [stable]
|
2024-01-30 20:26:59 +00:00
|
|
|
os: [ubuntu-22.04, windows-latest, macos-14]
|
2021-09-21 19:01:51 +00:00
|
|
|
include:
|
|
|
|
- rust_version: nightly
|
2022-08-17 15:56:24 +00:00
|
|
|
os: ubuntu-22.04
|
2021-09-21 19:01:51 +00:00
|
|
|
- rust_version: beta
|
2022-08-17 15:56:24 +00:00
|
|
|
os: ubuntu-22.04
|
2021-09-21 19:01:51 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: No-op
|
|
|
|
run: echo noop
|