diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 98631a7..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,220 +0,0 @@ -version: 2.1 - -parameters: - nightly-version: - type: string - default: "nightly-2022-04-24" - -orbs: - codecov: codecov/codecov@1 - -executors: - default: - docker: - - image: filecoin/rust:latest - working_directory: /mnt/crate - resource_class: 2xlarge - arm: - machine: - image: ubuntu-2004:202101-01 - resource_class: arm.large - -restore-workspace: &restore-workspace - attach_workspace: - at: /mnt - -restore-cache: &restore-cache - restore_cache: - keys: - - cargo-v8-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - - repo-source-{{ .Branch }}-{{ .Revision }} - -jobs: - cargo_fetch: - executor: default - steps: - - checkout - - run: - name: Calculate dependencies - command: cargo generate-lockfile - - restore_cache: - keys: - - cargo-v8-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - - run: rm -rf ~/.rustup - - run: rustup self update - - run: rustup install stable - - run: rustup default stable - # A nightly build is needed for code coverage reporting and clippy - - run: rustup toolchain install << pipeline.parameters.nightly-version >> - - run: rustup component add --toolchain << pipeline.parameters.nightly-version >> llvm-tools-preview - - run: rustc --version - - run: rm -rf .git - - run: cargo update - - run: cargo fetch - - persist_to_workspace: - root: /mnt - paths: - - crate - - save_cache: - key: cargo-v8-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - paths: - - "~/.cargo" - - "~/.rustup" - - rustfmt: - executor: default - steps: - - *restore-workspace - - *restore-cache - - run: - name: Run cargo fmt - command: cargo fmt --all -- --check - - clippy: - executor: default - steps: - - *restore-workspace - - *restore-cache - - run: - name: Run cargo clippy - # Nightly is needed as `--all-targets` also runs on the benchmarks - command: cargo +<< pipeline.parameters.nightly-version >> clippy --all-targets --features gpu --workspace -- -D warnings - - run: - name: Run cargo clippy (benches) - command: cargo +<< pipeline.parameters.nightly-version >> clippy --all-targets --features gpu,__private_bench --workspace -- -D warnings - - build_default: - executor: default - steps: - - *restore-workspace - - *restore-cache - - run: - name: Run cargo build - command: cargo build --workspace - - test_default: - executor: default - steps: - - *restore-workspace - - *restore-cache - - run: - name: Run cargo test - command: cargo test --workspace - - test_portable: - executor: default - steps: - - *restore-workspace - - *restore-cache - - run: - name: Run cargo test - command: cargo test --features portable --workspace - - test_arm: - executor: arm - steps: - - checkout - - run: - name: Install Rust - command: | - curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal --default-toolchain $(cat rust-toolchain) -y - - run: - name: Run cargo test - command: cargo test --workspace - - run: - name: Run cargo test portable - command: cargo test --workspace --features portable - - check_gpu: - executor: default - steps: - - *restore-workspace - - *restore-cache - - run: - name: Run cargo check - command: cargo check --features gpu --workspace - - bench: - executor: default - steps: - - *restore-workspace - - *restore-cache - - run: - name: Run cargo bench - command: cargo +<< pipeline.parameters.nightly-version >> bench - - coverage_run: - executor: default - environment: - # Incremental build is not supported when profiling - CARGO_INCREMENTAL: 0 - # -Zinstrument-coverage: enable llvm coverage instrumentation - # -Ccodegen-units=1: building in parallel is not supported when profiling - # -Copt-level=0: disable optimizations for more accurate coverage - # -Clink-dead-code: dead code should be considered as not covered code - # -Coverflow-checks=off: checking for overflow is not needed for coverage reporting - # -Cinline-threshold=0: do not inline - RUSTFLAGS: -Zinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Cinline-threshold=0 - # Make sure that each run of an executable creates a new profile file, with the default - # name they would override each other - LLVM_PROFILE_FILE: "%m.profraw" - steps: - - *restore-workspace - - *restore-cache - - run: - name: Set the PATH env variable - command: | - # Also put the Rust LLVM tools into the PATH. - echo 'export PATH="~/.rustup/toolchains/<< pipeline.parameters.nightly-version >>-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:$PATH"' | tee --append $BASH_ENV - source $BASH_ENV - - run: - name: Generate coverage report - command: | - RUST_LOG=info cargo +<< pipeline.parameters.nightly-version >> test -- --nocapture - - # Do *not* use sparse output. It leads to more lines that are not - # taken into account at all - llvm-profdata merge --output=default.profdata ./*.profraw - - # The compiled files contain the coverage information. From running the tests we don't - # know what those files are called, hence use all files from the `./target/debug/deps` - # directory which don't have an extension. - OBJECT_FILES=$(find ./target/debug/deps/* -name '*' -not -name '*\.*' -printf '%p,'|head --bytes -1) - # Only export the coverage of this project, we don't care about coverage of - # dependencies - llvm-cov export --ignore-filename-regex=".cargo|.rustup" --format=lcov -instr-profile=default.profdata --object=${OBJECT_FILES} > lcov.info - # Codecov automatically merges the reports in case there are several ones uploaded - - codecov/upload: - file: lcov.info - -workflows: - version: 2.1 - - test: - jobs: - - cargo_fetch - - rustfmt: - requires: - - cargo_fetch - - clippy: - requires: - - cargo_fetch - - build_default: - requires: - - cargo_fetch - - bench: - requires: - - cargo_fetch - - test_default: - requires: - - cargo_fetch - - test_portable: - requires: - - cargo_fetch - - test_arm - - check_gpu: - requires: - - cargo_fetch - - coverage_run: - requires: - - cargo_fetch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e79af1..a3ea772 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ env: RUSTFLAGS: "-Dwarnings" CARGO_INCREMENTAL: 0 RUST_BACKTRACE: 1 + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse jobs: set-msrv: @@ -17,44 +18,49 @@ jobs: outputs: msrv: ${{ steps.msrv.outputs.msrv }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - id: msrv run: echo "::set-output name=msrv::$(echo $MSRV)" - # NOTE vmx 2022-06-14: currently doesn't work, hence run it on CircleCI - # for now. - #linux_foreign: - # strategy: - # matrix: - # include: - # # 64-bit Linux/arm64 - # - target: aarch64-unknown-linux-gnu - # rust: nightly - # arch: aarch64 - # - # runs-on: ubuntu-18.04 - # steps: - # - uses: actions/checkout@v2 - # - uses: uraimo/run-on-arch-action@v2.1.1 - # name: Run commands - # id: runcmd - # with: - # arch: aarch64 - # distro: ubuntu18.04 - # - # # Not required, but speeds up builds by storing container images in - # # a GitHub package registry. - # githubToken: ${{ github.token }} - # - # install: | - # apt-get update -q -y - # apt-get install -q -y ocl-icd-opencl-dev curl build-essential - # curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal --default-toolchain ${{ matrix.rust }} -y - # source $HOME/.cargo/env - # - # run: | - # $HOME/.cargo/bin/cargo test --release --target ${{ matrix.target }} - # $HOME/.cargo/bin/cargo test --release --features portable --target ${{ matrix.target }} + linux_foreign: + strategy: + matrix: + include: + # 64-bit Linux/arm64 + - target: aarch64-unknown-linux-gnu + # NOTE vmx 2024-07-15: Use at least Rust 1.68.2 for now, so that we can use the sparse + # index. Without this, the build times out. Once the MSRV is >= 1.68.2, we don't need + # to special case anymore and can use the MSRV instead. + toolchain: 1.68.2 + arch: aarch64 + + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: uraimo/run-on-arch-action@v2 + name: Run tests + id: runtests + with: + arch: aarch64 + distro: ubuntu22.04 + + # Not required, but speeds up builds by storing container images in + # a GitHub package registry. + githubToken: ${{ github.token }} + + env: | # YAML, but pipe character is necessary + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse + + install: | + apt-get update -q -y + apt-get install -q -y ocl-icd-opencl-dev curl build-essential + curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal --default-toolchain ${{ matrix.toolchain }} -y + source $HOME/.cargo/env + + run: | + $HOME/.cargo/bin/rustup override set ${{ matrix.toolchain }} + $HOME/.cargo/bin/cargo test --release --target ${{ matrix.target }} + $HOME/.cargo/bin/cargo test --release --features portable --target ${{ matrix.target }} # Linux tests linux: @@ -64,32 +70,30 @@ jobs: include: # 32-bit Linux/x86 - target: i686-unknown-linux-gnu - rust: ${{needs.set-msrv.outputs.msrv}} + toolchain: ${{needs.set-msrv.outputs.msrv}} deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu - rust: stable + toolchain: stable deps: sudo apt update && sudo apt install gcc-multilib # 64-bit Linux/x86_64 - target: x86_64-unknown-linux-gnu - rust: ${{needs.set-msrv.outputs.msrv}} + toolchain: ${{needs.set-msrv.outputs.msrv}} - target: x86_64-unknown-linux-gnu - rust: stable + toolchain: stable runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: ${{ matrix.toolchain }} target: ${{ matrix.target }} - override: true - name: Install opencl run: sudo apt-get install -y ocl-icd-opencl-dev - run: ${{ matrix.deps }} - - run: cargo test --target ${{ matrix.target }} - - run: cargo test --target ${{ matrix.target }} --features portable + - run: cargo +${{ matrix.toolchain }} test --target ${{ matrix.target }} + - run: cargo +${{ matrix.toolchain }} test --target ${{ matrix.target }} --features portable # macOS tests macos: @@ -102,15 +106,13 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.toolchain }} target: x86_64-apple-darwin - override: true - - run: cargo test - - run: cargo test --features portable + - run: cargo +${{ matrix.toolchain }} test + - run: cargo +${{ matrix.toolchain }} test --features portable # Windows tests windows: @@ -124,46 +126,54 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.toolchain }} target: ${{ matrix.target }} - override: true - uses: msys2/setup-msys2@v2 - - run: cargo test --target ${{ matrix.target }} - - run: cargo test --target ${{ matrix.target }} --features portable + - run: cargo +${{ matrix.toolchain }} test --target ${{ matrix.target }} + - run: cargo +${{ matrix.toolchain }} test --target ${{ matrix.target }} --features portable clippy_check: + needs: set-msrv runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - run: rustup component add clippy - - uses: actions-rs/clippy-check@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features + toolchain: ${{ needs.set-msrv.outputs.msrv }} + components: clippy + - name: Clippy + run: cargo clippy --all-features check_fmt_and_docs: + needs: set-msrv name: Checking fmt and docs runs-on: ubuntu-latest steps: - - uses: actions/checkout@master - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt - - - name: setup - run: | - rustup component add rustfmt - rustc --version - - name: fmt - run: cargo fmt --all -- --check - - - name: Docs - run: cargo doc + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ needs.set-msrv.outputs.msrv }} + components: rustfmt + + - name: setup + run: | + rustup component add rustfmt + rustc --version + - name: fmt + run: cargo fmt --all -- --check + + - name: Docs + run: cargo doc + + # Benchmarks need a nightly Rust + bench: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: dtolnay/rust-toolchain@nightly + - name: Run cargo bench + run: cargo +nightly bench