added ci scripts for rust

This commit is contained in:
Simon Wörner
2017-03-30 21:55:00 +02:00
parent d877ec774f
commit 80934a5c70
4 changed files with 44 additions and 2 deletions

View File

@@ -1,8 +1,18 @@
# image: scorpil/rust:stable image: scorpil/rust:stable
stages: stages:
- test - test
cargo:test:
stage: test
script:
- ci/run-cargo-test.sh
rustfmt:
stage: test
script:
- ci/run-rustfmt.sh
shellcheck: shellcheck:
stage: test stage: test
image: ubuntu:yakkety image: ubuntu:yakkety
@@ -13,4 +23,4 @@ shellcheck:
- export LANGUAGE=en_US:en - export LANGUAGE=en_US:en
- export LC_ALL=en_US.UTF-8 - export LC_ALL=en_US.UTF-8
script: script:
- find . -type f -name '*.sh' -print0 | xargs -n 1 -0 shellcheck --color - ci/run-shellcheck.sh

16
ci/run-cargo-test.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
ERROR=0
while IFS= read -r -d '' f; do
dir="$(dirname "${f}")"
echo "run 'cargo test' in ${dir}"
cd "${dir}" && cargo test
if [[ $? -ne 0 ]]; then
ERROR=1
fi
done < <(find . -type f -name 'Cargo.toml' -print0)
exit ${ERROR}

13
ci/run-rustfmt.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
ERROR=0
while IFS= read -r -d '' f; do
echo "${f}"
if [ "$(rustfmt --write-mode=diff "$f")" != $'' ] ; then
ERROR=1
fi
done < <(find . -type f -name '*.rs' -print0)
exit ${ERROR}

3
ci/run-shellcheck.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
find . -type f -name '*.sh' -print0 | xargs -n 1 -0 shellcheck --color