mirror of
https://github.com/ClementTsang/bottom
synced 2025-02-16 13:18:28 +00:00
ci: clean all workflow caches to script (#936)
This commit is contained in:
parent
32da5f39bb
commit
21a21b86c0
4 changed files with 33 additions and 13 deletions
|
@ -1,12 +1,13 @@
|
|||
# Simple job to clear the cache used by a PR when it is closed/merged.
|
||||
# Simple job to clear the cache used by a workflow. This automatically runs when a PR is closed/merged
|
||||
# to clean up the corresponding PR's cache.
|
||||
|
||||
name: "clear PR cache"
|
||||
name: "clear workflow cache"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
id:
|
||||
description: "Which id to clear:"
|
||||
description: "Which id to clear. Type 'main'/'master'/'all' to clean all."
|
||||
required: false
|
||||
pull_request:
|
||||
types:
|
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
|
@ -9,7 +9,7 @@ on:
|
|||
workflow_dispatch:
|
||||
inputs:
|
||||
isMock:
|
||||
description: "Replace to trigger a non-mock run."
|
||||
description: "Replace with any word other than 'mock' to trigger a non-mock run."
|
||||
default: "mock"
|
||||
required: false
|
||||
|
||||
|
|
|
@ -33,15 +33,32 @@ def main():
|
|||
env = os.environ
|
||||
|
||||
key = env["GITHUB_TOKEN"]
|
||||
pr_id = int(args[1])
|
||||
ref = "refs/pull/{}/merge".format(pr_id)
|
||||
if args[1].isnumeric():
|
||||
pr_id = int(args[1])
|
||||
ref = "refs/pull/{}/merge".format(pr_id)
|
||||
|
||||
print("Clearing any caches generated by PR {}".format(pr_id))
|
||||
with urlopen(cache_list_request(key)) as response:
|
||||
response = json.load(response)
|
||||
caches = response["actions_caches"]
|
||||
for cache in caches:
|
||||
if cache["ref"] == ref:
|
||||
print("Clearing any caches generated by PR {}".format(pr_id))
|
||||
with urlopen(cache_list_request(key)) as response:
|
||||
response = json.load(response)
|
||||
caches = response["actions_caches"]
|
||||
for cache in caches:
|
||||
if cache["ref"] == ref:
|
||||
id = cache["id"]
|
||||
try:
|
||||
print("Deleting ID {}...".format(id))
|
||||
urlopen(delete_cache_request(key, id))
|
||||
except HTTPError as e:
|
||||
print("HTTPError with delete, error code {}.".format(e.code))
|
||||
except URLError as _:
|
||||
print("URLError with delete.")
|
||||
else:
|
||||
print("Successfully deleted cache ID {}!".format(id))
|
||||
elif args[1] == "main" or args[1] == "master" or args[1] == "all":
|
||||
print("Clearing all caches.")
|
||||
with urlopen(cache_list_request(key)) as response:
|
||||
response = json.load(response)
|
||||
caches = response["actions_caches"]
|
||||
for cache in caches:
|
||||
id = cache["id"]
|
||||
try:
|
||||
print("Deleting ID {}...".format(id))
|
||||
|
@ -52,6 +69,8 @@ def main():
|
|||
print("URLError with delete.")
|
||||
else:
|
||||
print("Successfully deleted cache ID {}!".format(id))
|
||||
else:
|
||||
print(f"Skipping, given argument {args[1]}.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -158,7 +158,7 @@ fn main() -> Result<()> {
|
|||
if let Ok(recv) = receiver.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
||||
match recv {
|
||||
BottomEvent::Resize => {
|
||||
try_drawing(&mut terminal, &mut app, &mut painter)?;
|
||||
try_drawing(&mut terminal, &mut app, &mut painter)?; // FIXME: This is bugged with frozen?
|
||||
}
|
||||
BottomEvent::KeyInput(event) => {
|
||||
if handle_key_event_or_break(event, &mut app, &collection_thread_ctrl_sender) {
|
||||
|
|
Loading…
Add table
Reference in a new issue