From b4bc4563d60fe97e673cc4af861adeff403fd729 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Wed, 14 Aug 2024 13:58:53 +0200 Subject: [PATCH] chore: use GitHub Actions for CI Remove the CircleCI config. --- .circleci/config.yml | 193 --------------------------------------- .github/workflows/ci.yml | 85 +++++++++++++++++ 2 files changed, 85 insertions(+), 193 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a7d71e6..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,193 +0,0 @@ -version: 2.1 - -executors: - default: - machine: - image: ubuntu-2004-cuda-11.2:202103-01 - working_directory: ~/gpuci - resource_class: gpu.nvidia.medium - -restore-workspace: &restore-workspace - attach_workspace: - at: ~/ - -restore-cache: &restore-cache - restore_cache: - keys: - - cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - - repo-source-{{ .Branch }}-{{ .Revision }} - -commands: - set-env-path: - steps: - - run: - name: Set the PATH env variable - command: | - echo 'export PATH="$HOME:~/.cargo/bin:/usr/local/cuda-11.2/bin:$PATH"' | tee --append $BASH_ENV - source $BASH_ENV - - install-gpu-deps: - steps: - - run: - name: Install libraries for GPU tests - command: | - sudo apt update - sudo apt install -y ocl-icd-opencl-dev - -jobs: - - cargo_fetch: - executor: default - steps: - - checkout - - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - - set-env-path - - run: echo $BASH_ENV - - run: echo $HOME - - run: cargo --version - - run: rustc --version - - run: - name: Update submodules - command: git submodule update --init --recursive - - run: - name: Calculate dependencies - command: cargo generate-lockfile - - restore_cache: - keys: - - cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - - run: cargo update - - run: cargo fetch - - run: rustup install $(cat rust-toolchain) - - run: rustup default $(cat rust-toolchain) - - run: rustup component add rustfmt-preview - - run: rustup component add clippy-preview - - run: rustc --version - - run: rm -rf .git - - persist_to_workspace: - root: ~/ - paths: - - gpuci - - save_cache: - key: cargo-v0-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }} - paths: - - "~/.cargo" - - "~/.rustup" - - test: - executor: default - parameters: - cargo-args: - description: Addtional arguments for the cargo command - type: string - default: "" - environment: - RUST_LOG: debug - steps: - - *restore-workspace - - *restore-cache - - set-env-path - - install-gpu-deps - - run: nvidia-smi --list-gpus - - run: - name: Test (<< parameters.cargo-args >>) - # GPU tests are best run sequentially so that they don't interfere with each other. - command: cargo test --workspace << parameters.cargo-args >> -- --nocapture --test-threads 1 - - rustfmt: - executor: default - steps: - - *restore-workspace - - *restore-cache - - set-env-path - - run: - name: Run cargo fmt - command: cargo fmt --all -- --check - - clippy: - executor: default - parameters: - cargo-args: - description: Addtional arguments for the cargo command - type: string - default: "" - steps: - - *restore-workspace - - *restore-cache - - set-env-path - - install-gpu-deps - - run: - name: Run cargo clippy default features - command: cargo clippy --workspace --all-targets -- -D warnings - - run: - name: Run cargo clippy with cuda and opencl features - command: cargo clippy --workspace --all-targets --features cuda,opencl -- -D warnings - - run: - name: Run cargo clippy with cuda feature - command: cargo clippy --workspace --all-targets --no-default-features --features cuda -- -D warnings - - run: - name: Run cargo clippy with opencl feature - command: cargo clippy --workspace --all-targets --no-default-features --features opencl -- -D warnings - - build: - executor: default - steps: - - *restore-workspace - - *restore-cache - - set-env-path - - install-gpu-deps - - run: - name: Run cargo release build - command: cargo build --workspace --release - rustdoc: - executor: default - environment: - # Making sure that the documentation can be built without having the NVIDIA toolkit - # installed. - DOCS_RS: true - steps: - - *restore-workspace - - *restore-cache - - run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV && source $BASH_ENV - - run: - name: Run rustdoc - command: | - cargo rustdoc --package ec-gpu --all-features -- -D warnings - cargo rustdoc --package ec-gpu-gen --all-features -- -D warnings - -workflows: - version: 2.1 - - test: - jobs: - - cargo_fetch - - rustfmt: - requires: - - cargo_fetch - - clippy: - requires: - - cargo_fetch - - test: - name: "Test with default features" - requires: - - cargo_fetch - - test: - name: "Test with CUDA and OpenCL" - cargo-args: "--features cuda,opencl" - requires: - - cargo_fetch - - test: - name: "Test with CUDA only" - cargo-args: "--no-default-features --features cuda" - requires: - - cargo_fetch - - test: - name: "Test with OpenCL only" - cargo-args: "--no-default-features --features opencl" - requires: - - cargo_fetch - - build: - requires: - - cargo_fetch - - rustdoc: - requires: - - cargo_fetch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1cdac3d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,85 @@ +name: CI + +on: [pull_request, push] + +# Cancel a job if there's a new on on the same branch started. +# Based on https://stackoverflow.com/questions/58895283/stop-already-running-workflow-job-in-github-actions/67223051#67223051 +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_INCREMENTAL: 0 + RUST_BACKTRACE: 1 + # Faster crates.io index checkout. + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse + +jobs: + set-msrv: + runs-on: ubuntu-latest + outputs: + msrv: ${{ steps.msrv.outputs.MSRV }} + steps: + - uses: actions/checkout@v4 + - name: Get MSRV from rust-toolchain + id: msrv + run: | + MSRV=$(cat ./rust-toolchain) + echo "MSRV=$MSRV" | tee --append "$GITHUB_OUTPUT" + + linux: + needs: set-msrv + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{needs.set-msrv.outputs.msrv}} + - name: Install required packages + run: sudo apt install --no-install-recommends --yes ocl-icd-opencl-dev nvidia-cuda-toolkit + - name: Build with default features + run: cargo build --workspace + # Machine has no GPU installed, hence run without the `cuda` or `opencl` feature. + - name: Run tests without default features + run: cargo test --workspace --no-default-features -- --nocapture + + clippy_check: + needs: set-msrv + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ needs.set-msrv.outputs.msrv }} + components: clippy + - name: Install required packages + run: sudo apt install --no-install-recommends --yes ocl-icd-opencl-dev nvidia-cuda-dev + - name: Run cargo clippy default features + run: cargo clippy --workspace --all-targets -- -D warnings + - name: Run cargo clippy with cuda and opencl features + run: cargo clippy --workspace --all-targets --features cuda,opencl -- -D warnings + - name: Run cargo clippy with cuda feature + run: cargo clippy --workspace --all-targets --no-default-features --features cuda -- -D warnings + - name: Run cargo clippy with opencl feature + run: cargo clippy --workspace --all-targets --no-default-features --features opencl -- -D warnings + + check_fmt_and_docs: + needs: set-msrv + name: Checking fmt and docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ needs.set-msrv.outputs.msrv }} + components: rustfmt + - name: fmt + run: cargo fmt --all -- --check + - name: Docs + env: + # Making sure that the documentation can be built without having the NVIDIA toolkit + # installed. + DOCS_RS: true + run: | + cargo rustdoc --package ec-gpu --all-features -- -D warnings + cargo rustdoc --package ec-gpu-gen --all-features -- -D warnings