Add --latest-commit-weekly arg to stop spam packagers
This commit is contained in:
parent
aaa60f81c2
commit
75e383cb23
1 changed files with 15 additions and 3 deletions
|
@ -216,6 +216,7 @@ class AppAutoUpdater:
|
||||||
raise RuntimeError("There's no resources.sources in manifest.toml ?")
|
raise RuntimeError("There's no resources.sources in manifest.toml ?")
|
||||||
|
|
||||||
self.main_upstream = self.manifest.get("upstream", {}).get("code")
|
self.main_upstream = self.manifest.get("upstream", {}).get("code")
|
||||||
|
self.latest_commit_weekly = False
|
||||||
|
|
||||||
def run(
|
def run(
|
||||||
self, edit: bool = False, commit: bool = False, pr: bool = False
|
self, edit: bool = False, commit: bool = False, pr: bool = False
|
||||||
|
@ -535,6 +536,9 @@ class AppAutoUpdater:
|
||||||
return latest_version, latest_tarball, ""
|
return latest_version, latest_tarball, ""
|
||||||
|
|
||||||
if revision_type == "commit":
|
if revision_type == "commit":
|
||||||
|
if self.latest_commit_weekly and datetime.now().weekday() != 0:
|
||||||
|
logging.warning("Skipped autoupdater because we're not monday")
|
||||||
|
return None
|
||||||
if asset != "tarball":
|
if asset != "tarball":
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"For the latest commit strategies, only asset = 'tarball' is supported"
|
"For the latest commit strategies, only asset = 'tarball' is supported"
|
||||||
|
@ -631,10 +635,12 @@ class StdoutSwitch:
|
||||||
|
|
||||||
|
|
||||||
def run_autoupdate_for_multiprocessing(data) -> tuple[str, tuple[State, str, str, str]]:
|
def run_autoupdate_for_multiprocessing(data) -> tuple[str, tuple[State, str, str, str]]:
|
||||||
app, edit, commit, pr = data
|
app, edit, commit, pr, latest_commit_weekly = data
|
||||||
stdoutswitch = StdoutSwitch()
|
stdoutswitch = StdoutSwitch()
|
||||||
try:
|
try:
|
||||||
result = AppAutoUpdater(app).run(edit=edit, commit=commit, pr=pr)
|
autoupdater = AppAutoUpdater(app)
|
||||||
|
autoupdater.latest_commit_weekly = latest_commit_weekly
|
||||||
|
result = autoupdater.run(edit=edit, commit=commit, pr=pr)
|
||||||
return (app, result)
|
return (app, result)
|
||||||
except Exception:
|
except Exception:
|
||||||
log_str = stdoutswitch.reset()
|
log_str = stdoutswitch.reset()
|
||||||
|
@ -652,6 +658,12 @@ def main() -> None:
|
||||||
type=Path,
|
type=Path,
|
||||||
help="If not passed, the script will run on the catalog. Github keys required.",
|
help="If not passed, the script will run on the catalog. Github keys required.",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-w", "--latest-commit-weekly",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
default=False,
|
||||||
|
help="For latest_commit versions, only run weekly to prevent too many PRs"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--edit",
|
"--edit",
|
||||||
action=argparse.BooleanOptionalAction,
|
action=argparse.BooleanOptionalAction,
|
||||||
|
@ -694,7 +706,7 @@ def main() -> None:
|
||||||
with multiprocessing.Pool(processes=args.processes) as pool:
|
with multiprocessing.Pool(processes=args.processes) as pool:
|
||||||
tasks = pool.imap(
|
tasks = pool.imap(
|
||||||
run_autoupdate_for_multiprocessing,
|
run_autoupdate_for_multiprocessing,
|
||||||
((app, args.edit, args.commit, args.pr) for app in apps),
|
((app, args.edit, args.commit, args.pr, args.latest_commit_weekly) for app in apps),
|
||||||
)
|
)
|
||||||
for app, result in tqdm.tqdm(tasks, total=len(apps), ascii=" ·#"):
|
for app, result in tqdm.tqdm(tasks, total=len(apps), ascii=" ·#"):
|
||||||
state, current_version, main_version, pr_url = result
|
state, current_version, main_version, pr_url = result
|
||||||
|
|
Loading…
Reference in a new issue