Skip to content

Commit

Permalink
test: add circleci configs
Browse files Browse the repository at this point in the history
  • Loading branch information
keyvank committed Apr 29, 2020
1 parent 859fe1b commit 4876133
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
135 changes: 135 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2020-01-08

0 comments on commit 4876133

Please sign in to comment.