Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions cleanup/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ runs:
jq -r --arg TS "$TS" '
## Loop over the items in the workflow_runs array
.workflow_runs[]
## Retrieve the keys: id (used for deleting), updated_at (used for comparison), status (used for comparison), conclusion (unused)
| { id, updated_at,status,conclusion }
## Filter out the id based on (updated_at < TS and is completed)
## Retrieve the keys: id (used for deleting), updated_at (used for comparison), status (used for comparison), conclusion (used for comparison), head_branch (branch the action is from), name (name of the workflow)
| { id,updated_at,status,conclusion,head_branch,name }
## Filter out the id based on (updated_at < TS and is completed)
| select((.updated_at < $TS) and .status == "completed")
# ## Filter out release branches
# | select(.head_branch | test("release/") | not)
## Filter out release branches (include any PRs etc made against a release branch)
| select((.head_branch | test("release/")) and (.name | test("release/") | not) or (.head_branch | test("release/") | not) )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: does or (.head_branch | test("release/") | not) overshadow (.head_branch | test("release/")) and (.name | test("release/") | not) ?

So that in the end deleting everything except workflows with "release/" literally in their name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - i beleive the second query you mentioned is just more verbose (i discovered the same after i had already tested the change).

since i want to redo some other things here, i'll re-test with the simplified logic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that in the end deleting everything except workflows with "release/" literally in their name?
had to refresh my memory here, but yes. what this means is that if you were to PR a change to a release branch, the workflow would be deleted after the set amount of time (30 days by default).
however, if the PR is from release/xxx (like for the release -> develop PR), it's not eligible for deletion.

i think the ideal scenario here is: any release workflow triggered manually should be ignored, but any other workflow should be eligible. i'll see if i can adjust the query to accomplish that and re-open the PR later.

## If an item matches our conditional, store the id as ID in the for loop
| {id}
| .[]
Expand Down Expand Up @@ -84,10 +88,14 @@ runs:
jq -r --arg TS "$TS" '
## Loop over the items in the workflow_runs array
.workflow_runs[]
## Retrieve the keys: id (used for deleting), updated_at (used for comparison), status (used for comparison), conclusion (used for comparison)
| { id, updated_at,status,conclusion }
## Filter out the id based on (updated_at < TS and (action was unsuccessful and is completed)
## Retrieve the keys: id (used for deleting), updated_at (used for comparison), status (used for comparison), conclusion (used for comparison), head_branch (branch the action is from), name (name of the workflow)
| { id,updated_at,status,conclusion,head_branch,name }
## Filter out the id based on (updated_at < TS and (action was unsuccessful and is completed)
| select((.updated_at < $TS) and (.conclusion != "success" and .status == "completed"))
# ## Filter out release branches
# | select(.head_branch | test("release/") | not)
## Filter out release branches (include any PRs etc made against a release branch)
| select((.head_branch | test("release/")) and (.name | test("release/") | not) or (.head_branch | test("release/") | not) )
## If an item matches our conditional, store the id as ID in the for loop
| {id}
| .[]
Expand Down Expand Up @@ -128,8 +136,8 @@ runs:
.actions_caches[]
## Retrieve the keys: id (used for deleting), last_accessed_at (used for comparison) and key (used for comparison)
| { id, last_accessed_at, key }
## Filter out the id based on (last_accessed_at < TS and key is not stacks-core-bitcoin-binaries
| select((.last_accessed_at < $TS) and (.key != "stacks-core-bitcoin-binaries" ))
## Filter out the id based on (last_accessed_at < TS )
| select(.last_accessed_at < $TS)
## If an item matches our conditional, store the id as ID in the for loop
| {id}
| .[]
Expand Down