summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2022-12-30 00:56:27 -0500
committerGitHub <noreply@github.com>2022-12-30 00:56:27 -0500
commit21a21b86c0bbfd02ae21e0602a02d1c30cb264fb (patch)
tree60e5eedc45e7bd943958e05e0caca4a10feb0b6d
parent32da5f39bb2ee74543bce607249df15885d3cf47 (diff)
ci: clean all workflow caches to script (#936)
-rw-r--r--.github/workflows/clear-workflow-cache.yml (renamed from .github/workflows/clear-pr-cache.yml)7
-rw-r--r--.github/workflows/nightly.yml2
-rw-r--r--scripts/clear_cache.py37
-rw-r--r--src/bin/main.rs2
4 files changed, 34 insertions, 14 deletions
diff --git a/.github/workflows/clear-pr-cache.yml b/.github/workflows/clear-workflow-cache.yml
index 237b7fe5..b4d1a4c2 100644
--- a/.github/workflows/clear-pr-cache.yml
+++ b/.github/workflows/clear-workflow-cache.yml
@@ -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:
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index d025e546..3c5a1ec5 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -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
diff --git a/scripts/clear_cache.py b/scripts/clear_cache.py
index c2af1359..ac1c99b1 100644
--- a/scripts/clear_cache.py
+++ b/scripts/clear_cache.py
@@ -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)
-
- 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:
+ 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:
+ 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__":
diff --git a/src/bin/main.rs b/src/bin/main.rs
index bbad61b3..806efe3b 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -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) {