diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..921728c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,135 @@ +version: 2.1 + +executors: + default: + machine: + image: ubuntu-1604-cuda-10.1:201909-23 + 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: + test_target: + parameters: + target: + type: string + steps: + - *restore-workspace + - *restore-cache + - run: + name: Test (<< parameters.target >>) + command: TARGET=<< parameters.target >> cargo test + no_output_timeout: 15m + +jobs: + + cargo_fetch: + executor: default + steps: + - checkout + - run: curl https://sh.rustup.rs -sSf | sh -s -- -y + - run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV + - run: echo $BASH_ENV + - run: echo $HOME + - run: source $BASH_ENV + - 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_x86_64-unknown-linux-gnu: + executor: default + steps: + - run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV + - run: source $BASH_ENV + - run: sudo apt-get update -y + - run: apt-cache search opencl + - run: sudo apt install -y ocl-icd-opencl-dev + - test_target: + target: "x86_64-unknown-linux-gnu" + + rustfmt: + executor: default + steps: + - *restore-workspace + - *restore-cache + - run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV + - run: source $BASH_ENV + - run: + name: Run cargo fmt + command: cargo fmt --all -- --check + + clippy: + executor: default + steps: + - *restore-workspace + - *restore-cache + - run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV + - run: source $BASH_ENV + - run: + name: Run cargo clippy + command: cargo clippy --all-features + + build: + executor: default + steps: + - *restore-workspace + - *restore-cache + - run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV + - run: source $BASH_ENV + - run: + name: Run cargo release build + command: cargo build --release + + +workflows: + version: 2.1 + + test: + jobs: + - cargo_fetch + - rustfmt: + requires: + - cargo_fetch + - clippy: + requires: + - cargo_fetch + - test_x86_64-unknown-linux-gnu: + requires: + - cargo_fetch + - build: + requires: + - cargo_fetch diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..ee41258 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly-2020-01-08