-
Notifications
You must be signed in to change notification settings - Fork 1.7k
build: improve script and travis config #4675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b869eeb
abafec5
f3ace5e
049800d
ba673d0
629b4d5
088d528
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,7 @@ SSH_REPO=${REPO/https:\/\/github.com\//[email protected]:} | |
SHA=$(git rev-parse --verify HEAD) | ||
|
||
# Clone the existing gh-pages for this repo into out/ | ||
( | ||
git clone "$REPO" out | ||
cd out | ||
git checkout $TARGET_BRANCH | ||
) | ||
git clone --quiet --single-branch --branch "$TARGET_BRANCH" "$REPO" out | ||
|
||
echo "Removing the current docs for master" | ||
rm -rf out/master/ || exit 0 | ||
|
@@ -27,35 +23,44 @@ mkdir out/master/ | |
cp util/gh-pages/index.html out/master | ||
python ./util/export.py out/master/lints.json | ||
|
||
if [ -n "$TRAVIS_TAG" ]; then | ||
if [[ -n "$TRAVIS_TAG" ]]; then | ||
echo "Save the doc for the current tag ($TRAVIS_TAG) and point current/ to it" | ||
cp -r out/master "out/$TRAVIS_TAG" | ||
rm -f out/current | ||
ln -s "$TRAVIS_TAG" out/current | ||
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) | ||
tesuji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
]) | ||
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 | ||
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] || [[ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]]; then | ||
# Tags should deploy | ||
if [ -z "$TRAVIS_TAG" ]; then | ||
if [[ -z "$TRAVIS_TAG" ]]; then | ||
echo "Generated, won't push" | ||
exit 0 | ||
fi | ||
fi | ||
|
||
# Now let's go have some fun with the cloned repo | ||
cd out | ||
git config user.name "Travis CI" | ||
git config user.email "[email protected]" | ||
|
||
if git diff --exit-code --quiet; then | ||
echo "No changes to the output on this push; exiting." | ||
exit 0 | ||
fi | ||
|
||
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc | ||
ENCRYPTION_LABEL=e3a2d77100be | ||
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" | ||
|
@@ -64,19 +69,9 @@ 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)" | ||
flip1995 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ssh-add .github/deploy_key | ||
|
||
# Now let's go have some fun with the cloned repo | ||
cd out | ||
git config user.name "Travis CI" | ||
git config user.email "[email protected]" | ||
|
||
if [ -z "$(git diff --exit-code)" ]; then | ||
echo "No changes to the output on this push; exiting." | ||
exit 0 | ||
fi | ||
|
||
git add . | ||
git commit -m "Automatic deploy to GitHub Pages: ${SHA}" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
dist: xenial | ||
language: bash | ||
|
||
os: | ||
- linux | ||
- osx | ||
- windows | ||
|
||
branches: | ||
# Don't build these branches | ||
except: | ||
|
@@ -34,13 +29,12 @@ install: | |
if ! rustup component add rustfmt; then | ||
cargo install -Z install-upgrade --git https://github.com/rust-lang/rustfmt --bin rustfmt | ||
fi | ||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then | ||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then | ||
. $HOME/.nvm/nvm.sh | ||
nvm install stable | ||
nvm use stable | ||
npm install remark-cli remark-lint | ||
fi | ||
if [ "$TRAVIS_OS_NAME" == "windows" ]; then | ||
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then | ||
choco install windows-sdk-10.1 | ||
fi | ||
fi | ||
|
@@ -53,11 +47,9 @@ matrix: | |
include: | ||
# Builds that are executed for every PR | ||
- os: osx # run base tests on both platforms | ||
env: BASE_TESTS=true | ||
- os: linux | ||
env: BASE_TESTS=true | ||
- os: windows | ||
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true | ||
env: CARGO_INCREMENTAL=0 OS_WINDOWS=true | ||
|
||
# Builds that are only executed when a PR is r+ed or a try build is started | ||
# We don't want to run these always because they go towards | ||
|
@@ -95,51 +87,51 @@ matrix: | |
if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) | ||
allow_failures: | ||
- os: windows | ||
env: CARGO_INCREMENTAL=0 BASE_TESTS=true OS_WINDOWS=true | ||
# prevent these jobs with default env vars | ||
exclude: | ||
- os: linux | ||
- os: osx | ||
- os: windows | ||
env: CARGO_INCREMENTAL=0 OS_WINDOWS=true | ||
|
||
before_script: | ||
- | | ||
if [ "$TRAVIS_BRANCH" == "auto" ] || [ "$TRAVIS_BRANCH" == "try" ]; then | ||
pr=$(echo $TRAVIS_COMMIT_MESSAGE | grep -o "#[0-9]*" | head -1 | sed 's/^#//g') | ||
output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$pr" | \ | ||
if [[ "$TRAVIS_BRANCH" == "auto" ]] || [[ "$TRAVIS_BRANCH" == "try" ]]; then | ||
PR=$(echo "$TRAVIS_COMMIT_MESSAGE" | grep -o "#[0-9]*" | head -1 | sed 's/^#//g') | ||
output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \ | ||
python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \ | ||
grep "^changelog: " | \ | ||
sed "s/changelog: //g") | ||
if [ -z "$output" ]; then | ||
if [[ -z "$output" ]]; then | ||
echo "ERROR: PR body must contain 'changelog: ...'" | ||
exit 1 | ||
elif [ "$output" = "none" ]; then | ||
elif [[ "$output" = "none" ]]; then | ||
echo "WARNING: changelog is 'none'" | ||
fi | ||
fi | ||
- | | ||
rm rust-toolchain | ||
./setup-toolchain.sh | ||
- | | ||
if [ "$TRAVIS_OS_NAME" == "windows" ]; then | ||
export PATH=$PATH:$(rustc --print sysroot)/bin | ||
else | ||
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib | ||
fi | ||
SYSROOT=$(rustc --print sysroot) | ||
case "$TRAVIS_OS_NAME" in | ||
windows ) export PATH="${SYSROOT}/bin:${PATH}" ;; | ||
linux ) export LD_LIBRARY_PATH="${SYSROOT}/lib" ;; | ||
osx ) | ||
# See <https://github.com/nteract/nteract/issues/1523#issuecomment-301623519> | ||
sudo mkdir -p /usr/local/lib | ||
sudo find "$SYSROOT/lib" -maxdepth 1 -name '*.dylib' -exec ln -s {} /usr/local/lib \; | ||
;; | ||
Comment on lines
+115
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't necessary before. What changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I don't know. I tried to set LD_LIBRARY_PATH, LIBRARY_PATH, DYLD_LIBRARY_PATH. All of that still made this PR failed. |
||
esac | ||
|
||
script: | ||
- | | ||
if [ -z ${INTEGRATION} ]; then | ||
travis_wait 30 ./ci/base-tests.sh && sleep 5 | ||
else | ||
if [[ -n ${INTEGRATION} ]]; then | ||
./ci/integration-tests.sh && sleep 5 | ||
else | ||
./ci/base-tests.sh && sleep 5 | ||
fi | ||
|
||
after_success: | ||
- | | ||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then | ||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then | ||
set -e | ||
if [ -z ${INTEGRATION} ]; then | ||
if [[ -z ${INTEGRATION} ]]; then | ||
./.github/deploy.sh | ||
else | ||
echo "Not deploying, because we're in an integration test run" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# for faster build, share target dir between subcrates | ||
CARGO_TARGET_DIR=$(pwd)/target/ | ||
export CARGO_TARGET_DIR | ||
|
||
echo "Running clippy base tests" | ||
|
||
PATH=$PATH:./node_modules/.bin | ||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then | ||
remark -f *.md -f doc/*.md > /dev/null | ||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then | ||
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/ | ||
|
||
(cd clippy_lints && cargo test) | ||
(cd rustc_tools_util && cargo test) | ||
(cd clippy_dev && cargo test) | ||
|
@@ -29,26 +33,27 @@ 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what this command does. Could someone explain it to me? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole block checks if This command is just a test, if the output of I guess all these flags are there to simulate the behavior of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PR that added this has some more context. Maybe include the PR link in the comment? |
||
diff <(sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr) tests/ui/cstring.stderr | ||
# FIXME: 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 && exit 1 | ||
sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr | ||
diff normalized.stderr tests/ui/cstring.stderr | ||
|
||
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/bin/sh | ||
CARGO_TARGET_DIR=$(pwd)/target/ | ||
export CARGO_TARGET_DIR | ||
|
||
cd clippy_dev && cargo run -- $@ | ||
cd clippy_dev && cargo run -- "$@" |
Uh oh!
There was an error while loading. Please reload this page.