gh-actions-cache icon indicating copy to clipboard operation
gh-actions-cache copied to clipboard

Full-length cache key.

Open hankei6km opened this issue 3 years ago • 2 comments

CLI Feedback

What have you loved?

It's an easy-to-read list view.

Thanks to the easy-to-read list, I was able to find a mistake in the cache key I set. https://github.com/hankei6km/xquo/pull/24/files

What was confusing or gave you pause?

delete command requires full-length key to delete the cache.

$ gh actions-cache delete Linux-cargo-test_debug-745cab0288fc37d8864b0178ed01e0dc115354d51702a55b62bc511f28d37ef6
You're going to delete 2 cache entries

Linux-cargo-test_debug-745cab0288fc37d8864b0178ed0... [170.82 MB]     refs/heads/main   a day ago          
Linux-cargo-test_debug-745cab0288fc37d8864b0178ed0... [170.82 MB]     refs/heads/to...  2 days ago         

? Are you sure you want to delete the cache entries?  [Use arrows to move, type to filter]
> Delete
  Cancel

Therefore, I run list command. However, keys in list are abbreviated in narrow wide terminal.

$ gh actions-cache list --branch topic/fix-wrong-cache-key
Showing 3 of 3 cache entries in hankei6km/xquo

Linux-cargo-test_release_jemalloc-745cab0288fc37d8... [203.50 MB]     refs/heads/to...  2 days ago         
Linux-cargo-test_release-745cab0288fc37d8864b0178e... [136.02 MB]     refs/heads/to...  2 days ago         
Linux-cargo-test_debug-745cab0288fc37d8864b0178ed0... [170.82 MB]     refs/heads/to...  2 days ago  

$ gh actions-cache delete "Linux-cargo-test_debug-745cab0288fc37d8864b0178ed0..."
Error: Cache with input key 'Linux-cargo-test_debug-745cab0288fc37d8864b0178ed0...' does not exist

$ gh actions-cache delete "Linux-cargo-test_debug-745cab0288fc37d8864b0178ed0"
Error: Cache with input key 'Linux-cargo-test_debug-745cab0288fc37d8864b0178ed0' does not exist

$ gh actions-cache delete "Linux-cargo-test_debug"
Error: Cache with input key 'Linux-cargo-test_debug' does not exist

I couldn't find a way to always display the full-length keys in list command.

The full-length key can be displayed by using the API, but it is inconvenient.

$ gh api -H "Accept: application/vnd.github+json" "/repos/{owner}/{repo}/actions/caches?ref=refs/heads/topic/fix-wrong-cache-key" --jq ".actions_caches[] | {id, key}"
{"id":91,"key":"Linux-cargo-test_release_jemalloc-745cab0288fc37d8864b0178ed01e0dc115354d51702a55b62bc511f28d37ef6"}
{"id":89,"key":"Linux-cargo-test_release-745cab0288fc37d8864b0178ed01e0dc115354d51702a55b62bc511f28d37ef6"}
{"id":88,"key":"Linux-cargo-test_debug-745cab0288fc37d8864b0178ed01e0dc115354d51702a55b62bc511f28d37ef6"}

hankei6km avatar Aug 02 '22 07:08 hankei6km

We do plan to have a more sophisticated tabular data printer. However given other things it may take a few weeks for us to get there.

In the meanwhile using APIs seems like a useful though inconvenient work-around.

bishal-pdMSFT avatar Aug 02 '22 19:08 bishal-pdMSFT

@hankei6km @bishal-pdMSFT Another workaround I found was to just decrease the zoom considerable on your terminal and then run the command again. I get the full key when doing this.

rplankenhorn avatar Oct 13 '22 12:10 rplankenhorn

Hi @hankei6km we now support a new table printer that allows users to pipe output for further processing. If you want to list down certain columns without trimming then just select the column number in the below command.

gh actions-cache list -R <owner>/<repo_name> | cut -f 1,2,3

This will print columns 1,2 and 3 without any trimming.

You can also refer to this doc where we explain how to automate the deletion of cache for any branch. Force deleting cache entries

t-dedah avatar Jan 20 '23 08:01 t-dedah

@t-dedah I tried the latest version(v1.0.3). I was able to see cache keys in full length.

$ gh actions-cache list --limit 10 --key "Windows"
Showing 2 of 2 cache entries in hankei6km/xquo

Windows-install-f55c7f933...  171.66 MB  refs/heads/main              a day ago
Windows-install-f55c7f933...  171.60 MB  refs/heads/dependabot/ca...  4 days ago

$ gh actions-cache list --limit 10 --key "Windows" | cut -f 1
Windows-install-f55c7f9330655b32c91858cedc1df6af68fb939379268f75dd3209a48b5b776a
Windows-install-f55c7f9330655b32c91858cedc1df6af68fb939379268f75dd3209a48b5b776a

You can also refer to this doc where we explain how to automate the deletion of cache for any branch. Force deleting cache entries

This is a great use case!

However, the sample seems to have some fixes. https://github.com/github/docs/issues/22727

I'll study it in my repository too. https://github.com/hankei6km/test-cleanup-caches-by-branch

Thank you for the great features and information.

hankei6km avatar Jan 20 '23 16:01 hankei6km