Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create BigRedButton script to cancel all the worflows with a given name #64025

Open
Felixoid opened this issue May 17, 2024 · 2 comments
Open
Labels
comp-ci Continuous integration

Comments

@Felixoid
Copy link
Member

Our CI is completely stuck right now, and during triaging, @maxknv proposed creating a way to stop every running workflow with given name

@Felixoid
Copy link
Member Author

  • Backport concurrency to cancel previous workflows

@Algunenano Algunenano added the comp-ci Continuous integration label May 17, 2024
@Felixoid
Copy link
Member Author

Here's a very raw PoC of brb.py

#!/usr/bin/env python

from typing import List

from github.WorkflowRun import WorkflowRun

from env_helper import GITHUB_REPOSITORY
from get_robot_token import get_best_robot_token
from github_helper import GitHub

gh = GitHub(get_best_robot_token(), per_page=100)

repo = gh.get_repo(GITHUB_REPOSITORY)

names = ["MasterCI", "PullRequestCI"]
states_to_kill = ["queued", "in_progress", "pending", "waiting"]

wfs = list(repo.get_workflows())
filtered_wfs = [wf for wf in wfs if wf.state == "active" and wf.name in names]
runs = []  # type: List[WorkflowRun]

for state in states_to_kill:
    for wf in filtered_wfs:
        runs.extend(wf.get_runs(status=state))

for run in runs:
    print(f"Run {run.cancel_url}")
    run.cancel()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-ci Continuous integration
Projects
None yet
Development

No branches or pull requests

2 participants