diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..568f493 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: rust +sudo: false +cache: + cargo +rust: + - stable + - beta + - nightly +before_install: + - bash ./tests/scripts/rustfmt.sh + +script: + - cargo fmt -- --write-mode diff + - cargo test +matrix: + allow_failures: + - rust: nightly diff --git a/tests/scripts/rustfmt.sh b/tests/scripts/rustfmt.sh new file mode 100644 index 0000000..6836314 --- /dev/null +++ b/tests/scripts/rustfmt.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +which rustfmt > /dev/null + +if [[ $? -ne 0 ]]; then + cargo install rustfmt +else + current_version=$(rustfmt --version | cut -d '-' -f 1 | xargs) + upstream_version=$(cargo search rustfmt | head -n 1 | cut -d ' ' -f 3 | tr -d '"' | xargs) + if [ $current_version != $upstream_version ]; then + cargo install rustfmt --force + fi +fi