Skip to content

Commit

Permalink
improve script
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Oct 12, 2019
1 parent d2661af commit f23309a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 61 deletions.
23 changes: 11 additions & 12 deletions .github/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ if [ -n "$TRAVIS_TAG" ]; then
fi

# Generate version index that is shown as root index page
(
cp util/gh-pages/versions.html out/index.html

cd out
python -c '\
import os, json;\
print json.dumps([\
dir for dir in os.listdir(".")\
if not dir.startswith(".") and os.path.isdir(dir)\
])' > versions.json
)
cp util/gh-pages/versions.html out/index.html
pushd out

cat <<-EOF | python - > versions.json
import os, json
print json.dumps([
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
])
EOF
popd

# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
Expand All @@ -60,7 +59,7 @@ ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d
chmod 600 .github/deploy_key
eval $(ssh-agent -s)
eval "$(ssh-agent -s)"
ssh-add .github/deploy_key

# Now let's go have some fun with the cloned repo
Expand Down
16 changes: 9 additions & 7 deletions ci/base-tests.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env bash
set -ex

echo "Running clippy base tests"

PATH=$PATH:./node_modules/.bin
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
remark -f *.md -f doc/*.md > /dev/null
remark -f ./*.md -f doc/*.md > /dev/null
fi
# build clippy in debug mode and run tests
cargo build --features "debugging deny-warnings"
cargo test --features "debugging deny-warnings"
# for faster build, share target dir between subcrates
export CARGO_TARGET_DIR=`pwd`/target/
CARGO_TARGET_DIR=$(pwd)/target/
export CARGO_TARGET_DIR
(cd clippy_lints && cargo test)
(cd rustc_tools_util && cargo test)
(cd clippy_dev && cargo test)
Expand All @@ -29,25 +31,25 @@ export CARGO_TARGET_DIR=`pwd`/target/
(
# Check sysroot handling
sysroot=$(./target/debug/clippy-driver --print sysroot)
test $sysroot = $(rustc --print sysroot)
test "$sysroot" = "$(rustc --print sysroot)"

if [ -z $OS_WINDOWS ]; then
if [ -z "$OS_WINDOWS" ]; then
desired_sysroot=/tmp
else
desired_sysroot=C:/tmp
fi
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
test $sysroot = $desired_sysroot
test "$sysroot" = $desired_sysroot

sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
test $sysroot = $desired_sysroot
test "$sysroot" = $desired_sysroot

# Make sure this isn't set - clippy-driver should cope without it
unset CARGO_MANIFEST_DIR

# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
# XXX How to match the clippy invocation in compile-test.rs?
! ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
diff <(sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr) tests/ui/cstring.stderr

# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
Expand Down
8 changes: 4 additions & 4 deletions ci/integration-tests.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env bash
set -x
rm ~/.cargo/bin/cargo-clippy
cargo install --force --path .

echo "Running integration test for crate ${INTEGRATION}"

git clone --depth=1 https://github.com/${INTEGRATION}.git checkout
cd checkout
git clone --depth=1 https://github.com/"${INTEGRATION}".git checkout
cd checkout || exit

function check() {
# run clippy on a project, try to be verbose and trigger as many warnings as possible for greater coverage
RUST_BACKTRACE=full cargo clippy --all-targets --all-features -- --cap-lints warn -W clippy::pedantic -W clippy::nursery &> clippy_output
cat clippy_output
! cat clippy_output | grep -q "internal compiler error\|query stack during panic\|E0463"
if [[ $? != 0 ]]; then
if ! grep -q "internal compiler error\|query stack during panic\|E0463" clippy_output; then
return 1
fi
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ui-toml/update-all-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ if [[ "$1" == "--help" || "$1" == "-h" ]]; then
fi

BUILD_DIR=$PWD/target/debug/test_build_base
MY_DIR=$(dirname $0)
cd $MY_DIR
find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR
MY_DIR=$(dirname "$0")
cd "$MY_DIR" || exit
find . -name '*.rs' -exec ./update-references.sh "$BUILD_DIR" {} +
20 changes: 9 additions & 11 deletions tests/ui-toml/update-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
fi

MYDIR=$(dirname $0)
MYDIR=$(dirname "$0")

BUILD_DIR="$1"
shift
Expand All @@ -25,16 +25,14 @@ while [[ "$1" != "" ]]; do
STDERR_NAME="${1/%.rs/.stderr}"
STDOUT_NAME="${1/%.rs/.stdout}"
shift
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
echo updating $MYDIR/$STDOUT_NAME
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
if [ -f "$BUILD_DIR"/"$STDOUT_NAME" ] && \
! (diff "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME" >& /dev/null); then
echo updating "$MYDIR"/"$STDOUT_NAME"
cp "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"
fi
if [ -f $BUILD_DIR/$STDERR_NAME ] && \
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
echo updating $MYDIR/$STDERR_NAME
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
if [ -f "$BUILD_DIR"/"$STDERR_NAME" ] && \
! (diff "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME" >& /dev/null); then
echo updating "$MYDIR"/"$STDERR_NAME"
cp "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"
fi
done


6 changes: 3 additions & 3 deletions tests/ui/update-all-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ if [[ "$1" == "--help" || "$1" == "-h" ]]; then
fi

BUILD_DIR=$PWD/target/debug/test_build_base
MY_DIR=$(dirname $0)
cd $MY_DIR
find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR
MY_DIR=$(dirname "$0")
cd "$MY_DIR" || exit
find . -name '*.rs' -exec ./update-references.sh "$BUILD_DIR" {} +
28 changes: 13 additions & 15 deletions tests/ui/update-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
fi

MYDIR=$(dirname $0)
MYDIR=$(dirname "$0")

BUILD_DIR="$1"
shift
Expand All @@ -26,21 +26,19 @@ while [[ "$1" != "" ]]; do
STDOUT_NAME="${1/%.rs/.stdout}"
FIXED_NAME="${1/%.rs/.fixed}"
shift
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
echo updating $MYDIR/$STDOUT_NAME
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
if [ -f "$BUILD_DIR"/"$STDOUT_NAME" ] && \
! (diff "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME" >& /dev/null); then
echo updating "$MYDIR"/"$STDOUT_NAME"
cp "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"
fi
if [ -f $BUILD_DIR/$STDERR_NAME ] && \
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
echo updating $MYDIR/$STDERR_NAME
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
if [ -f "$BUILD_DIR"/"$STDERR_NAME" ] && \
! (diff "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME" >& /dev/null); then
echo updating "$MYDIR"/"$STDERR_NAME"
cp "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"
fi
if [ -f $BUILD_DIR/$FIXED_NAME ] && \
! (diff $BUILD_DIR/$FIXED_NAME $MYDIR/$FIXED_NAME >& /dev/null); then
echo updating $MYDIR/$FIXED_NAME
cp $BUILD_DIR/$FIXED_NAME $MYDIR/$FIXED_NAME
if [ -f "$BUILD_DIR"/"$FIXED_NAME" ] && \
! (diff "$BUILD_DIR"/"$FIXED_NAME" "$MYDIR"/"$FIXED_NAME" >& /dev/null); then
echo updating "$MYDIR"/"$FIXED_NAME"
cp "$BUILD_DIR"/"$FIXED_NAME" "$MYDIR"/"$FIXED_NAME"
fi
done


12 changes: 6 additions & 6 deletions util/fetch_prs_between.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Fetches the merge commits between two git commits and prints the PR URL
# together with the full commit message
Expand All @@ -12,14 +12,14 @@ last=$2
IFS='
'
for pr in $(git log --oneline --grep "Merge #" --grep "Merge pull request" --grep "Auto merge of" --grep "Rollup merge of" "$first...$last" | sort -rn | uniq); do
id=$(echo $pr | rg -o '#[0-9]{3,5}' | cut -c 2-)
commit=$(echo $pr | cut -d' ' -f 1)
message=$(git --no-pager show --pretty=medium $commit)
if [ ! -z $(echo "$message" | rg "^[\s]{4}changelog: [nN]one\.*$") ]; then
id=$(echo "$pr" | rg -o '#[0-9]{3,5}' | cut -c 2-)
commit=$(echo "$pr" | cut -d' ' -f 1)
message=$(git --no-pager show --pretty=medium "$commit")
if [[ -n $(echo "$message" | rg "^[\s]{4}changelog: [nN]one\.*$") ]]; then
continue
fi

echo "URL: https://github.com/rust-lang/rust-clippy/pull/$id"
echo "$message"
echo "---------------------------------------------------------\n"
printf "---------------------------------------------------------\n\n"
done

0 comments on commit f23309a

Please sign in to comment.