5 Commits

Author SHA1 Message Date
Leah
47113d1159 Only print empty cache message in terminal output (#47)
Some checks failed
ci-workflow / build (macos-latest) (push) Has been cancelled
ci-workflow / build (ubuntu-latest) (push) Has been cancelled
ci-workflow / build (windows-latest) (push) Has been cancelled
release / release (push) Has been cancelled
only print empty cache list in terminal output
2023-01-19 03:38:15 +05:30
Deepak Dahiya
9adb9e80c2 Added conditions to print for list commands (#43)
Some checks failed
ci-workflow / build (macos-latest) (push) Has been cancelled
ci-workflow / build (ubuntu-latest) (push) Has been cancelled
ci-workflow / build (windows-latest) (push) Has been cancelled
release / release (push) Has been cancelled
2022-11-21 18:45:26 +05:30
Aparna Ravindra
18233abdce Update canary and e2e workflow to use checkout@v3 - node16 version (#41)
* Update canary.yaml and e2e_test.yml to use checkout@v3
2022-10-31 12:42:55 +05:30
Sankalp Kotewar
d3293b69e1 Added note regarding GHES support (#32)
* Added note regarding GHES support

Added a note about GHES support for the extension

* Added info regarding hostname use for GHES repos

* Implemented review comments
2022-09-20 12:00:01 +05:30
Enes
2b273da8da Fixed -L shorthand bug for list command (#33) (#34)
* Fixed -L shorthand bug for list command (#33)

* Changed function name to TestListLimitShorthandUsingIncorrectLimit
2022-09-18 12:49:38 +05:30
5 changed files with 28 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ jobs:
CacheKey: ${{ matrix.os }}-runner-${{ github.run_number }}-${{ github.run_attempt }}
steps:
- name: checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install extension
env:
GITHUB_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }}

View File

@@ -34,7 +34,7 @@ jobs:
CacheKey: ${{ matrix.os }}-runner-${{ github.run_number }}-${{ github.run_attempt }}
steps:
- name: checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Restore Go modules cache
uses: actions/cache@v3
with:

View File

@@ -8,6 +8,8 @@ It also allows deleting a corrupt, incomplete or dangling cache. A cache can be
This extension builds on top of [cache management](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches) capabilities exposed by GitHub [APIs](https://docs.github.com/en/rest/actions/cache).
**Note:** This extension currently supports github.com only, GitHub Enterprise Server is not supported currently.
## Installation
1. Install the `gh` CLI - see the [installation](https://github.com/cli/cli#installation)
@@ -97,4 +99,4 @@ EXAMPLES:
## Contributing
If anything feels off, or if you feel that some functionality is missing, please check out the [contributing page](CONTRIBUTING.md). There you will find instructions for sharing your feedback, building the tool locally, and submitting pull requests to the project.
If anything feels off, or if you feel that some functionality is missing, please check out the [contributing page](CONTRIBUTING.md). There you will find instructions for sharing your feedback, building the tool locally, and submitting pull requests to the project.

View File

@@ -8,6 +8,7 @@ import (
"github.com/actions/gh-actions-cache/service"
"github.com/actions/gh-actions-cache/types"
"github.com/spf13/cobra"
ghTerm "github.com/cli/go-gh/pkg/term"
)
func NewCmdList() *cobra.Command {
@@ -41,9 +42,13 @@ func NewCmdList() *cobra.Command {
return types.HandledError{Message: err.Error(), InnerError: err}
}
// This will be used to determine the if output is terminal
terminal := ghTerm.FromEnv()
isTerminalOutput := terminal.IsTerminalOutput()
if f.Branch == "" && f.Key == "" {
totalCacheSize, err := artifactCache.GetCacheUsage()
if err == nil && totalCacheSize > 0 {
if err == nil && totalCacheSize > 0 && isTerminalOutput {
fmt.Printf("Total caches size %s\n\n", internal.FormatCacheSize(totalCacheSize))
}
}
@@ -58,9 +63,11 @@ func NewCmdList() *cobra.Command {
totalCaches := listCacheResponse.TotalCount
caches := listCacheResponse.ActionsCaches
if len(caches) > 0 {
fmt.Printf("Showing %d of %d cache entries in %s/%s\n\n", displayedEntriesCount(len(caches), f.Limit), totalCaches, repo.Owner(), repo.Name())
if isTerminalOutput {
fmt.Printf("Showing %d of %d cache entries in %s/%s\n\n", displayedEntriesCount(len(caches), f.Limit), totalCaches, repo.Owner(), repo.Name())
}
internal.PrettyPrintCacheList(caches)
} else {
} else if isTerminalOutput {
fmt.Printf("There are no Actions caches currently present in this repo or for the provided filters\n")
}
return nil
@@ -69,7 +76,7 @@ func NewCmdList() *cobra.Command {
listCmd.Flags().StringVarP(&f.Repo, "repo", "R", "", "Select another repository for finding actions cache.")
listCmd.Flags().StringVarP(&f.Branch, "branch", "B", "", "Filter by branch")
listCmd.Flags().IntVarP(&f.Limit, "limit", "", 30, "Number of items to fetch between 1 and 100")
listCmd.Flags().IntVarP(&f.Limit, "limit", "L", 30, "Number of items to fetch between 1 and 100")
listCmd.Flags().StringVarP(&f.Key, "key", "", "", "Filter by key")
listCmd.Flags().StringVarP(&f.Order, "order", "", "", "Order of caches returned (asc/desc)")
listCmd.Flags().StringVarP(&f.Sort, "sort", "", "", "Sort fetched caches (last-used/size/created-at)")

View File

@@ -62,6 +62,18 @@ func TestListWithIncorrectLimit(t *testing.T) {
assert.True(t, gock.IsDone(), internal.PrintPendingMocks(gock.Pending()))
}
func TestListLimitShorthandUsingIncorrectLimit(t *testing.T) {
t.Cleanup(gock.Off)
cmd := NewCmdList()
cmd.SetArgs([]string{"-L", "102", "--repo", "testOrg/testRepo"})
err := cmd.Execute()
assert.NotNil(t, err)
assert.Equal(t, err, fmt.Errorf("102 is not a valid integer value for limit flag. Allowed values: 1-100"))
assert.True(t, gock.IsDone(), internal.PrintPendingMocks(gock.Pending()))
}
func TestListWithIncorrectOrder(t *testing.T) {
t.Cleanup(gock.Off)