diff --git a/scripts/generate-popular-actions/README.md b/scripts/generate-popular-actions/README.md index ff507ca4e..8be64db5e 100644 --- a/scripts/generate-popular-actions/README.md +++ b/scripts/generate-popular-actions/README.md @@ -33,14 +33,14 @@ Please see output of `-help` flag for more details. The data source of the popular actions is defined in [`popular_actions.json`](./popular_actions.json). This file contains an array of each action registry. Each registry is a JSON object containing the following keys: -| Key | Description | Example | Required? | -|----------------|----------------------------------------------------------------|----------------------------|-----------| -| `slug` | GitHub repository slug | `"actions/checkout"` | Yes | -| `tags` | Known release tags | `["v1", "v2", "v3", "v4"]` | Yes | -| `next` | The next release tag | `"v5"` | Yes | -| `path` | Absolute path to the action from the repository root | `"/path/to/action"` | No | -| `skip_inputs` | Skipping checking inputs of this action or not | `true` | No | -| `skip_outputs` | Skipping checking outputs of this action or not | `true` | No | -| `file_ext` | File extension of action metadata file. The default is `"yml"` | `"yaml"` | No | +| Key | Description | Example | Required? | +|----------------|-----------------------------------------------------------------|----------------------------|-----------| +| `slug` | GitHub repository slug | `"actions/checkout"` | Yes | +| `tags` | Known release tags | `["v1", "v2", "v3", "v4"]` | Yes | +| `next` | The next release tag. Empty means new version won't be detected | `"v5"` | No | +| `path` | Absolute path to the action from the repository root | `"/path/to/action"` | No | +| `skip_inputs` | Skipping checking inputs of this action or not | `true` | No | +| `skip_outputs` | Skipping checking outputs of this action or not | `true` | No | +| `file_ext` | File extension of action metadata file. The default is `"yml"` | `"yaml"` | No | Alternative actions registry JSON file can be used via `-r` option. diff --git a/scripts/generate-popular-actions/main.go b/scripts/generate-popular-actions/main.go index b3f32a635..5a06e5a1d 100644 --- a/scripts/generate-popular-actions/main.go +++ b/scripts/generate-popular-actions/main.go @@ -298,11 +298,21 @@ func (g *gen) readJSONL(file string) (map[string]*actionlint.ActionMetadata, err } func (g *gen) detectNewReleaseURLs() ([]string, error) { - actions, err := g.registry() + all, err := g.registry() if err != nil { return nil, err } + // Filter actions which have no next versions + actions := []*registry{} + for _, a := range all { + if a.Next != "" { + actions = append(actions, a) + } + } + + g.log.Println("Start detecting new versions in", len(actions), "repositories") + urls := make(chan string) done := make(chan struct{}) errs := make(chan error) @@ -314,10 +324,6 @@ func (g *gen) detectNewReleaseURLs() ([]string, error) { for { select { case r := <-reqs: - if r.Next == "" { - ret <- "" - break - } url := r.rawURL(r.Next) g.log.Println("Checking", url) res, err := c.Head(url) @@ -368,6 +374,8 @@ func (g *gen) detectNewReleaseURLs() ([]string, error) { close(done) sort.Strings(us) + + g.log.Println("Done detecting new versions in", len(actions), "repositories") return us, nil } @@ -439,6 +447,7 @@ Flags:`) return 1 } if len(urls) == 0 { + fmt.Fprintln(g.stdout, "No new release was found") return 0 } fmt.Fprintln(g.stdout, "Detected some new releases") diff --git a/scripts/generate-popular-actions/main_test.go b/scripts/generate-popular-actions/main_test.go index d10c39f1a..ce854c4c6 100644 --- a/scripts/generate-popular-actions/main_test.go +++ b/scripts/generate-popular-actions/main_test.go @@ -26,8 +26,10 @@ func TestDefaultPopularActions(t *testing.T) { slugs := map[string]int{} for i, a := range popularActions { - if j, ok := slugs[a.Slug]; ok && popularActions[i].Path == popularActions[j].Path { - t.Errorf("slug %q at popularActions[%d] was already added at popularActions[%d]", a.Slug, i, j) + if a.Slug == "" { + t.Errorf("repository slug must not empty at popularActions[%d]", i) + } else if j, ok := slugs[a.Slug]; ok && popularActions[i].Path == popularActions[j].Path { + t.Errorf("duplicate registry. action %q at popularActions[%d] was already added at popularActions[%d]", a.Slug, i, j) } else { slugs[a.Slug] = i } diff --git a/scripts/generate-popular-actions/popular_actions.json b/scripts/generate-popular-actions/popular_actions.json index 9a1cd6569..2b738c17e 100644 --- a/scripts/generate-popular-actions/popular_actions.json +++ b/scripts/generate-popular-actions/popular_actions.json @@ -52,8 +52,7 @@ }, { "slug": "dtolnay/rust-toolchain", - "tags": ["stable", "beta", "nightly"], - "next": "" + "tags": ["stable", "beta", "nightly"] }, { "slug": "actions-rs/clippy-check", @@ -319,8 +318,7 @@ }, { "slug": "marvinpinto/action-automatic-releases", - "tags": ["latest"], - "next": "" + "tags": ["latest"] }, { "slug": "microsoft/playwright-github-action",