From a0f6c9361b6ad653ebee27b73d63cb966be33d40 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 25 Apr 2019 15:45:52 +0200 Subject: [PATCH 1/4] Check PRs for changelog entry in the body --- .travis.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3f7c856a7f762..ba8fad5f31771 100644 --- a/.travis.yml +++ b/.travis.yml @@ -88,6 +88,19 @@ matrix: - os: windows script: + - | + if [ "$TRAVIS_BRANCH" == "auto" ] || [ "$TRAVIS_BRANCH" == "try" ]; then + output=$(curl -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$TRAVIS_PULL_REQUEST" | \ + python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \ + grep "changelog: " | \ + sed "s/changelog: //g") + if [ -z "$output" ]; then + echo "ERROR: PR body must contain 'changelog: ...'" + exit 1 + elif [ "$output" = "none" ]; then + echo "WARNING: changelog is 'none'" + fi + fi - | rm rust-toolchain ./setup-toolchain.sh From cb6cec5695eff8ed58139b87075c0f05278d28e6 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 25 Apr 2019 17:08:20 +0200 Subject: [PATCH 2/4] Authenticate with github_api_token --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ba8fad5f31771..6629f92a09089 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ branches: env: global: - RUST_BACKTRACE=1 + - secure: "OKulfkA5OGd/d1IhvBKzRkHQwMcWjzrzbimo7+5NhkUkWxndAzl+719TB3wWvIh1i2wXXrEXsyZkXM5FtRrHm55v1VKQ5ibjEvFg1w3NIg81iDyoLq186fLqywvxGkOAFPrsePPsBj5USd5xvhwwbrjO6L7/RK6Z8shBwOSc41s=" install: - | @@ -90,7 +91,7 @@ matrix: script: - | if [ "$TRAVIS_BRANCH" == "auto" ] || [ "$TRAVIS_BRANCH" == "try" ]; then - output=$(curl -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$TRAVIS_PULL_REQUEST" | \ + output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$TRAVIS_PULL_REQUEST" | \ python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \ grep "changelog: " | \ sed "s/changelog: //g") From 61ca901e51be911ccc0664ffcfb908f8f477658b Mon Sep 17 00:00:00 2001 From: flip1995 Date: Sat, 15 Jun 2019 13:54:46 +0200 Subject: [PATCH 3/4] Get PR number from bors commit message --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6629f92a09089..12c9f512f569e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -91,7 +91,8 @@ matrix: script: - | if [ "$TRAVIS_BRANCH" == "auto" ] || [ "$TRAVIS_BRANCH" == "try" ]; then - output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$TRAVIS_PULL_REQUEST" | \ + 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") From 1c87df486e44f46ef1860b497e9cc538bae09545 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 18 Jun 2019 12:14:02 +0200 Subject: [PATCH 4/4] grep only lines, that start with 'changelog: ' --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 12c9f512f569e..0a1bd0ea2750c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ script: 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: " | \ + grep "^changelog: " | \ sed "s/changelog: //g") if [ -z "$output" ]; then echo "ERROR: PR body must contain 'changelog: ...'"