diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aeaefd7a..f0a98f35 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,19 +17,15 @@ jobs: name: Docs, deadlinks, minimal dependencies runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly # Needed for -Z minimal-versions and doc_cfg - override: true - - uses: Swatinem/rust-cache@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly # Needed for -Z minimal-versions and doc_cfg - 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 chmod +x /tmp/cargo-deadlinks mv /tmp/cargo-deadlinks ~/.cargo/bin + - uses: Swatinem/rust-cache@v2 - name: Generate Docs env: RUSTDOCFLAGS: --cfg docsrs @@ -38,8 +34,9 @@ jobs: cargo generate-lockfile -Z minimal-versions cargo test --features=custom,std + # TODO: add aarch64-based macOS runner when it's supported by Github Actions main-tests: - name: Main tests + name: Tier 1 Test runs-on: ${{ matrix.os }} strategy: matrix: @@ -50,13 +47,11 @@ jobs: - os: macos-latest toolchain: stable steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.toolchain }} - override: true - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 - run: cargo test - run: cargo test --features=std - run: cargo test --features=custom # custom should do nothing here @@ -64,7 +59,7 @@ jobs: run: cargo test --benches linux-tests: - name: Additional Linux targets + name: Linux Test runs-on: ubuntu-latest strategy: matrix: @@ -74,46 +69,45 @@ jobs: i686-unknown-linux-musl, ] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - target: ${{ matrix.target }} - toolchain: stable - - uses: Swatinem/rust-cache@v1 + targets: ${{ 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 + - uses: Swatinem/rust-cache@v2 - 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 + ios-tests: + name: iOS Simulator Test runs-on: macos-latest - strategy: - matrix: - target: [ - aarch64-apple-ios, - x86_64-apple-ios, - ] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - target: ${{ matrix.target }} - toolchain: stable - - uses: Swatinem/rust-cache@v1 - - name: Build Tests - run: cargo test --no-run --target=${{ matrix.target }} --features=std + targets: x86_64-apple-ios + - name: Download cargo-dinghy + run: | + VERSION=0.6.2 + URL="https://github.com/sonos/dinghy/releases/download/${VERSION}/cargo-dinghy-macos-${VERSION}.tgz" + curl -L $URL | tar -xz --strip-components=1 -C ~/.cargo/bin + cargo dinghy --version + - name: Setup Simulator + run: | + RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1) + SIM_ID=$(xcrun simctl create My-iphone7 com.apple.CoreSimulator.SimDeviceType.iPhone-7 $RUNTIME_ID) + xcrun simctl boot $SIM_ID + echo "device=$SIM_ID" >> $GITHUB_ENV + - uses: Swatinem/rust-cache@v2 + - name: Run tests + run: cargo dinghy -d ${{ env.device }} test windows-tests: - name: Additional Windows targets + name: Windows Test runs-on: windows-latest strategy: matrix: @@ -123,14 +117,11 @@ jobs: stable-i686-msvc, ] steps: - - uses: actions/checkout@v2 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.toolchain }} - override: true - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 - run: cargo test --features=std cross-tests: @@ -145,22 +136,29 @@ jobs: wasm32-unknown-emscripten, ] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - target: ${{ matrix.target }} - toolchain: stable - - uses: Swatinem/rust-cache@v1 + - uses: actions/checkout@v3 - name: Install precompiled cross run: | export URL=$(curl -s https://api.github.com/repos/cross-rs/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 + - uses: Swatinem/rust-cache@v2 - name: Test run: cross test --no-fail-fast --target=${{ matrix.target }} --features=std + macos-link: + name: macOS ARM64 Build/Link + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-apple-darwin, aarch64-apple-ios + - uses: Swatinem/rust-cache@v2 + - run: cargo test --no-run --target=aarch64-apple-darwin --features=std + - run: cargo test --no-run --target=aarch64-apple-ios --features=std + cross-link: name: Cross Build/Link runs-on: ubuntu-latest @@ -173,39 +171,32 @@ jobs: x86_64-unknown-netbsd, ] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - target: ${{ matrix.target }} - toolchain: stable - - uses: Swatinem/rust-cache@v1 + - uses: actions/checkout@v3 - name: Install precompiled cross run: | export URL=$(curl -s https://api.github.com/repos/cross-rs/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 + - uses: Swatinem/rust-cache@v2 - name: Build Tests run: cross test --no-run --target=${{ matrix.target }} --features=std web-tests: - name: Web tests + name: Web Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - target: wasm32-unknown-unknown - toolchain: stable - - uses: Swatinem/rust-cache@v1 + targets: wasm32-unknown-unknown - 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 tar -C /tmp -xzf /tmp/binaries.tar.gz --strip-components=1 mv /tmp/wasm-bindgen-test-runner ~/.cargo/bin + - uses: Swatinem/rust-cache@v2 - name: Test (Node) run: cargo test --target=wasm32-unknown-unknown --features=js - name: Test (Firefox) @@ -220,17 +211,14 @@ jobs: run: cargo test --target=wasm32-unknown-unknown --features=custom wasm64-tests: - name: WASM memory64 + name: wasm64 Build/Link runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly # Need to build libstd with: - profile: minimal - toolchain: nightly components: rust-src - override: true - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 - name: Build and Link tests (build-std) # This target is Tier 3, so we have to build libstd ourselves. # We currently cannot run these tests because wasm-bindgen-test-runner @@ -238,26 +226,24 @@ jobs: run: cargo test --no-run -Z build-std=std,panic_abort --target=wasm64-unknown-unknown --features=js wasi-tests: - name: WASI test + name: WASI Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - target: wasm32-wasi - toolchain: stable - - uses: Swatinem/rust-cache@v1 + targets: wasm32-wasi - 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 tar -C /tmp -xf /tmp/binaries.tar.xz --strip-components=1 mv /tmp/wasmtime ~/.cargo/bin + - uses: Swatinem/rust-cache@v2 - run: cargo test --target wasm32-wasi - build: - name: Build only + build-tier2: + name: Tier 2 Build runs-on: ubuntu-latest strategy: matrix: @@ -267,65 +253,57 @@ jobs: x86_64-fortanix-unknown-sgx, ] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - target: ${{ matrix.target }} - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v1 + targets: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 - name: Build run: cargo build --target=${{ matrix.target }} --features=std - build-std: - name: Build-only (build-std) + build-tier3: + name: Tier 3 Build runs-on: ubuntu-latest + strategy: + matrix: + # Supported tier 3 targets without libstd support + target: [ + x86_64-unknown-hermit, + x86_64-wrs-vxworks, + aarch64-kmc-solid_asp3, + armv6k-nintendo-3ds, + riscv32imc-esp-espidf, + ] + include: + # Supported tier 3 targets without libstd support + - target: x86_64-unknown-openbsd + features: ["std"] + - target: x86_64-unknown-dragonfly + features: ["std"] + - target: x86_64-unknown-haiku + features: ["std"] + # Unsupported tier 3 targets to test the rdrand feature + - target: x86_64-unknown-uefi + features: ["rdrand"] + - target: x86_64-unknown-l4re-uclibc + features: ["rdrand"] steps: - - uses: actions/checkout@v2 - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly # Required to build libcore with: - profile: minimal - toolchain: nightly # Required to build libcore components: rust-src - override: true - - uses: Swatinem/rust-cache@v1 - - name: Hermit (x86-64 only) - run: cargo build -Z build-std=core --target=x86_64-unknown-hermit - - name: UEFI (RDRAND) - run: cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-uefi - - 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 --target=x86_64-wrs-vxworks - - name: SOLID - run: cargo build -Z build-std=core --target=aarch64-kmc-solid_asp3 - - name: Nintendo 3DS - run: cargo build -Z build-std=core --target=armv6k-nintendo-3ds - - name: RISC-V ESP-IDF - run: cargo build -Z build-std=core --target=riscv32imc-esp-espidf - - name: OpenBSD - run: cargo build -Z build-std=std --target=x86_64-unknown-openbsd --features=std - - name: Dragonfly BSD - run: cargo build -Z build-std=std --target=x86_64-unknown-dragonfly --features=std - - name: Haiku OS - run: cargo build -Z build-std=std --target=x86_64-unknown-haiku --features=std + - uses: Swatinem/rust-cache@v2 + - run: cargo build -Z build-std=${{ contains(matrix.features, 'std') && 'std' || 'core'}} --target=${{ matrix.target }} --features="${{ join(matrix.features, ',') }}" clippy-fmt: name: Clippy + rustfmt runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - # 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 - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 - name: clippy run: cargo clippy --all --features=custom,std - name: fmt