From 0d144298eedaf259a6430386b3720d2b7d42211e Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Mon, 12 Apr 2021 14:13:42 -0500 Subject: [PATCH] Improve changelog check error handling --- .github/workflows/clippy_bors.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index 47253eecc4c..ae6f1aa1b30 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -34,15 +34,16 @@ jobs: run: | MESSAGE=$(git log --format=%B -n 1) PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//') - output=$(curl -H "Authorization: token ${{ secrets.GITHUB_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 + body=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \ + python -c "import sys, json; print(json.load(sys.stdin)['body'])") + output=$(grep "^changelog:\s*\S" <<< "$body" | sed "s/changelog:\s*//g") || { echo "ERROR: PR body must contain 'changelog: ...'" exit 1 - elif [[ "$output" = "none" ]]; then + } + if [[ "$output" = "none" ]]; then echo "WARNING: changelog is 'none'" + else + echo "changelog: $output" fi env: PYTHONIOENCODING: 'utf-8'