Skip to content

Instantly share code, notes, and snippets.

@Nemo157
Last active July 16, 2022 12:13
Show Gist options
  • Save Nemo157/f35784c5ae2577894d38505f7ac5db7c to your computer and use it in GitHub Desktop.
Save Nemo157/f35784c5ae2577894d38505f7ac5db7c to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
# Find recent build failures containing a specific message by scraping the
# website for builds since a specific nightly (exclusive)
#
# ./scrape-recent-failures 2022-03-23 'no entry found for key' > fails
set -euo pipefail
nightly="${1:?missing argument 1: date of last nightly before the problem}"
message="${2:?missing argument 2: message to check for}"
for page in {1..20}
do
echo "Listing page $page" >&2
curl -sS https://docs.rs/releases/recent-failures/$page \
| pup -p '.release .name text{}' \
| while read -r l
do
crate="${l%-*}"
version="${l##*-}"
curl -sS https://docs.rs/crate/$crate/$version/builds \
| pup 'li:first-of-type .release attr{href}' \
| while read -r l
do
echo "Checking $crate @ $version" >&2
log="$(curl -sS https://docs.rs$l | pup -p 'pre text{}')"
if (echo "$log" | egrep -qs "rustc 1\\.[0-9]+\\.[0-9]+-nightly \\([0-9a-f]+ $nightly\\)")
then
echo "Completed searching till $nightly" >&2
exit
fi
if (echo "$log" | grep -qsF "$message")
then
echo "Matched $crate @ $version" >&2
echo $crate $version
fi
sleep 1
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment