diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fae1209..9ff9204 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,18 @@ -# image: scorpil/rust:stable +image: scorpil/rust:stable stages: - test +cargo:test: + stage: test + script: + - ci/run-cargo-test.sh + +rustfmt: + stage: test + script: + - ci/run-rustfmt.sh + shellcheck: stage: test image: ubuntu:yakkety @@ -13,4 +23,4 @@ shellcheck: - export LANGUAGE=en_US:en - export LC_ALL=en_US.UTF-8 script: - - find . -type f -name '*.sh' -print0 | xargs -n 1 -0 shellcheck --color + - ci/run-shellcheck.sh diff --git a/ci/run-cargo-test.sh b/ci/run-cargo-test.sh new file mode 100755 index 0000000..bc151bb --- /dev/null +++ b/ci/run-cargo-test.sh @@ -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} diff --git a/ci/run-rustfmt.sh b/ci/run-rustfmt.sh new file mode 100755 index 0000000..37403d1 --- /dev/null +++ b/ci/run-rustfmt.sh @@ -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} diff --git a/ci/run-shellcheck.sh b/ci/run-shellcheck.sh new file mode 100755 index 0000000..4a2de49 --- /dev/null +++ b/ci/run-shellcheck.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +find . -type f -name '*.sh' -print0 | xargs -n 1 -0 shellcheck --color