Skip to content

Reorder Pull request CI steps#4896

Merged
frankharkins merged 3 commits intomainfrom
FH/reorder-pr-ci
Mar 27, 2026
Merged

Reorder Pull request CI steps#4896
frankharkins merged 3 commits intomainfrom
FH/reorder-pr-ci

Conversation

@frankharkins
Copy link
Copy Markdown
Member

@frankharkins frankharkins commented Mar 27, 2026

This PR re-orders the main PR CI steps by how likely they are to fail. This should reduce CI time and help contributors get feedback faster. It also pushes the Playwright and ImageMagick install steps to just before they're required, rather than at the beginning.

Here are the failure reasons for the last 500 failed runs:

Script used
import subprocess
from collections import defaultdict
from time import sleep

LIMIT = 500

run_ids = (
    subprocess.run(
        f"gh run list --workflow='Pull request' --status=failure --limit {LIMIT} --json databaseId | jq '.[] | .databaseId'",
        shell=True,
        check=True,
        capture_output=True,
    )
    .stdout.decode()
    .strip()
    .split("\n")
)


def get_failure_step(run_id: str) -> str:
    reason = (
        subprocess.run(
            f'gh run view {run_id} --json jobs | jq \'.jobs[] | select( .name == "Lint" ) | select( .conclusion == "failure" ) | .steps[] | select( .conclusion == "failure" ) | .name\'',
            shell=True,
            check=True,
            capture_output=True,
        )
        .stdout.decode()
        .strip()
        .strip('"')
    )
    return reason

sums = defaultdict(int)
for index, num in enumerate(run_ids):
    sleep(1)
    print(f"Getting run {index}/{len(run_ids)}")
    try:
        reason = get_failure_step(num)
        if reason == "":
            continue
        sums[reason] += 1
    except Exception as err:
        print(f"Error: {err}")
        pass

items = [(count, name) for (name, count) in sums.items()]
for count, name in sorted(items, key=lambda x: -x[0]):
    print(f"{str(count).rjust(5)} {name}")
107 Internal link checker
 97 Lint notebooks
 59 Check stale images
 56 Check markdown
 27 Spellcheck
 17 Check Qiskit bot config
 12 Formatting
 12 Install ImageMagick
 10 Check orphaned pages
  7 Check that pages render
  7 Check all notebooks are listed in the config file
  7 Infrastructure tests
  4 Pull preview image
  4 Install Node.js dependencies
  3 Check for orphan pages
  1 Get changed files artifact

While "Lint notebooks" comes second, I think it still makes sense to run it last because it feels neater to keep all the Python checks together, and it requires Python/ImageMagick setup.

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@frankharkins frankharkins marked this pull request as ready for review March 27, 2026 11:10
@frankharkins frankharkins requested a review from arnaucasau March 27, 2026 11:10
Copy link
Copy Markdown
Collaborator

@arnaucasau arnaucasau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!! 💡

@frankharkins frankharkins added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit ab96584 Mar 27, 2026
4 checks passed
@frankharkins frankharkins deleted the FH/reorder-pr-ci branch March 27, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants