Skip to content

Commit

Permalink
chore(ci): add travis ci
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroqn committed Mar 6, 2019
1 parent bc844c7 commit 9dca349
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language: rust
sudo: true
cache:
cargo: true
timeout: 1024

git:
depth: 2
submodules: false

if: 'branch IN (master, develop, staging, trying) OR type != push OR fork = true OR tag =~ ^v'

env:
global:
- RUST_BACKTRACE=full

matrix:
include:
- rust: 1.33.0
os: osx
env: FMT=true CHECK=true TEST=true
- rust: 1.33.0
os: linux
env: FMT=true CHECK=true TEST=true

install: ./devtools/ci/install.sh
script: ./devtools/ci/script.sh

before_cache:
- rm -rf ./target/debug/incremental/
- cargo sweep -f
52 changes: 52 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
VERBOSE := $(if ${CI},--verbose,)

test:
cargo test ${VERBOSE} --all -- --nocapture

doc:
cargo doc --all --no-deps

doc-deps:
cargo doc --all

check:
cargo check ${VERBOSE} --all

build:
cargo build ${VERBOSE} --release

prod:
cargo build ${VERBOSE} --release

prod-test:
cargo test ${VERBOSE} --all -- --nocapture

fmt:
cargo fmt ${VERBOSE} --all -- --check

clippy:
cargo clippy ${VERBOSE} --all --all-targets --all-features -- -D warnings -D clippy::clone_on_ref_ptr -D clippy::enum_glob_use


ci: fmt clippy test
git diff --exit-code Cargo.lock

info:
date
pwd
env

# For counting lines of code
stats:
@cargo count --version || cargo +nightly install --git https://github.com/kbknapp/cargo-count
@cargo count --separator , --unsafe-statistics

# Use cargo-audit to audit Cargo.lock for crates with security vulnerabilities
# expecting to see "Success No vulnerable packages found"
security-audit:
@cargo audit --version || cargo install cargo-audit
@cargo audit

.PHONY: build prod prod-test
.PHONY: fmt test clippy doc doc-deps check stats
.PHONY: ci info security-audit
12 changes: 12 additions & 0 deletions devtools/ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -ev

cargo sweep --version || cargo install --git https://github.com/holmgr/cargo-sweep --rev 3e98dbf7e4ddf1e07dd2526a803c501fd549da75

if [ "$FMT" = true ]; then
cargo fmt --version || rustup component add rustfmt
fi

if [ "$CHECK" = true ]; then
cargo clippy --version || rustup component add clippy
fi
17 changes: 17 additions & 0 deletions devtools/ci/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -ev

cargo sweep -s

if [ "$FMT" = true ]; then
make fmt
fi
if [ "$CHECK" = true ]; then
make check
make clippy
fi
if [ "$TEST" = true ]; then
make test
fi

git diff --exit-code Cargo.lock

0 comments on commit 9dca349

Please sign in to comment.