From 3303349ef1f0139cdb91001e498e8e31a258d743 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sat, 2 Jan 2021 19:31:22 -0800 Subject: [PATCH 1/6] Use -Z build-std=core instead of xbuild See: https://github.com/rust-osdev/cargo-xbuild#alternative-the-build-std-feature-of-cargo Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 313be5ca..160356c3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -157,21 +157,14 @@ jobs: toolchain: nightly components: rust-src override: true - - name: Cache cargo plugins - uses: actions/cache@v1 - with: - path: ~/.cargo/bin/ - key: ${{ runner.os }}-cargo-plugins - - name: Install xbuild - run: cargo install cargo-xbuild || true - name: UEFI - run: cargo xbuild --features=rdrand --target x86_64-unknown-uefi + run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-uefi - name: Hermit - run: cargo xbuild --features=rdrand --target x86_64-unknown-hermit + run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-hermit - name: L4Re - run: cargo xbuild --features=rdrand --target x86_64-unknown-l4re-uclibc + run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-l4re-uclibc - name: VxWorks - run: cargo xbuild --features=rdrand --target x86_64-wrs-vxworks + run: cargo build -Z build-std=core --features=rdrand --target=x86_64-wrs-vxworks clippy-fmt: name: Clippy + rustfmt From d5186e0c860eb9e9d96327d27001c60234dcdfbe Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sat, 2 Jan 2021 19:50:16 -0800 Subject: [PATCH 2/6] Add Clippy msrv configuration file This allows us to automatically ignore lints that are incompatible with our MSRV. Signed-off-by: Joe Richey --- .clippy.toml | 1 + .github/workflows/tests.yml | 5 ++++- src/lib.rs | 2 -- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .clippy.toml diff --git a/.clippy.toml b/.clippy.toml new file mode 100644 index 00000000..492e05c4 --- /dev/null +++ b/.clippy.toml @@ -0,0 +1 @@ +msrv = "1.34" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 160356c3..34b86d25 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -174,8 +174,11 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: stable + # https://github.com/rust-lang/rust-clippy/pull/6379 added MSRV + # support, so we need to use nightly until this is on stable. + toolchain: nightly components: rustfmt, clippy + override: true - name: clippy run: cargo clippy --all - name: fmt diff --git a/src/lib.rs b/src/lib.rs index 940113a7..683b9ce3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -146,8 +146,6 @@ )] #![no_std] #![warn(rust_2018_idioms, unused_lifetimes, missing_docs)] -// `matches!` macro was added only in Rust 1.42, which is bigger than our MSRV -#![allow(clippy::match_like_matches_macro)] #[macro_use] extern crate cfg_if; From ea73f5a975582ac675adf3e9b07778c2c3eeaadc Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sun, 3 Jan 2021 05:58:33 -0800 Subject: [PATCH 3/6] Update CI - Cleanup `tests.yml` - Add better binary downloads - Add minimal dependancies check - Add tests for `custom` feature - Build/Link for iOS - Run cross tests on aarch64 linux and Android - Link on Solaris and Netbsd - Test wasm code on Node, Chrome, Firefox - Test WASI - No need for RDRAND feature on VxWorks Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 197 +++++++++++++++++++++++++++--------- 1 file changed, 147 insertions(+), 50 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 34b86d25..3ad744d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,18 +14,25 @@ env: jobs: check-doc: - name: Doc deadlinks + name: Docs, deadlinks, minimal dependencies runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: nightly # Needed for -Z minimal-versions override: true - - run: cargo install cargo-deadlinks - - run: cargo deadlinks -- --features custom + - name: Install deadlinks + run: | + export URL=$(curl -s https://api.github.com/repos/deadlinks/cargo-deadlinks/releases/latest | jq -r '.assets[] | select(.name | contains("cargo-deadlinks-linux")) | .browser_download_url') + wget -O /tmp/cargo-deadlinks $URL + chmod +x /tmp/cargo-deadlinks + mv /tmp/cargo-deadlinks ~/.cargo/bin + - run: cargo deadlinks -- --features=custom,std + - run: | + cargo generate-lockfile -Z minimal-versions + cargo test --features=custom,std main-tests: name: Main tests @@ -36,14 +43,14 @@ jobs: toolchain: [nightly, beta, stable, 1.34] steps: - uses: actions/checkout@v2 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true - run: cargo test - - run: cargo test --features std + - run: cargo test --features=std + - run: cargo test --features=custom - if: ${{ matrix.toolchain == 'nightly' }} run: cargo build --benches @@ -59,18 +66,40 @@ jobs: ] steps: - uses: actions/checkout@v2 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1 with: profile: minimal target: ${{ matrix.target }} toolchain: stable - override: true - # update is needed to fix the 404 error on install, see: - # https://github.com/actions/virtual-environments/issues/675 - - run: sudo apt-get update - - run: sudo apt-get install gcc-multilib - - run: cargo test --target ${{ matrix.target }} + - name: Install multilib + # update is needed to fix the 404 error on install, see: + # https://github.com/actions/virtual-environments/issues/675 + run: | + sudo apt-get update + sudo apt-get install gcc-multilib + - run: cargo test --target=${{ matrix.target }} --features=std + + # We can only Build/Link on these targets for now. + # TODO: Run the iOS binaries in the simulator + # TODO: build/run aarch64-apple-darwin binaries on a x86_64 Mac + apple-tests: + name: Additional Apple targets + runs-on: macos-latest + strategy: + matrix: + target: [ + aarch64-apple-ios, + x86_64-apple-ios, + ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + target: ${{ matrix.target }} + toolchain: stable + - name: Build Tests + run: cargo test --no-run --target=${{ matrix.target }} --features=std windows-tests: name: Additional Windows targets @@ -90,63 +119,131 @@ jobs: profile: minimal toolchain: ${{ matrix.toolchain }} override: true - - run: cargo test + - run: cargo test --features=std + # TODO: Add emscripten when it's working with Cross cross-tests: - name: Cross tests - runs-on: ${{ matrix.os }} + name: Cross Test + runs-on: ubuntu-latest strategy: matrix: - include: - - os: ubuntu-latest - target: mips-unknown-linux-gnu - toolchain: stable + target: [ + aarch64-unknown-linux-gnu, + aarch64-linux-android, + mips-unknown-linux-gnu, + ] steps: - uses: actions/checkout@v2 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1 with: profile: minimal target: ${{ matrix.target }} - toolchain: ${{ matrix.toolchain }} - override: true - - name: Cache cargo plugins - uses: actions/cache@v1 - with: - path: ~/.cargo/bin/ - key: ${{ runner.os }}-cargo-plugins + toolchain: stable - name: Install cross - run: cargo install cross || true + run: | + export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url') + wget -O /tmp/binaries.tar.gz $URL + tar -C /tmp -xzf /tmp/binaries.tar.gz + mv /tmp/cross ~/.cargo/bin - name: Test - run: cross test --no-fail-fast --target ${{ matrix.target }} + run: cross test --no-fail-fast --target=${{ matrix.target }} --features=std - build: - name: Build-only + cross-link: + name: Cross Build/Link runs-on: ubuntu-latest strategy: matrix: target: [ x86_64-sun-solaris, + x86_64-unknown-netbsd, + ] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + target: ${{ matrix.target }} + toolchain: stable + - name: Install cross + run: | + export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url') + wget -O /tmp/binaries.tar.gz $URL + tar -C /tmp -xzf /tmp/binaries.tar.gz + mv /tmp/cross ~/.cargo/bin + - name: Build Tests + run: cross test --no-run --target=${{ matrix.target }} --features=std + + web-tests: + name: Web tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + target: wasm32-unknown-unknown + toolchain: stable + - name: Install wasm-bindgen-test-runner + run: | + export VERSION=$(cargo metadata --format-version=1 | jq -r '.packages[] | select ( .name == "wasm-bindgen" ) | .version') + wget -O /tmp/binaries.tar.gz https://github.com/rustwasm/wasm-bindgen/releases/download/$VERSION/wasm-bindgen-$VERSION-x86_64-unknown-linux-musl.tar.gz + tar -C /tmp -xzf /tmp/binaries.tar.gz --strip-components=1 + mv /tmp/wasm-bindgen-test-runner ~/.cargo/bin + - name: Test (Node) + run: cargo test --target=wasm32-unknown-unknown --features=js + - name: Test (Firefox) + env: + GECKODRIVER: /usr/bin/geckodriver + run: cargo test --target=wasm32-unknown-unknown --features=js,test-in-browser + - name: Test (Chrome) + env: + CHROMEDRIVER: /usr/bin/chromedriver + run: cargo test --target=wasm32-unknown-unknown --features=js,test-in-browser + - name: Build Tests (with custom, without JS) + run: cargo test --no-run --target=wasm32-unknown-unknown --features=custom + + wasi-tests: + name: WASI test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + target: wasm32-wasi + toolchain: stable + - name: Install wasmtime + run: | + export URL=$(curl -s https://api.github.com/repos/bytecodealliance/wasmtime/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-linux.tar.xz")) | .browser_download_url') + wget -O /tmp/binaries.tar.xz $URL + tar -C /tmp -xf /tmp/binaries.tar.xz --strip-components=1 + mv /tmp/wasmtime ~/.cargo/bin + - run: cargo test --target wasm32-wasi + + build: + name: Build only + runs-on: ubuntu-latest + strategy: + matrix: + target: [ x86_64-unknown-freebsd, x86_64-fuchsia, - x86_64-unknown-netbsd, x86_64-unknown-redox, x86_64-fortanix-unknown-sgx, ] steps: - uses: actions/checkout@v2 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v1 with: profile: minimal target: ${{ matrix.target }} - toolchain: nightly + toolchain: nightly # Required to build libc for Redox override: true - name: Build - run: cargo build --target ${{ matrix.target }} + run: cargo build --target=${{ matrix.target }} --features=std - build-rdrand: - name: Build-only RDRAND + build-std: + name: Build-only (build-std) runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -154,17 +251,17 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: nightly # Required to build libcore components: rust-src override: true - - name: UEFI + - name: UEFI (RDRAND) run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-uefi - - name: Hermit + - name: Hermit (RDRAND) run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-hermit - - name: L4Re + - name: L4Re (RDRAND) run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-l4re-uclibc - name: VxWorks - run: cargo build -Z build-std=core --features=rdrand --target=x86_64-wrs-vxworks + run: cargo build -Z build-std=core --target=x86_64-wrs-vxworks clippy-fmt: name: Clippy + rustfmt @@ -180,6 +277,6 @@ jobs: components: rustfmt, clippy override: true - name: clippy - run: cargo clippy --all + run: cargo clippy --all --features=custom,std - name: fmt run: cargo fmt --all -- --check From 76874981606d5d7d7f19bb13156a0528a8fccfad Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sun, 3 Jan 2021 15:32:36 -0800 Subject: [PATCH 4/6] Only test macOS on stable Most of the advantages from testing various Rust versions already come from running those tests on Linux and Windows. There's very little gain from also running these tests on macOS, while macOS jobs are the slowest to schedule. Signed-off-by: Joe Richey --- .github/workflows/tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3ad744d5..e0d4228b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,8 +39,12 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, windows-latest] toolchain: [nightly, beta, stable, 1.34] + # Only Test macOS on stable to reduce macOS CI jobs + include: + - os: macos-latest + toolchain: stable steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 From e593f43daaaa41261339b8791793606d04451dbc Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sun, 3 Jan 2021 20:48:13 -0800 Subject: [PATCH 5/6] Clarify use of .cargo/config Signed-off-by: Joe Richey --- .cargo/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cargo/config b/.cargo/config index 291ce5e5..0c06f2ad 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,5 +1,5 @@ +# Allow normal use of "cargo run" and "cargo test" on these wasm32 platforms. [target.wasm32-unknown-unknown] runner = 'wasm-bindgen-test-runner' - [target.wasm32-wasi] runner = 'wasmtime' From 7b8f2ba95299b2ad007fb536fec8d5e46490abfe Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sun, 3 Jan 2021 21:26:32 -0800 Subject: [PATCH 6/6] Note that installed binaries are precompiled --- .github/workflows/tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e0d4228b..028b7822 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: profile: minimal toolchain: nightly # Needed for -Z minimal-versions override: true - - name: Install deadlinks + - name: Install precompiled cargo-deadlinks run: | export URL=$(curl -s https://api.github.com/repos/deadlinks/cargo-deadlinks/releases/latest | jq -r '.assets[] | select(.name | contains("cargo-deadlinks-linux")) | .browser_download_url') wget -O /tmp/cargo-deadlinks $URL @@ -54,7 +54,7 @@ jobs: override: true - run: cargo test - run: cargo test --features=std - - run: cargo test --features=custom + - run: cargo test --features=custom # custom should do nothing here - if: ${{ matrix.toolchain == 'nightly' }} run: cargo build --benches @@ -143,7 +143,7 @@ jobs: profile: minimal target: ${{ matrix.target }} toolchain: stable - - name: Install cross + - name: Install precompiled cross run: | export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url') wget -O /tmp/binaries.tar.gz $URL @@ -168,7 +168,7 @@ jobs: profile: minimal target: ${{ matrix.target }} toolchain: stable - - name: Install cross + - name: Install precompiled cross run: | export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url') wget -O /tmp/binaries.tar.gz $URL @@ -187,7 +187,7 @@ jobs: profile: minimal target: wasm32-unknown-unknown toolchain: stable - - name: Install wasm-bindgen-test-runner + - name: Install precompiled wasm-bindgen-test-runner run: | export VERSION=$(cargo metadata --format-version=1 | jq -r '.packages[] | select ( .name == "wasm-bindgen" ) | .version') wget -O /tmp/binaries.tar.gz https://github.com/rustwasm/wasm-bindgen/releases/download/$VERSION/wasm-bindgen-$VERSION-x86_64-unknown-linux-musl.tar.gz @@ -216,7 +216,7 @@ jobs: profile: minimal target: wasm32-wasi toolchain: stable - - name: Install wasmtime + - name: Install precompiled wasmtime run: | export URL=$(curl -s https://api.github.com/repos/bytecodealliance/wasmtime/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-linux.tar.xz")) | .browser_download_url') wget -O /tmp/binaries.tar.xz $URL