diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 388db67456..4bbdcbabcf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,19 +3,51 @@ env:
# version like 1.70. Note that we only specify MAJOR.MINOR and not PATCH so that bugfixes still
# come automatically. If the version specified here is no longer the latest stable version,
# then please feel free to submit a PR that adjusts it along with the potential clippy fixes.
- RUST_STABLE_VER: "1.79" # In quotes because otherwise 1.70 would be interpreted as 1.7
- # We do not run the masonry snapshot tests, because those require a specific font stack
+ RUST_STABLE_VER: "1.79" # In quotes because otherwise (e.g.) 1.70 would be interpreted as 1.7
+ # The purpose of checking with the minimum supported Rust toolchain is to detect its staleness.
+ # If the compilation fails, then the version specified here needs to be bumped up to reality.
+ # Be sure to also update the rust-version property in the workspace Cargo.toml file,
+ # plus all the README.md files of the affected packages.
+ RUST_MIN_VER: "1.77"
+ # List of packages that will be checked with the minimum supported Rust version.
+ # This should be limited to packages that are intended for publishing.
+ # If updating, synchronise RUST_MIN_VER_WASM_PKGS
+ RUST_MIN_VER_PKGS: "-p xilem -p xilem_core -p masonry"
+
+ # List of packages that can not target Wasm.
+ # If updating, synchronise RUST_MIN_VER_WASM_PKGS
+ NO_WASM_PKGS: "--exclude masonry --exclude xilem"
+ # RUST_MIN_VER_PKGS + NO_WASM_PKGS, evaluated.
+ # This is required because `cargo hack` does not support -p {x} --exclude {x}
+ RUST_MIN_VER_WASM_PKGS: "-p xilem_core"
+
+ # We do not run the masonry snapshot tests, because those currently require a specific font stack
+ # See https://github.com/linebender/xilem/pull/233
SKIP_RENDER_SNAPSHOTS: 1
# We do not run the masonry render tests, because those require Vello rendering to be working
- # See https://github.com/linebender/vello/pull/439
+ # See also https://github.com/linebender/vello/pull/610
SKIP_RENDER_TESTS: 1
# Rationale
#
# We don't run clippy with --all-targets because then even --lib and --bins are compiled with
# dev dependencies enabled, which does not match how they would be compiled by users.
-# A dev dependency might enable a feature of a regular dependency that we need, but testing
-# with --all-targets would not catch that. Thus we split --lib & --bins into a separate step.
+# A dev dependency might enable a feature that we need for a regular dependency,
+# and checking with --all-targets would not find our feature requirements lacking.
+# This problem still applies to cargo resolver version 2.
+# Thus we split all the targets into two steps, one with --lib --bins
+# and another with --tests --benches --examples.
+# Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages.
+# Luckily the default behavior of cargo with no explicit targets is the same but without the error.
+#
+# We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across
+# the whole workspace. While cargo-hack will instead check each workspace package separately.
+#
+# Using cargo-hack also allows us to more easily test the feature matrix of our packages.
+# We use --each-feature & --optional-deps which will run a separate check for every feature.
+#
+# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and
+# running tests introduces dev dependencies which may require a higher MSRV than the bare package.
name: CI
@@ -24,9 +56,9 @@ on:
merge_group:
jobs:
- rustfmt:
- runs-on: ubuntu-latest
+ fmt:
name: cargo fmt
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -47,20 +79,17 @@ jobs:
- name: check copyright headers
run: bash .github/copyright.sh
- test-stable:
+ clippy-stable:
+ name: cargo clippy
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
- name: cargo clippy + test
steps:
- uses: actions/checkout@v4
- - name: install additional linux dependencies
- run: |
- sudo apt update
- sudo apt install libwayland-dev libxkbcommon-x11-dev
- if: contains(matrix.os, 'ubuntu')
+ - name: restore cache
+ uses: Swatinem/rust-cache@v2
- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
@@ -68,36 +97,127 @@ jobs:
toolchain: ${{ env.RUST_STABLE_VER }}
components: clippy
+ - name: install cargo-hack
+ uses: taiki-e/install-action@v2
+ with:
+ tool: cargo-hack
+
+ - name: install native dependencies
+ if: matrix.os == 'ubuntu-latest'
+ run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
+
+ - name: cargo clippy
+ run: cargo hack clippy --workspace --locked --each-feature --optional-deps -- -D warnings
+
+ - name: cargo clippy (auxiliary)
+ run: cargo hack clippy --workspace --locked --each-feature --optional-deps --tests --benches --examples -- -D warnings
+
+ clippy-stable-wasm:
+ name: cargo clippy (wasm32)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
- name: restore cache
uses: Swatinem/rust-cache@v2
- - name: cargo clippy (no default features)
- run: cargo clippy --workspace --lib --bins --no-default-features -- -D warnings
- # No default features means no backend on Linux, so we won't run it
- if: contains(matrix.os, 'ubuntu') == false
+ - name: install stable toolchain
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ env.RUST_STABLE_VER }}
+ targets: wasm32-unknown-unknown
+ components: clippy
- - name: cargo clippy (no default features) (auxiliary)
- run: cargo clippy --workspace --tests --benches --examples --no-default-features -- -D warnings
- # No default features means no backend on Linux, so we won't run it
- if: contains(matrix.os, 'ubuntu') == false
+ - name: install cargo-hack
+ uses: taiki-e/install-action@v2
+ with:
+ tool: cargo-hack
- - name: cargo clippy (default features)
- run: cargo clippy --workspace --lib --bins -- -D warnings
+ - name: cargo clippy
+ run: cargo hack clippy --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --each-feature --optional-deps -- -D warnings
- - name: cargo clippy (default features) (auxiliary)
- run: cargo clippy --workspace --tests --benches --examples -- -D warnings
+ - name: cargo clippy (auxiliary)
+ run: cargo hack clippy --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --each-feature --optional-deps --tests --benches --examples -- -D warnings
- - name: cargo clippy (all features)
- run: cargo clippy --workspace --lib --bins --all-features -- -D warnings
+ test-stable:
+ name: cargo test
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [windows-latest, macos-latest, ubuntu-latest]
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: restore cache
+ uses: Swatinem/rust-cache@v2
+
+ - name: install stable toolchain
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ env.RUST_STABLE_VER }}
- - name: cargo clippy (all features) (auxiliary)
- run: cargo clippy --workspace --tests --benches --examples --all-features -- -D warnings
+ - name: install native dependencies
+ if: matrix.os == 'ubuntu-latest'
+ run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
+
+ # Adapted from https://github.com/bevyengine/bevy/blob/b446374392adc70aceb92621b080d1a6cf7a7392/.github/workflows/validation-jobs.yml#L74-L79
+ - name: install xvfb, llvmpipe and lavapipe
+ if: matrix.os == 'ubuntu-latest'
+ # https://launchpad.net/~kisak/+archive/ubuntu/turtle
+ run: |
+ sudo apt-get update -y -qq
+ sudo add-apt-repository ppa:kisak/turtle -y
+ sudo apt-get update
+ sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: cargo test
- run: cargo test --workspace --all-features
+ run: cargo test --workspace --locked --all-features
- docs:
- name: cargo doc
+ test-stable-wasm:
+ name: cargo test (wasm32)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: restore cache
+ uses: Swatinem/rust-cache@v2
+
+ - name: install stable toolchain
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ env.RUST_STABLE_VER }}
+ targets: wasm32-unknown-unknown
+
+ # TODO: Find a way to make tests work. Until then the tests are merely compiled.
+ - name: cargo test compile
+ run: cargo test --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --all-features --no-run
+
+ check-stable-android:
+ name: cargo check (aarch64-android)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: restore cache
+ uses: Swatinem/rust-cache@v2
+
+ - name: install stable toolchain
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ env.RUST_STABLE_VER }}
+ targets: aarch64-linux-android
+
+ - name: install cargo apk
+ run: cargo install cargo-apk
+
+ - name: cargo apk check (android)
+ run: cargo apk check -p xilem --example mason_android
+ env:
+ # This is a bit of a hack, but cargo apk doesn't seem to allow customising this otherwise
+ RUSTFLAGS: '-D warnings'
+
+ check-msrv:
+ name: cargo check (msrv)
runs-on: ${{ matrix.os }}
strategy:
matrix:
@@ -105,21 +225,66 @@ jobs:
steps:
- uses: actions/checkout@v4
- - name: install additional linux dependencies
- run: |
- sudo apt update
- sudo apt install libwayland-dev libxkbcommon-x11-dev
- if: contains(matrix.os, 'ubuntu')
+ - name: restore cache
+ uses: Swatinem/rust-cache@v2
- - name: install nightly toolchain
- uses: dtolnay/rust-toolchain@nightly
+ - name: install msrv toolchain
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ env.RUST_MIN_VER }}
+
+ - name: install cargo-hack
+ uses: taiki-e/install-action@v2
+ with:
+ tool: cargo-hack
+
+ - name: install native dependencies
+ if: matrix.os == 'ubuntu-latest'
+ run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
+
+ - name: cargo check
+ run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --each-feature --optional-deps
+
+ check-msrv-wasm:
+ name: cargo check (msrv) (wasm32)
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: restore cache
+ uses: Swatinem/rust-cache@v2
+
+ - name: install msrv toolchain
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ env.RUST_MIN_VER }}
+ targets: wasm32-unknown-unknown
+
+ - name: install cargo-hack
+ uses: taiki-e/install-action@v2
+ with:
+ tool: cargo-hack
+
+ - name: cargo check
+ run: cargo hack check ${{ env.RUST_MIN_VER_WASM_PKGS }} --locked --target wasm32-unknown-unknown --each-feature --optional-deps
+
+ doc:
+ name: cargo doc
+ # NOTE: We don't have any platform specific docs in this workspace, so we only run on Ubuntu.
+ # If we get per-platform docs (win/macos/linux/wasm32/..) then doc jobs should match that.
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
- name: restore cache
uses: Swatinem/rust-cache@v2
+ - name: install nightly toolchain
+ uses: dtolnay/rust-toolchain@nightly
+
+ # We test documentation using nightly to match docs.rs. This prevents potential breakages
- name: cargo doc
- # We currently skip checking masonry's docs
- run: cargo doc --workspace --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples --exclude masonry
+ run: cargo doc --workspace --locked --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples
# If this fails, consider changing your text or adding something to .typos.toml
typos:
@@ -128,4 +293,4 @@ jobs:
- uses: actions/checkout@v4
- name: check typos
- uses: crate-ci/typos@v1.21.0
+ uses: crate-ci/typos@v1.22.9
diff --git a/.typos.toml b/.typos.toml
index d01b712708..39c347fec9 100644
--- a/.typos.toml
+++ b/.typos.toml
@@ -24,6 +24,11 @@ FillStrat = "FillStrat" # short for strategy
seeked = "seeked" # Part of the HTML standard
[files]
+# Include .github, .cargo, etc.
+ignore-hidden = false
extend-exclude = [
- "masonry/resources/i18n"
+ "masonry/resources/i18n",
+ # /.git isn't in .gitignore, because git never tracks it.
+ # Typos doesn't know that, though.
+ "/.git",
]
diff --git a/Cargo.toml b/Cargo.toml
index a213e4bb87..913d2416d5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,6 +15,8 @@ members = [
[workspace.package]
edition = "2021"
+# Keep in sync with RUST_MIN_VER in .github/workflows/ci.yml, with the relevant README.md files.
+rust-version = "1.77"
license = "Apache-2.0"
repository = "https://github.com/linebender/xilem"
homepage = "https://xilem.dev/"
diff --git a/masonry/README.md b/masonry/README.md
index 499cbf357b..df6ffaa8ce 100644
--- a/masonry/README.md
+++ b/masonry/README.md
@@ -88,6 +88,26 @@ fn main() {
}
```
+## Minimum supported Rust Version (MSRV)
+
+This version of Masonry has been verified to compile with **Rust 1.77** and later.
+
+Future versions of Masonry might increase the Rust version requirement.
+It will not be treated as a breaking change and as such can even happen with small patch releases.
+
+Click here if compiling fails.
+
+As time has passed, some of Masonry's dependencies could have released versions with a higher Rust requirement.
+If you encounter a compilation issue due to a dependency and don't want to upgrade your Rust toolchain, then you could downgrade the dependency.
+
+```sh
+# Use the problematic dependency's name and version
+cargo update -p package_name --precise 0.1.1
+```
+
+Click here if compiling fails.
+
+As time has passed, some of Xilem's dependencies could have released versions with a higher Rust requirement.
+If you encounter a compilation issue due to a dependency and don't want to upgrade your Rust toolchain, then you could downgrade the dependency.
+
+```sh
+# Use the problematic dependency's name and version
+cargo update -p package_name --precise 0.1.1
+```
+
+Click here if compiling fails.
+
+As time has passed, some of Xilem Core's dependencies could have released versions with a higher Rust requirement.
+If you encounter a compilation issue due to a dependency and don't want to upgrade your Rust toolchain, then you could downgrade the dependency.
+
+```sh
+# Use the problematic dependency's name and version
+cargo update -p package_name --precise 0.1.1
+```
+
+