Skip to content

Commit

Permalink
CI runs clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Aug 15, 2018
1 parent d2d348d commit bdfe1e6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
13 changes: 11 additions & 2 deletions build-support/bin/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function usage() {
cat <<EOF
Runs commons tests for local or hosted CI.
Usage: $0 (-h|-3fxbkmrjlpuneycitz)
Usage: $0 (-h|-3fxbkmrjlpuneycitzs)
-h print out this help message
-3 After pants is bootstrapped, set --python-setup-interpreter-constraints such that any
python tests run with Python 3.
Expand All @@ -34,6 +34,7 @@ Usage: $0 (-h|-3fxbkmrjlpuneycitz)
to run only even tests: '-u 0/2', odd: '-u 1/2'
-n run contrib python tests
-e run rust tests
-s run clippy on rust code
-y SHARD_NUMBER/TOTAL_SHARDS
if running contrib python tests, divide them into
TOTAL_SHARDS shards and just run those in SHARD_NUMBER
Expand Down Expand Up @@ -64,7 +65,7 @@ python_contrib_shard="0/1"
python_intg_shard="0/1"
python_three="false"

while getopts "h3fxbkmrjlpeu:ny:ci:tz" opt; do
while getopts "h3fxbkmrjlpesu:ny:ci:tz" opt; do
case ${opt} in
h) usage ;;
3) python_three="true" ;;
Expand All @@ -79,6 +80,7 @@ while getopts "h3fxbkmrjlpeu:ny:ci:tz" opt; do
p) run_python="true" ;;
u) python_unit_shard=${OPTARG} ;;
e) run_rust_tests="true" ;;
s) run_rust_clippy="true" ;;
n) run_contrib="true" ;;
y) python_contrib_shard=${OPTARG} ;;
c) run_integration="true" ;;
Expand Down Expand Up @@ -231,6 +233,13 @@ if [[ "${run_rust_tests:-false}" == "true" ]]; then
end_travis_section
fi

if [[ "${run_rust_clippy:-false}" == "true" ]]; then
start_travis_section "RustClippy" "Running Clippy on rust code"
(
"${REPO_ROOT}/build-support/bin/native/cargo" +nightly clippy --manifest-path="${REPO_ROOT}/src/rust/engine/Cargo.toml" --all
) || die "Pants clippy failure"
fi

# NB: this only tests python tests right now -- the command needs to be edited if test targets in
# other languages are tagged with 'platform_specific_behavior' in the future.
if [[ "${test_platform_specific_behavior:-false}" == 'true' ]]; then
Expand Down
21 changes: 13 additions & 8 deletions build-support/bin/native/bootstrap_rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../../.. && pwd -P)"
# + fingerprint_data: Fingerprints the data on stdin.
source "${REPO_ROOT}/build-support/common.sh"

RUST_TOOLCHAIN="$(cat ${REPO_ROOT}/rust-toolchain)"
readonly RUST_COMPONENTS=(
"rustfmt-preview"
"rust-src"
)

readonly rust_toolchain_root="${CACHE_ROOT}/rust"
export CARGO_HOME="${rust_toolchain_root}/cargo"
export RUSTUP_HOME="${rust_toolchain_root}/rustup"
Expand All @@ -24,6 +18,17 @@ function cargo_bin() {
}

function bootstrap_rust() {
RUST_TOOLCHAIN="$(cat ${REPO_ROOT}/rust-toolchain)"
RUST_COMPONENTS=(
"rustfmt-preview"
"rust-src"
)

if [[ "$#" -eq 1 && "$1" == "+nightly" ]]; then
RUST_TOOLCHAIN="nightly"
RUST_COMPONENTS=("${RUST_COMPONENTS[@]}" "clippy-preview")
fi

# Control a pants-specific rust toolchain.
if [[ ! -x "${RUSTUP}" ]]
then
Expand All @@ -39,15 +44,15 @@ function bootstrap_rust() {
local -r cargo="${CARGO_HOME}/bin/cargo"
local -r cargo_components_fp=$(echo "${RUST_COMPONENTS[@]}" | fingerprint_data)
local -r cargo_versioned="cargo-${RUST_TOOLCHAIN}-${cargo_components_fp}"
if [[ ! -x "${rust_toolchain_root}/${cargo_versioned}" ]]
if [[ ! -x "${rust_toolchain_root}/${cargo_versioned}" || "${RUST_TOOLCHAIN}" == "nightly" ]]
then
# If rustup was already bootstrapped against a different toolchain in the past, freshen it and
# ensure the toolchain and components we need are installed.
"${RUSTUP}" self update
"${RUSTUP}" toolchain install ${RUST_TOOLCHAIN}
"${RUSTUP}" component add --toolchain ${RUST_TOOLCHAIN} ${RUST_COMPONENTS[@]} >&2

ln -fs "$(cargo_bin)" "${rust_toolchain_root}/${cargo_versioned}"
ln -fs "$(RUSTUP_TOOLCHAIN="${RUST_TOOLCHAIN}" cargo_bin)" "${rust_toolchain_root}/${cargo_versioned}"
fi

local -r symlink_farm_root="${REPO_ROOT}/build-support/bin/native"
Expand Down
8 changes: 7 additions & 1 deletion build-support/bin/native/cargo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ REPO_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}") && cd ../../.. && pwd -P)
# Exposes:
# + bootstrap_rust: Bootstraps a Pants-controlled rust toolchain and associated extras.
source "${REPO_ROOT}/build-support/bin/native/bootstrap_rust.sh"
bootstrap_rust >&2

nightly=""
if [[ "$@" =~ '+nightly' ]]; then
nightly="+nightly"
fi

bootstrap_rust "${nightly}" >&2

download_binary="${REPO_ROOT}/build-support/bin/download_binary.sh"

Expand Down

0 comments on commit bdfe1e6

Please sign in to comment.