How to get notification if package fails to build on Hydra?

Is there any way to get notification when package fails to build on Hydra or the build succeeds after previous failures ?

Recently, some of the packages which I maintain got broken due to change in dependencies (which I don’t maintain) and I didn’t know about that. Next time, I want to know immediately when Hydra build starts failing.

Any suggestions ?

3 Likes

Common request that seems to come up about once a year:

The most-succinct comment I recall seeing on the issue/status is probably:

2 Likes

Thank you very much. Sorry for not searching by myself.

If you want to get the list of all packages failing on Hydra that you maintain, Hydra failures (7c6f434c) seems to be at least something.

2 Likes

I made simple Hydra web scraping script which will print last build status of package

#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3Packages.requests python3Packages.beautifulsoup4

import sys

import requests
from bs4 import BeautifulSoup


pkgs = sys.argv[1:]


exit_code = 0
for pkg in pkgs:
    URL = f"https://hydra.nixos.org/job/nixpkgs/trunk/{pkg}.x86_64-linux/all"
    page = requests.get(URL)

    soup = BeautifulSoup(page.content, "html.parser")

    results_table = soup.find("table", class_="table")
    build_results = results_table.find_all("tr")
    build_result = build_results[1].find_all("td")
    build_status = build_result[0].img["alt"]

    print(f"{pkg} - {build_status}")

    if build_status != "Succeeded": exit_code = 1

sys.exit(exit_code)

Example:

$ ./hydra-build-status.py gdal pdal qgis qgis-ltr
gdal - Succeeded
pdal - Succeeded
qgis - Cancelled
qgis-ltr - Dependency failed

EDIT: Script will end with exit code 1 if Hydra build is not successful for some package. You can run it in your CI and it will notify you with failure.

1 Like

I ended up implementing this Github Action which gives me this output .

Action runs 12 hours. I hope it wouldn’t put too much load on Hydra server, especially when more people will use it.

1 Like

I expect it would be a bit more efficient to use /latest instead of /all, but hopefully it’s not significant anyway.

2 Likes