write_build_plan: remove the check for running workflows

This was required to avoid running multiple builds at the same time.
But GHA now has concurrency groups which solves the same problem,
so drop that code
This commit is contained in:
Christoph Reiter 2023-03-23 11:54:10 +01:00
parent ba632451ef
commit 956ac59246
2 changed files with 2 additions and 32 deletions

View File

@ -1,13 +1,11 @@
import json
import os
import shlex
from typing import Any, Dict, List
from tabulate import tabulate
from .config import Config, BuildType
from .gh import (get_current_repo, get_current_workflow,
wait_for_api_limit_reset)
from .config import BuildType, Config
from .gh import get_current_repo, wait_for_api_limit_reset
from .queue import (Package, PackageStatus, get_buildqueue_with_status,
get_cycles, update_status)
from .utils import apply_optional_deps, gha_group
@ -104,25 +102,10 @@ def write_build_plan(args: Any) -> None:
apply_optional_deps(optional_deps)
current_id = None
if "GITHUB_RUN_ID" in os.environ:
current_id = int(os.environ["GITHUB_RUN_ID"])
def write_out(result: List[Dict[str, str]]) -> None:
with open(target_file, "wb") as h:
h.write(json.dumps(result, indent=2).encode())
workflow = get_current_workflow()
runs = list(workflow.get_runs(status="in_progress"))
runs += list(workflow.get_runs(status="queued"))
for run in runs:
if current_id is not None and current_id == run.id:
# Ignore this run itself
continue
print(f"Another workflow is currently running or has something queued: {run.html_url}")
write_out([])
return
wait_for_api_limit_reset()
pkgs = get_buildqueue_with_status(full_details=True)

View File

@ -18,7 +18,6 @@ from github.GithubObject import GithubObject
from github.GitRelease import GitRelease
from github.GitReleaseAsset import GitReleaseAsset
from github.Repository import Repository
from github.Workflow import Workflow
from .config import REQUESTS_RETRY, REQUESTS_TIMEOUT, BuildType, Config
from .utils import PathLike, get_requests_session
@ -274,15 +273,3 @@ class CachedAssets:
assets = self._failed[key]
# XXX: This depends on the format of the filename
return [a for a in assets if get_asset_filename(a).startswith(build_type + "-")]
def get_current_workflow() -> Workflow:
workflow_name = os.environ.get("GITHUB_WORKFLOW", None)
if workflow_name is None:
raise Exception("GITHUB_WORKFLOW not set")
repo = get_current_repo()
for workflow in repo.get_workflows():
if workflow.name == workflow_name:
return workflow
else:
raise Exception("workflow not found:", workflow_name)