From 28bc37e485fdda0603a27a3ee0d65e3b9a6e473a Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Fri, 3 Jan 2025 14:56:16 -0800 Subject: [PATCH] Fix jq error and master not found issue --- .github/workflows/rustc.yml | 2 ++ scripts/check_rustc.sh | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rustc.yml b/.github/workflows/rustc.yml index 96dca730e84ac..abc2a1a31552b 100644 --- a/.github/workflows/rustc.yml +++ b/.github/workflows/rustc.yml @@ -30,4 +30,6 @@ jobs: uses: actions/checkout@v4 - name: Run rustc script + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./scripts/check_rustc.sh diff --git a/scripts/check_rustc.sh b/scripts/check_rustc.sh index 1d7e0fc4152e4..a57e416ef3c2d 100755 --- a/scripts/check_rustc.sh +++ b/scripts/check_rustc.sh @@ -46,12 +46,25 @@ cd "$REPO_DIR" # Get the commit ID from rustc --version echo "Retrieving commit ID..." COMMIT_ID=$(rustc --version | sed -e "s/.*(\(.*\) .*/\1/") -echo "$COMMIT_ID for rustc is" # Get the full commit ID for shallow clone -curl -H "Connection: close" -o "${TMP_RUST_DIR}/output.json" -s --show-error \ - "https://api.github.com/repos/rust-lang/rust/commits?sha=${COMMIT_ID}&per_page=1" -COMMIT_ID=$(jq -r '.[0].sha' "${TMP_RUST_DIR}/output.json") +echo "Full commit id for $COMMIT_ID for is:" + +if [ -z "${GH_TOKEN:-}" ]; then + curl -o "${TMP_RUST_DIR}/output.json" -s --show-error \ + "https://api.github.com/repos/rust-lang/rust/commits?sha=${COMMIT_ID}&per_page=1" +else + # Use token if possible to avoid being throttled + curl -o "${TMP_RUST_DIR}/output.json" -s --show-error \ + --request GET \ + --url "https://api.github.com/repos/rust-lang/rust/commits?sha=${COMMIT_ID}&per_page=1" \ + --header "Accept: application/vnd.github+json" \ + --header "Authorization: Bearer $GH_TOKEN" +fi +cat "${TMP_RUST_DIR}/output.json" # Dump the file in case `curl` fails. + +COMMIT_ID=$(cat "${TMP_RUST_DIR}/output.json" | jq -r '.[0].sha') +echo "- $COMMIT_ID" # Clone the rust-lang/rust repository echo "Cloning rust-lang/rust repository into ${TMP_RUST_DIR}..." @@ -74,6 +87,8 @@ cp -r "${REPO_DIR}/library" "${TMP_RUST_DIR}" pushd "${TMP_RUST_DIR}" ./configure --set=llvm.download-ci-llvm=true export RUSTFLAGS="--check-cfg cfg(kani) --check-cfg cfg(feature,values(any()))" +export RUST_BACKTRACE=1 +unset GITHUB_ACTIONS # Bootstrap script requires specific repo layout when run from an action. Disable that. # Run tidy if [ "${TIDY_MODE}" == "--bless" ];