diff --git a/AGENTS.md b/AGENTS.md index 2292472..5b6ef22 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,7 +52,7 @@ Go module `github.com/patch-it-dev/patch-it-plugins`; the only dependency is `go core/plugin/ the Plugin interface (Run; ListVersions, ReadAt, Extract), the registry of providers and sources, Env, Result core/fetch/ the HTTP fetch with retries and the ETag / Last-Modified cache core/github/ the newest release / commit on GitHub, and a commit's SHA and date (one place) -core/versions/ every version of a source: GitHub releases, tags and commits, PyPI, npm, the Web Archive at a date +core/versions/ every version of a source: GitHub releases, tags and commits, PyPI, npm, Web Archive captures core/kit/ core/kit/kittest/ Unchanged, Cite, Wayback, Notices; the test kit (Mem, Pages, Ingest, Golden) core/extract/ what readers of prose share: RSS/Atom entries, HTML as text, dates, code spans core/event/ core/migrate/ the change-event types from patch-it's contract (v1 + v2), v1 -> v2 diff --git a/core/versions/versions.go b/core/versions/versions.go index 77ebddf..5cccd3c 100644 --- a/core/versions/versions.go +++ b/core/versions/versions.go @@ -1,7 +1,7 @@ // Package versions lists a source's versions from where they're published: // a GitHub repo's releases, tags or the commits that changed a file, a -// package's releases on PyPI or npm, and the Web Archive's capture of a page -// at a date. Every list comes back oldest first, as plugin.Version. +// package's releases on PyPI or npm, and a living page's captures in the Web +// Archive (every distinct one, or the one closest to a date). Every list comes back oldest first, as plugin.Version. // // Each function takes how to fetch (a plugin's env.Get, or github.Get for the // GitHub API with its token), so tests serve saved responses. @@ -36,6 +36,13 @@ var ( // MaxPages caps how many pages of 100 a GitHub list reads (1,000 entries). const MaxPages = 10 +// GitHubPages reads a GitHub list endpoint (base, with or without a query) +// page by page, 100 at a time, until a short page or MaxPages: for a list +// the functions here don't cover (a release's assets, another host's base). +func GitHubPages[T any](ctx context.Context, get Getter, base string) ([]T, error) { + return pages[T](ctx, get, base) +} + // pages reads a GitHub list endpoint page by page until a short page. func pages[T any](ctx context.Context, get Getter, base string) ([]T, error) { sep := "?" @@ -238,6 +245,63 @@ func WaybackAt(ctx context.Context, get Getter, page string, at time.Time) (plug return plugin.Version{ID: taken.Format(time.DateOnly), Released: taken, Ref: c.URL, URL: c.URL}, nil } +// WaybackCaptures are the versions of a living page (one that only shows its +// newest state: a deprecations page, a feed) as the Web Archive captured it +// between from and to (zero: no bound), oldest first, from its CDX API: one +// version per distinct content, so captures of an unchanged page collapse +// into the first of them, and a page that changes back is a new version. +// Two distinct captures on one day keep the later one: a version's ID is +// its day (YYYY-MM-DD). The Ref is the capture's original bytes +// (web.archive.org/web/id_/), the URL the capture a person +// sees and an event cites. +// +// One request, made with get: the caller's fetch is what spaces requests +// out and names the client (patch-it's hosted ingestion service fetches one +// at a time per host, with its own User-Agent). +func WaybackCaptures(ctx context.Context, get Getter, page string, from, to time.Time) ([]plugin.Version, error) { + q := url.Values{"url": {page}, "output": {"json"}, "fl": {"timestamp,original,digest"}, "filter": {"statuscode:200"}, "collapse": {"digest"}} + if !from.IsZero() { + q.Set("from", from.UTC().Format("20060102150405")) + } + if !to.IsZero() { + q.Set("to", to.UTC().Format("20060102150405")) + } + body, err := get(ctx, Wayback+"/cdx/search/cdx?"+q.Encode()) + if err != nil { + return nil, fmt.Errorf("listing the Web Archive's captures of %s: %w", page, err) + } + var rows [][]string + if len(strings.TrimSpace(string(body))) > 0 { + if err := json.Unmarshal(body, &rows); err != nil { + return nil, fmt.Errorf("parsing the Web Archive's captures of %s: %w", page, err) + } + } + var out []plugin.Version + lastDigest := "" + for i, r := range rows { + if i == 0 || len(r) < 3 { // the header row: ["timestamp","original","digest"] + continue + } + taken, err := time.Parse("20060102150405", r[0]) + if err != nil || r[2] == lastDigest { + continue + } + lastDigest = r[2] + v := plugin.Version{ + ID: taken.Format(time.DateOnly), Released: taken, + Ref: "https://web.archive.org/web/" + r[0] + "id_/" + r[1], + URL: "https://web.archive.org/web/" + r[0] + "/" + r[1], + } + if n := len(out); n > 0 && out[n-1].ID == v.ID { + out[n-1] = v + continue + } + out = append(out, v) + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) + return out, nil +} + var ( final = regexp.MustCompile(`^v?\d+(\.\d+)*$`) number = regexp.MustCompile(`\d+`) diff --git a/core/versions/versions_test.go b/core/versions/versions_test.go index ba1981a..5fd20f8 100644 --- a/core/versions/versions_test.go +++ b/core/versions/versions_test.go @@ -168,3 +168,52 @@ func TestCompareFinalMajorPairs(t *testing.T) { t.Errorf("Pairs = %v", ps) } } + +// The CDX API's answer: a header row, then captures oldest first. The same +// content captured again (same digest) is one version; a change back is a +// new one; two distinct captures on one day keep the later. +func TestWaybackCapturesCollapseDuplicates(t *testing.T) { + const page = "https://example.com/deprecations" + cdx := `[["timestamp","original","digest"], +["20250103120000","https://example.com/deprecations","AAA"], +["20250210080000","https://example.com/deprecations","AAA"], +["20250301090000","https://example.com/deprecations","BBB"], +["20250301170000","https://example.com/deprecations","CCC"], +["20250601000000","https://example.com/deprecations","CCC"], +["20251120000000","https://example.com/deprecations","AAA"]]` + var asked string + get := func(_ context.Context, u string) ([]byte, error) { asked = u; return []byte(cdx), nil } + from, to := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC), time.Date(2025, 12, 31, 0, 0, 0, 0, time.UTC) + vs, err := WaybackCaptures(context.Background(), get, page, from, to) + if err != nil { + t.Fatal(err) + } + var got []string + for _, v := range vs { + got = append(got, v.ID+" "+v.Ref) + } + want := []string{ + "2025-01-03 https://web.archive.org/web/20250103120000id_/https://example.com/deprecations", + "2025-03-01 https://web.archive.org/web/20250301170000id_/https://example.com/deprecations", + "2025-11-20 https://web.archive.org/web/20251120000000id_/https://example.com/deprecations", + } + if strings.Join(got, "\n") != strings.Join(want, "\n") { + t.Errorf("got\n%s\nwant\n%s", strings.Join(got, "\n"), strings.Join(want, "\n")) + } + for _, p := range []string{"from=20250101000000", "to=20251231000000", "collapse=digest", "filter=statuscode%3A200", "url=https%3A%2F%2Fexample.com%2Fdeprecations"} { + if !strings.Contains(asked, p) { + t.Errorf("asked %s, without %s", asked, p) + } + } + if vs[0].URL != "https://web.archive.org/web/20250103120000/https://example.com/deprecations" { + t.Errorf("URL %s", vs[0].URL) + } +} + +// A page the archive never captured has no versions, and no error. +func TestWaybackCapturesOfAnUncapturedPage(t *testing.T) { + get := func(context.Context, string) ([]byte, error) { return []byte("[]"), nil } + if vs, err := WaybackCaptures(context.Background(), get, "https://example.com/x", time.Time{}, time.Time{}); err != nil || len(vs) != 0 { + t.Errorf("%v %v", vs, err) + } +} diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 9bacfff..eee82d1 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -4,7 +4,7 @@ A **provider** (Stripe, OpenAI, GitHub…) has one category and one or more **so ## What a plugin does -0. **List the versions.** A source with versions (a spec's releases, a package on PyPI or npm, a guide per major) lists every one, oldest first (`ListVersions`, from `core/versions`: GitHub releases, tags and commits, PyPI, npm, the Web Archive at a date). Each consecutive pair is read and compared once (`ReadAt`, `Extract`), so a customer several versions behind gets every step of the upgrade. A living page with no versions (a deprecations page, a feed) is read as it is now; each change to it is a dated version. +0. **List the versions.** A source with versions (a spec's releases, a package on PyPI or npm, a guide per major) lists every one, oldest first (`ListVersions`, from `core/versions`: GitHub releases, tags and commits, PyPI, npm, a living page's Web Archive captures). Each consecutive pair is read and compared once (`ReadAt`, `Extract`), so a customer several versions behind gets every step of the upgrade. A living page with no versions (a deprecations page, a feed) is read as it is now; each change to it is a dated version, and its past ones are its Web Archive captures. 1. **Fetch.** The plugin asks its environment for the source (`env.Get`); it never opens connections itself. Pages that change in place are also cited through a Web Archive snapshot, so the link in an event keeps showing what the plugin read. 2. **Compare.** It compares two versions of the source: two OpenAPI specs, two versions of a deprecations page, a release's changelog section against the release before. `Run` does the newest version against the last one it saw (the baseline); `Extract` does any pair. 3. **Emit events.** Each change becomes one event in [patch-it's change-event format](https://github.com/patch-it-dev/patch-it/tree/main/docs/contract): what changed, how bad it is (breaking, deprecation, behavior change, non-breaking), the date it takes effect, and the source URL with a quote. **No source, no event.** When unsure, a plugin emits nothing: a wrong event would become a wrong pull request. @@ -20,7 +20,7 @@ There's no list in this repo: `make plugins` prints every provider and source fr | Path | What's there | |---|---| | [`core/plugin/`](../core/plugin/) | The `Plugin` interface (`Run`; `ListVersions`, `ReadAt`, `Extract`), the registry of providers and sources (`RegisterProvider`, `Lookup`, `LookupSource`, `Providers`), `Env`, `Result` | -| [`core/versions/`](../core/versions/) | Every version of a source: GitHub releases, tags and commits, PyPI, npm, the Web Archive at a date | +| [`core/versions/`](../core/versions/) | Every version of a source: GitHub releases, tags and commits, PyPI, npm, a page's Web Archive captures (all, or the one at a date) | | [`plugins/`](../plugins/) | One package per kind, with its providers; `plugins/all` imports every one | | [`cmd/new-plugin/`](../cmd/new-plugin/), [`cmd/list-plugins/`](../cmd/list-plugins/) | The starter for a new provider; the list of providers and sources, printed from the registry | | [`core/kit/`](../core/kit/), [`core/kit/kittest/`](../core/kit/kittest/), [`core/github/`](../core/github/), [`core/extract/`](../core/extract/) | What plugins share (the unchanged-page check, Wayback citing, the newest release or commit on GitHub, RSS/Atom and HTML text helpers) and the test kit (in-memory store, saved pages, golden files) | diff --git a/docs/writing-a-plugin.md b/docs/writing-a-plugin.md index b27dd55..6be55f3 100644 --- a/docs/writing-a-plugin.md +++ b/docs/writing-a-plugin.md @@ -117,12 +117,12 @@ ReadAt(ctx, env, v Version) (Snapshot, error) // the source at o Extract(ctx, env, from, to Snapshot) (Result, error) // the changes from one to the next ``` -- **List** with [`core/versions`](../core/versions/versions.go): `GitHubReleases`, `GitHubTags`, `GitHubCommits` (the commits that changed a file), `PyPIReleases`, `NPMReleases`, `WaybackAt` (a page as it was on a date). Never pin a tag in code: a version you need for a golden test is a pinned *case* in the test (`changelog.Urllib3.At("2.0.0")`), not the registered source. +- **List** with [`core/versions`](../core/versions/versions.go): `GitHubReleases`, `GitHubTags`, `GitHubCommits` (the commits that changed a file), `PyPIReleases`, `NPMReleases`, `WaybackCaptures` (every distinct Web Archive capture of a living page, dated), `WaybackAt` (a page as it was on a date), `GitHubPages` (any other GitHub list, page by page). An OpenAPI adapter lists its own versions (`adapter.Lister`): every adapter does. Never pin a tag in code: a version you need for a golden test is a pinned *case* in the test (`changelog.Urllib3.At("2.0.0")`), not the registered source. - **Read at** a version's `Ref` (a tag, a commit SHA, an archive URL) and return the exact URL read as the snapshot's `SourceURL`: it's the events' citation. - **Extract** sets `previous_version` to `from`'s version; `from` may be zero (nothing before). It returns no baselines. - `Run` is built from the same parts: the newest version, extracted against the last baseline. -A living page with no versions of its own (a deprecations page, a feed) only has `Run`: it's read as it is now, and each change to it is a dated version. +A living page with no versions of its own (a deprecations page, a feed: a `notices` source) is read as it is now by `Run`, and each change to it is a dated version. Its history comes from the Web Archive: the `notices` kind lists every distinct capture (`WaybackCaptures`), reads each, and extracts what each one added, citing that capture, so a year of it can be backfilled by date with no stored copies. ### Register the provider and its source diff --git a/plugins/notices/notices.go b/plugins/notices/notices.go index cfdea5f..56c051a 100644 --- a/plugins/notices/notices.go +++ b/plugins/notices/notices.go @@ -14,6 +14,7 @@ package notices import ( + "cmp" "context" "errors" "fmt" @@ -25,6 +26,7 @@ import ( "github.com/patch-it-dev/patch-it-plugins/core/kit" "github.com/patch-it-dev/patch-it-plugins/core/migrate" "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" "github.com/patch-it-dev/patch-it-plugins/plugins/notices/eol" "github.com/patch-it-dev/patch-it-plugins/plugins/notices/feed" "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" @@ -199,3 +201,67 @@ func (p Plugin) fetch(ctx context.Context, env plugin.Env, pageURL string) (body } return body, archivedURL, nil } + +// A living page has no versions of its own, so its history is the Web +// Archive's: every distinct capture is a version, dated (I19.11). A backfill +// reads the page at each capture and extracts each consecutive pair, the +// same events a run on that day would have stored, each citing its capture. + +// ListVersions is every distinct Web Archive capture of the page, oldest +// first (versions.WaybackCaptures); the caller keeps the ones in its window. +func (p Plugin) ListVersions(ctx context.Context, env plugin.Env) ([]plugin.Version, error) { + return versions.WaybackCaptures(ctx, env.Get, p.Page.PageURL(), time.Time{}, time.Time{}) +} + +// ReadAt reads the page as the capture v holds it: the capture's original +// bytes (v.Ref), cited by its address (v.URL). +func (p Plugin) ReadAt(ctx context.Context, env plugin.Env, v plugin.Version) (plugin.Snapshot, error) { + body, err := env.Get(ctx, v.Ref) + if err != nil { + return plugin.Snapshot{}, fmt.Errorf("fetching %s as captured on %s: %w", p.Page.PageURL(), v.ID, err) + } + return plugin.Snapshot{Version: v, Content: body, SourceURL: cmp.Or(v.URL, v.Ref)}, nil +} + +// Extract is an event per notice on the page at to that wasn't at from +// (every one when from is zero), citing to's capture. The events keep the +// notice's own version (its date or API version), so previous_version stays +// empty: from is an earlier day of the page, not an earlier release. +func (p Plugin) Extract(_ context.Context, env plugin.Env, from, to plugin.Snapshot) (plugin.Result, error) { + now := env.Now().UTC() + events, rejected, err := p.events(to, now) + if err != nil { + return plugin.Result{}, err + } + if !from.IsZero() { + before, _, err := p.events(from, now) + if err != nil { + return plugin.Result{}, err + } + had := map[string]bool{} + for _, e := range before { + had[e.Fingerprint] = true + } + kept := events[:0:0] + for _, e := range events { + if !had[e.Fingerprint] { + kept = append(kept, e) + } + } + events = kept + } + return plugin.Result{Label: to.SourceURL, Events: events, Rejected: rejected}, nil +} + +// events reads one snapshot's notices into v2 events citing it. +func (p Plugin) events(s plugin.Snapshot, now time.Time) ([]event.EventV2, []error, error) { + found, err := p.Page.Find(s.Content) + if err != nil { + return nil, nil, fmt.Errorf("reading %s: %w", s.SourceURL, err) + } + v1, v2, rejected := p.Page.Events(found, s.SourceURL, now) + converted, invalid := migrate.Fresh(v1) + return append(converted, v2...), append(rejected, invalid...), nil +} + +var _ plugin.Versioned = Plugin{} diff --git a/plugins/notices/versions_test.go b/plugins/notices/versions_test.go new file mode 100644 index 0000000..a3691b4 --- /dev/null +++ b/plugins/notices/versions_test.go @@ -0,0 +1,110 @@ +package notices + +import ( + "context" + "fmt" + "os" + "strings" + "testing" + "time" + + "github.com/patch-it-dev/patch-it-plugins/core/kit/kittest" + "github.com/patch-it-dev/patch-it-plugins/core/plugin" + "github.com/patch-it-dev/patch-it-plugins/core/versions" + "github.com/patch-it-dev/patch-it-plugins/plugins/notices/retire" +) + +// A year of a living page from its Web Archive captures alone: four +// captures, two of them the same content, are three versions; reading each +// and extracting each consecutive pair gives every retirement once, each +// citing the capture where it first appeared. Nothing reaches the network: +// the CDX answer and the captures are served from memory. +func TestBackfillAYearFromCaptures(t *testing.T) { + full, err := os.ReadFile("retire/testdata/openai-deprecations.md") + if err != nil { + t.Fatal(err) + } + lines := strings.SplitAfter(string(full), "\n") + header := strings.Join(lines[:2], "") + // The page as it grew: the oldest capture has the sections from the + // 2026-04-22 announcement down, the next adds three, the newest is today's. + older := header + strings.Join(lines[34:], "") + middle := header + strings.Join(lines[10:], "") + pg := retire.OpenAI + capture := func(ts string) string { return "https://web.archive.org/web/" + ts + "id_/" + pg.URL } + captures := map[string]string{ + capture("20250115000000"): older, + capture("20250601000000"): middle, + capture("20251201000000"): string(full), + } + cdx := fmt.Sprintf(`[["timestamp","original","digest"], +["20250115000000",%[1]q,"A"],["20250301000000",%[1]q,"A"],["20250601000000",%[1]q,"B"],["20251201000000",%[1]q,"C"]]`, pg.URL) + env := plugin.Env{ + Baselines: kittest.NewMem(), + Now: func() time.Time { return kittest.Clock }, + Get: func(_ context.Context, u string) ([]byte, error) { + if strings.HasPrefix(u, versions.Wayback+"/cdx/search/cdx?") { + return []byte(cdx), nil + } + if body, ok := captures[u]; ok { + return []byte(body), nil + } + t.Errorf("fetched %s", u) + return nil, fmt.Errorf("no saved copy of %s", u) + }, + } + ctx := context.Background() + p := Plugin{Page: pg} + vs, err := p.ListVersions(ctx, env) + if err != nil { + t.Fatal(err) + } + if len(vs) != 3 || vs[0].ID != "2025-01-15" || vs[2].ID != "2025-12-01" { + t.Fatalf("versions %v", vs) + } + var snaps []plugin.Snapshot + for _, v := range vs { + s, err := p.ReadAt(ctx, env, v) + if err != nil { + t.Fatal(err) + } + snaps = append(snaps, s) + } + firstSeen := map[string]string{} // fingerprint -> the capture it's cited from + for i := range snaps { + var from plugin.Snapshot + if i > 0 { + from = snaps[i-1] + } + res, err := p.Extract(ctx, env, from, snaps[i]) + if err != nil || len(res.Rejected) > 0 { + t.Fatalf("%v %v", err, res.Rejected) + } + if len(res.Events) == 0 { + t.Errorf("%s: no new retirement", vs[i].ID) + } + for _, e := range res.Events { + if _, dup := firstSeen[e.Fingerprint]; dup { + t.Errorf("%s: %s again", vs[i].ID, e.Subject.Name) + } + if e.SourceURL != vs[i].URL { + t.Errorf("%s cites %s, want %s", e.Subject.Name, e.SourceURL, vs[i].URL) + } + firstSeen[e.Fingerprint] = e.SourceURL + } + } + // Today's page, read in one go, holds every retirement the history found + // (a retirement can only change its fingerprint, never vanish). + today, err := p.Extract(ctx, env, plugin.Snapshot{}, snaps[2]) + if err != nil { + t.Fatal(err) + } + for _, e := range today.Events { + if _, ok := firstSeen[e.Fingerprint]; !ok { + t.Errorf("%s on today's page, never seen in the history", e.Subject.Name) + } + } + if strings.Contains(firstSeen[today.Events[0].Fingerprint], "20250115") { + t.Errorf("today's newest retirement is cited from the oldest capture") + } +} diff --git a/plugins/openapi/adapter/algolia.go b/plugins/openapi/adapter/algolia.go index 37a70d0..2628fb8 100644 --- a/plugins/openapi/adapter/algolia.go +++ b/plugins/openapi/adapter/algolia.go @@ -43,24 +43,15 @@ var algoliaTag = regexp.MustCompile(`^released-(\d{4}-\d{2}-\d{2})(-[0-9a-f]+)?$ // have several releases (three on 2024-09-19) whose commit suffix says // nothing about their order, so those are told apart by their commit's date. func (a Algolia) LatestTag(ctx context.Context) (string, error) { - body, err := fetch.Get(ctx, algoliaRefsURL, github.Headers()) + tags, err := algoliaTags(ctx) if err != nil { - return "", fmt.Errorf("listing algolia's release tags: %w", err) - } - var refs []struct { - Ref string `json:"ref"` - } - if err := json.Unmarshal(body, &refs); err != nil { - return "", fmt.Errorf("parsing github's tag refs: %w", err) + return "", err } var day string var sameDay []string - for _, r := range refs { - tag := strings.TrimPrefix(r.Ref, "refs/tags/") + for _, tag := range tags { m := algoliaTag.FindStringSubmatch(tag) switch { - case m == nil: - continue case m[1] > day: day, sameDay = m[1], []string{tag} case m[1] == day: @@ -87,6 +78,27 @@ func (a Algolia) LatestTag(ctx context.Context) (string, error) { return latest, nil } +// algoliaTags are every release tag, in the listing's order. +func algoliaTags(ctx context.Context) ([]string, error) { + body, err := fetch.Get(ctx, algoliaRefsURL, github.Headers()) + if err != nil { + return nil, fmt.Errorf("listing algolia's release tags: %w", err) + } + var refs []struct { + Ref string `json:"ref"` + } + if err := json.Unmarshal(body, &refs); err != nil { + return nil, fmt.Errorf("parsing github's tag refs: %w", err) + } + var tags []string + for _, r := range refs { + if tag := strings.TrimPrefix(r.Ref, "refs/tags/"); algoliaTag.MatchString(tag) { + tags = append(tags, tag) + } + } + return tags, nil +} + func algoliaCommitDate(ctx context.Context, tag string) (time.Time, error) { _, date, err := github.Commit(ctx, github.Get, fmt.Sprintf(algoliaCommitURL, tag)) if err != nil { diff --git a/plugins/openapi/adapter/elasticsearch.go b/plugins/openapi/adapter/elasticsearch.go index e14b571..9bd8aaf 100644 --- a/plugins/openapi/adapter/elasticsearch.go +++ b/plugins/openapi/adapter/elasticsearch.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "regexp" + "slices" "strconv" "strings" @@ -49,9 +50,23 @@ var ( // 2026-11-19, when the newest release was 9.5.6), whose spec can still // change before it ships. func (Elasticsearch) LatestTag(ctx context.Context) (string, error) { + newest, branches, err := esMinors(ctx) + if err != nil { + return "", err + } + want := fmt.Sprintf("%d.%d", newest[0], newest[1]) + if slices.Contains(branches, want) { + return want, nil + } + return "", fmt.Errorf("elasticsearch %s is released, but elasticsearch-specification has no %s branch", want, want) +} + +// esMinors is the newest minor Elastic has released and every minor branch +// ("9.5") of elasticsearch-specification. +func esMinors(ctx context.Context) (newest [2]int, branches []string, err error) { body, err := fetch.Get(ctx, esReleasesURL, github.Headers()) if err != nil { - return "", fmt.Errorf("listing elasticsearch releases: %w", err) + return newest, nil, fmt.Errorf("listing elasticsearch releases: %w", err) } var releases []struct { Tag string `json:"tag_name"` @@ -59,9 +74,9 @@ func (Elasticsearch) LatestTag(ctx context.Context) (string, error) { Draft bool `json:"draft"` } if err := json.Unmarshal(body, &releases); err != nil { - return "", fmt.Errorf("parsing github releases: %w", err) + return newest, nil, fmt.Errorf("parsing github releases: %w", err) } - newest := [2]int{-1, -1} + newest = [2]int{-1, -1} for _, r := range releases { m := esRelease.FindStringSubmatch(r.Tag) if m == nil || r.Prerelease || r.Draft { @@ -73,26 +88,25 @@ func (Elasticsearch) LatestTag(ctx context.Context) (string, error) { } } if newest[0] < 0 { - return "", fmt.Errorf("github lists no elasticsearch release") + return newest, nil, fmt.Errorf("github lists no elasticsearch release") } body, err = fetch.Get(ctx, esBranchesURL, github.Headers()) if err != nil { - return "", fmt.Errorf("listing elasticsearch-specification branches: %w", err) + return newest, nil, fmt.Errorf("listing elasticsearch-specification branches: %w", err) } var refs []struct { Ref string `json:"ref"` } if err := json.Unmarshal(body, &refs); err != nil { - return "", fmt.Errorf("parsing github branch refs: %w", err) + return newest, nil, fmt.Errorf("parsing github branch refs: %w", err) } - want := fmt.Sprintf("%d.%d", newest[0], newest[1]) for _, r := range refs { - if strings.TrimPrefix(r.Ref, "refs/heads/") == want { - return want, nil + if b := strings.TrimPrefix(r.Ref, "refs/heads/"); esBranch.MatchString(b) { + branches = append(branches, b) } } - return "", fmt.Errorf("elasticsearch %s is released, but elasticsearch-specification has no %s branch", want, want) + return newest, branches, nil } func atoi(s string) int { diff --git a/plugins/openapi/adapter/testdata/README.md b/plugins/openapi/adapter/testdata/README.md new file mode 100644 index 0000000..d24b82e --- /dev/null +++ b/plugins/openapi/adapter/testdata/README.md @@ -0,0 +1,18 @@ +# Recorded API responses + +The version-listing tests (`versions_test.go`) read these instead of the network. Each was recorded on 2026-11-20 from the public API named, then trimmed: only the fields the adapter reads are kept, and some lists are cut to a few entries, said per file. Nothing else is changed. + +| File | Recorded from | Trimmed to | +|---|---|---| +| `versions/github-versions.json` | `https://api.github.com/versions` | whole | +| `versions/gitlab-tags-1.json` | `https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/tags?order_by=version&sort=desc&per_page=100&page=1` | all 100 tags; `name` and `commit.created_at` | +| `versions/gitlab-tags-2.json` | the same, `page=2` | 14 tags (18.10.0, 18.10.1, 18.9.x, 18.1.4); same fields | +| `versions/es-releases.json` | `https://api.github.com/repos/elastic/elasticsearch/releases?per_page=100` | all 100; `tag_name`, `prerelease`, `draft` | +| `versions/es-branches.json` | `https://api.github.com/repos/elastic/elasticsearch-specification/git/matching-refs/heads/` | the minor branches, `main` and `gh-pages` (33 of 250) | +| `versions/sentry-api-releases.json` | `https://api.github.com/repos/getsentry/sentry/releases?per_page=100&page=1` | the 19 `api@` releases; `tag_name`, `draft`, `prerelease`, `published_at`, asset names | +| `versions/sentry-schema-releases.json` | `https://api.github.com/repos/getsentry/sentry-api-schema/releases` (pages 1-4) | 2.3.2 and 2.4.0; same fields | +| `versions/algolia-refs.json` | `https://api.github.com/repos/algolia/api-clients-automation/git/matching-refs/tags/released-` | 9 of 186 tags, five of them on two days with several releases | +| `versions/algolia-commit-*.json` | `https://api.github.com/repos/algolia/api-clients-automation/commits/` | `sha` and the committer date | +| `versions/appwrite-commits.json` | `https://api.github.com/repos/appwrite/specs/commits?path=specs&per_page=100&page=1` | the 40 newest commits; `sha`, `html_url`, the committer date | + +Licenses: these are API metadata (tag names, dates, SHAs), not the projects' content. diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-45edcd844.json b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-45edcd844.json new file mode 100644 index 0000000..467081e --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-45edcd844.json @@ -0,0 +1,8 @@ +{ + "commit": { + "committer": { + "date": "2024-09-18T12:31:40Z" + } + }, + "sha": "45edcd844ff3a8f79bf3d04f7a6ee35b40e57b84" +} diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-cc190fae3.json b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-cc190fae3.json new file mode 100644 index 0000000..ae87e58 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-18-cc190fae3.json @@ -0,0 +1,8 @@ +{ + "commit": { + "committer": { + "date": "2024-09-18T19:37:12Z" + } + }, + "sha": "cc190fae3ddac7acbce990f38a1110f165520011" +} diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-6e91dbf55.json b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-6e91dbf55.json new file mode 100644 index 0000000..ae645d8 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-6e91dbf55.json @@ -0,0 +1,8 @@ +{ + "commit": { + "committer": { + "date": "2024-09-19T13:16:52Z" + } + }, + "sha": "6e91dbf555623d6a35e1491903ffbf3fdd4273f7" +} diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-a62c27d3b.json b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-a62c27d3b.json new file mode 100644 index 0000000..1ac6684 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-a62c27d3b.json @@ -0,0 +1,8 @@ +{ + "commit": { + "committer": { + "date": "2024-09-19T10:17:21Z" + } + }, + "sha": "a62c27d3bd51ca5e26f7d0cbd60a69e0b4408c9c" +} diff --git a/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-e47df6533.json b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-e47df6533.json new file mode 100644 index 0000000..41513af --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/algolia-commit-released-2024-09-19-e47df6533.json @@ -0,0 +1,8 @@ +{ + "commit": { + "committer": { + "date": "2024-09-19T19:28:05Z" + } + }, + "sha": "e47df65330ddcc3c61293ac8da7c0e89feb14948" +} diff --git a/plugins/openapi/adapter/testdata/versions/algolia-refs.json b/plugins/openapi/adapter/testdata/versions/algolia-refs.json new file mode 100644 index 0000000..f68d785 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/algolia-refs.json @@ -0,0 +1,29 @@ +[ + { + "ref": "refs/tags/released-2023-08-22" + }, + { + "ref": "refs/tags/released-2023-08-29" + }, + { + "ref": "refs/tags/released-2024-09-18-45edcd844" + }, + { + "ref": "refs/tags/released-2024-09-18-cc190fae3" + }, + { + "ref": "refs/tags/released-2024-09-19-6e91dbf55" + }, + { + "ref": "refs/tags/released-2024-09-19-a62c27d3b" + }, + { + "ref": "refs/tags/released-2024-09-19-e47df6533" + }, + { + "ref": "refs/tags/released-2026-11-10-8d91e3d8a3" + }, + { + "ref": "refs/tags/released-2026-11-17-31c309fe2a" + } +] diff --git a/plugins/openapi/adapter/testdata/versions/appwrite-commits.json b/plugins/openapi/adapter/testdata/versions/appwrite-commits.json new file mode 100644 index 0000000..8131340 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/appwrite-commits.json @@ -0,0 +1,42 @@ +[ +{"commit":{"committer":{"date":"2026-11-17T12:19:47Z"}},"html_url":"https://github.com/appwrite/specs/commit/529dfb64e0886acabd44f8e02fa96c5fdc7020cb","sha":"529dfb64e0886acabd44f8e02fa96c5fdc7020cb"}, +{"commit":{"committer":{"date":"2026-11-17T12:06:38Z"}},"html_url":"https://github.com/appwrite/specs/commit/946d0b0e8be2b1ea06c8591951b3df66ba33db51","sha":"946d0b0e8be2b1ea06c8591951b3df66ba33db51"}, +{"commit":{"committer":{"date":"2026-11-12T21:40:57Z"}},"html_url":"https://github.com/appwrite/specs/commit/f1c18dddc40bfabfcefc8a346583c7817f0af7c7","sha":"f1c18dddc40bfabfcefc8a346583c7817f0af7c7"}, +{"commit":{"committer":{"date":"2026-11-12T17:37:58Z"}},"html_url":"https://github.com/appwrite/specs/commit/3529c0c89cff4002f457dc1240dae84947fc23c1","sha":"3529c0c89cff4002f457dc1240dae84947fc23c1"}, +{"commit":{"committer":{"date":"2026-11-12T14:35:53Z"}},"html_url":"https://github.com/appwrite/specs/commit/4e00d85213d1884cc27abb1549f022c8b781bfaa","sha":"4e00d85213d1884cc27abb1549f022c8b781bfaa"}, +{"commit":{"committer":{"date":"2026-11-05T01:06:08Z"}},"html_url":"https://github.com/appwrite/specs/commit/218c99f7593e854ebf3089137aae4ad8bd50c48d","sha":"218c99f7593e854ebf3089137aae4ad8bd50c48d"}, +{"commit":{"committer":{"date":"2026-11-04T05:20:14Z"}},"html_url":"https://github.com/appwrite/specs/commit/5deee2847895a5f540cecb3b73035febc8ac4cba","sha":"5deee2847895a5f540cecb3b73035febc8ac4cba"}, +{"commit":{"committer":{"date":"2026-11-03T14:21:27Z"}},"html_url":"https://github.com/appwrite/specs/commit/9a50097dd538fd7663748aceed37fa05692bc5e4","sha":"9a50097dd538fd7663748aceed37fa05692bc5e4"}, +{"commit":{"committer":{"date":"2026-11-03T14:14:52Z"}},"html_url":"https://github.com/appwrite/specs/commit/90075ef836951a4d7173ec164eedafde9b37cf11","sha":"90075ef836951a4d7173ec164eedafde9b37cf11"}, +{"commit":{"committer":{"date":"2026-11-03T14:11:56Z"}},"html_url":"https://github.com/appwrite/specs/commit/64942f853d9fd2bed6c447424d12ead784824857","sha":"64942f853d9fd2bed6c447424d12ead784824857"}, +{"commit":{"committer":{"date":"2026-10-24T15:19:11Z"}},"html_url":"https://github.com/appwrite/specs/commit/b1ed34a3639a12c6763646585ec96ec7b4b5cd30","sha":"b1ed34a3639a12c6763646585ec96ec7b4b5cd30"}, +{"commit":{"committer":{"date":"2026-10-24T15:16:42Z"}},"html_url":"https://github.com/appwrite/specs/commit/7542cb07767c82d96dacb58f0590c28269ed2b58","sha":"7542cb07767c82d96dacb58f0590c28269ed2b58"}, +{"commit":{"committer":{"date":"2026-10-21T21:30:47Z"}},"html_url":"https://github.com/appwrite/specs/commit/3aba27c956bf7a3fe64605fed2f5081646ec3c52","sha":"3aba27c956bf7a3fe64605fed2f5081646ec3c52"}, +{"commit":{"committer":{"date":"2026-10-21T21:30:43Z"}},"html_url":"https://github.com/appwrite/specs/commit/eb54195bd82b1b6b4d35b873b33a9dc5e2811a5a","sha":"eb54195bd82b1b6b4d35b873b33a9dc5e2811a5a"}, +{"commit":{"committer":{"date":"2026-10-21T15:15:27Z"}},"html_url":"https://github.com/appwrite/specs/commit/177e27b44005f73e3fc455385a8f79dc3aeac897","sha":"177e27b44005f73e3fc455385a8f79dc3aeac897"}, +{"commit":{"committer":{"date":"2026-10-21T13:43:40Z"}},"html_url":"https://github.com/appwrite/specs/commit/138ae87d49b4df7122e2a4fde663d2f1bb830818","sha":"138ae87d49b4df7122e2a4fde663d2f1bb830818"}, +{"commit":{"committer":{"date":"2026-10-13T14:43:22Z"}},"html_url":"https://github.com/appwrite/specs/commit/5d0161216cc26eb898388e9c6ee51ecaae567c48","sha":"5d0161216cc26eb898388e9c6ee51ecaae567c48"}, +{"commit":{"committer":{"date":"2026-10-13T14:40:39Z"}},"html_url":"https://github.com/appwrite/specs/commit/5a3a34d5f592e1079f68dee24bee18bbcc930118","sha":"5a3a34d5f592e1079f68dee24bee18bbcc930118"}, +{"commit":{"committer":{"date":"2026-10-13T14:40:14Z"}},"html_url":"https://github.com/appwrite/specs/commit/26ab4b057d295fd42579f70b610ef27a880f485d","sha":"26ab4b057d295fd42579f70b610ef27a880f485d"}, +{"commit":{"committer":{"date":"2026-10-12T18:11:38Z"}},"html_url":"https://github.com/appwrite/specs/commit/06e6fafa4d1ae3c815843ff0b02a56e6e5582756","sha":"06e6fafa4d1ae3c815843ff0b02a56e6e5582756"}, +{"commit":{"committer":{"date":"2026-10-12T18:11:32Z"}},"html_url":"https://github.com/appwrite/specs/commit/54bfafcaa1ef8de99288d1014dc64ad1e4188d9c","sha":"54bfafcaa1ef8de99288d1014dc64ad1e4188d9c"}, +{"commit":{"committer":{"date":"2026-10-08T15:06:26Z"}},"html_url":"https://github.com/appwrite/specs/commit/98cc1a25215d3cead3a64f9bd4574a9c5b1ec87b","sha":"98cc1a25215d3cead3a64f9bd4574a9c5b1ec87b"}, +{"commit":{"committer":{"date":"2026-10-08T10:55:33Z"}},"html_url":"https://github.com/appwrite/specs/commit/fcaf861efd0186d0e53dd82df6993f90eb66bd7b","sha":"fcaf861efd0186d0e53dd82df6993f90eb66bd7b"}, +{"commit":{"committer":{"date":"2026-10-08T10:55:24Z"}},"html_url":"https://github.com/appwrite/specs/commit/0a012b5b85cf14c0f53db0da3bb49f97eab522ad","sha":"0a012b5b85cf14c0f53db0da3bb49f97eab522ad"}, +{"commit":{"committer":{"date":"2026-10-05T12:54:21Z"}},"html_url":"https://github.com/appwrite/specs/commit/275907e08299bda9c73e9cd08a75ede75444fce5","sha":"275907e08299bda9c73e9cd08a75ede75444fce5"}, +{"commit":{"committer":{"date":"2026-10-05T12:54:17Z"}},"html_url":"https://github.com/appwrite/specs/commit/20cd27f3a3d6caf923c829e880dae9d8a3d673d5","sha":"20cd27f3a3d6caf923c829e880dae9d8a3d673d5"}, +{"commit":{"committer":{"date":"2026-09-24T14:39:42Z"}},"html_url":"https://github.com/appwrite/specs/commit/96060bf70ebd673f94e349289ac5007815619be1","sha":"96060bf70ebd673f94e349289ac5007815619be1"}, +{"commit":{"committer":{"date":"2026-09-24T12:26:26Z"}},"html_url":"https://github.com/appwrite/specs/commit/fa0ac9e58511bf3a0ce4e5cdcb7d95413fcaf262","sha":"fa0ac9e58511bf3a0ce4e5cdcb7d95413fcaf262"}, +{"commit":{"committer":{"date":"2026-09-23T14:39:59Z"}},"html_url":"https://github.com/appwrite/specs/commit/af4c27c8f30e492e592a7c9ab6e83641851732d7","sha":"af4c27c8f30e492e592a7c9ab6e83641851732d7"}, +{"commit":{"committer":{"date":"2026-09-23T14:29:51Z"}},"html_url":"https://github.com/appwrite/specs/commit/9a2203ac099e272273296ddea1c89df92292975a","sha":"9a2203ac099e272273296ddea1c89df92292975a"}, +{"commit":{"committer":{"date":"2026-09-18T12:27:45Z"}},"html_url":"https://github.com/appwrite/specs/commit/29c25de5ddbfcf93b60f74e648da3b7312bc2012","sha":"29c25de5ddbfcf93b60f74e648da3b7312bc2012"}, +{"commit":{"committer":{"date":"2026-09-18T12:21:52Z"}},"html_url":"https://github.com/appwrite/specs/commit/19b780bf887c8ceb31bd4df5519e754b6202d1ce","sha":"19b780bf887c8ceb31bd4df5519e754b6202d1ce"}, +{"commit":{"committer":{"date":"2026-09-18T12:14:54Z"}},"html_url":"https://github.com/appwrite/specs/commit/623e580eae5dfaea7c62383ead066323a287c94b","sha":"623e580eae5dfaea7c62383ead066323a287c94b"}, +{"commit":{"committer":{"date":"2026-09-18T12:14:20Z"}},"html_url":"https://github.com/appwrite/specs/commit/d7fc6c4a5bd4dcd59b864bdf7485a235f4b654c3","sha":"d7fc6c4a5bd4dcd59b864bdf7485a235f4b654c3"}, +{"commit":{"committer":{"date":"2026-09-10T08:17:50Z"}},"html_url":"https://github.com/appwrite/specs/commit/592d16a6d8bedfff7da085fceceaa90affbc5056","sha":"592d16a6d8bedfff7da085fceceaa90affbc5056"}, +{"commit":{"committer":{"date":"2026-09-10T08:07:31Z"}},"html_url":"https://github.com/appwrite/specs/commit/371e49909b4deef9168e7563d96ff127d6324b71","sha":"371e49909b4deef9168e7563d96ff127d6324b71"}, +{"commit":{"committer":{"date":"2026-09-10T08:07:09Z"}},"html_url":"https://github.com/appwrite/specs/commit/0f0bd2ab63901f06c7fca107c7a95cf59d476e44","sha":"0f0bd2ab63901f06c7fca107c7a95cf59d476e44"}, +{"commit":{"committer":{"date":"2026-09-08T11:08:25Z"}},"html_url":"https://github.com/appwrite/specs/commit/56f42236ccdf7621019020e6224279d707d6f848","sha":"56f42236ccdf7621019020e6224279d707d6f848"}, +{"commit":{"committer":{"date":"2026-09-08T11:07:53Z"}},"html_url":"https://github.com/appwrite/specs/commit/3adab28615a52fb64641097c6d2cb266e9b650e6","sha":"3adab28615a52fb64641097c6d2cb266e9b650e6"}, +{"commit":{"committer":{"date":"2026-09-08T11:07:49Z"}},"html_url":"https://github.com/appwrite/specs/commit/2248bd24e9c4ab571694d3d3ac5dcf323263a63e","sha":"2248bd24e9c4ab571694d3d3ac5dcf323263a63e"} +] diff --git a/plugins/openapi/adapter/testdata/versions/es-branches.json b/plugins/openapi/adapter/testdata/versions/es-branches.json new file mode 100644 index 0000000..60832dc --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/es-branches.json @@ -0,0 +1,101 @@ +[ + { + "ref": "refs/heads/7.14" + }, + { + "ref": "refs/heads/7.15" + }, + { + "ref": "refs/heads/7.16" + }, + { + "ref": "refs/heads/7.17" + }, + { + "ref": "refs/heads/8.0" + }, + { + "ref": "refs/heads/8.1" + }, + { + "ref": "refs/heads/8.10" + }, + { + "ref": "refs/heads/8.11" + }, + { + "ref": "refs/heads/8.12" + }, + { + "ref": "refs/heads/8.13" + }, + { + "ref": "refs/heads/8.14" + }, + { + "ref": "refs/heads/8.15" + }, + { + "ref": "refs/heads/8.16" + }, + { + "ref": "refs/heads/8.17" + }, + { + "ref": "refs/heads/8.18" + }, + { + "ref": "refs/heads/8.19" + }, + { + "ref": "refs/heads/8.2" + }, + { + "ref": "refs/heads/8.3" + }, + { + "ref": "refs/heads/8.4" + }, + { + "ref": "refs/heads/8.5" + }, + { + "ref": "refs/heads/8.6" + }, + { + "ref": "refs/heads/8.7" + }, + { + "ref": "refs/heads/8.8" + }, + { + "ref": "refs/heads/8.9" + }, + { + "ref": "refs/heads/9.0" + }, + { + "ref": "refs/heads/9.1" + }, + { + "ref": "refs/heads/9.2" + }, + { + "ref": "refs/heads/9.3" + }, + { + "ref": "refs/heads/9.4" + }, + { + "ref": "refs/heads/9.5" + }, + { + "ref": "refs/heads/9.6" + }, + { + "ref": "refs/heads/gh-pages" + }, + { + "ref": "refs/heads/main" + } +] diff --git a/plugins/openapi/adapter/testdata/versions/es-releases.json b/plugins/openapi/adapter/testdata/versions/es-releases.json new file mode 100644 index 0000000..42f6bcc --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/es-releases.json @@ -0,0 +1,502 @@ +[ + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.25" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.5.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.9" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.24" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.5.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.23" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.22" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.5.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.5.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.21" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.5.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.5.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.20" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.5.0" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.19" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.18" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.17" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.16" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.4.0" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.15" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.14" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.13" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.12" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.3.0" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.11" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.10" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.10" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.9" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.9" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.2.0" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.17.10" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.1.0" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.19.0" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.17.9" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.3" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v7.17.29" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.17.8" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.2" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.17.7" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.17.6" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.18.0" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.17.5" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v9.0.0" + }, + { + "draft": false, + "prerelease": true, + "tag_name": "v9.0.0-rc1" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.17.4" + }, + { + "draft": false, + "prerelease": false, + "tag_name": "v8.16.6" + } +] diff --git a/plugins/openapi/adapter/testdata/versions/github-versions.json b/plugins/openapi/adapter/testdata/versions/github-versions.json new file mode 100644 index 0000000..1ed70f8 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/github-versions.json @@ -0,0 +1 @@ +["2026-03-10","2022-11-28"] \ No newline at end of file diff --git a/plugins/openapi/adapter/testdata/versions/gitlab-tags-1.json b/plugins/openapi/adapter/testdata/versions/gitlab-tags-1.json new file mode 100644 index 0000000..dd11e78 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/gitlab-tags-1.json @@ -0,0 +1,102 @@ +[ +{"name":"v19.6.1-ee","commit":{"created_at":"2026-11-19T22:47:46.000+00:00"}}, +{"name":"v19.6.0-rc43-ee","commit":{"created_at":"2026-11-17T15:41:23.000+00:00"}}, +{"name":"v19.6.0-rc42-ee","commit":{"created_at":"2026-11-17T09:18:16.000+00:00"}}, +{"name":"v19.6.0-ee","commit":{"created_at":"2026-11-18T17:40:45.000+00:00"}}, +{"name":"v19.5.8-ee","commit":{"created_at":"2026-11-19T21:37:02.000+00:00"}}, +{"name":"v19.5.6-ee","commit":{"created_at":"2026-11-16T15:34:18.000+00:00"}}, +{"name":"v19.5.5-ee","commit":{"created_at":"2026-11-11T04:11:12.000+00:00"}}, +{"name":"v19.5.4-ee","commit":{"created_at":"2026-11-06T15:44:23.000+00:00"}}, +{"name":"v19.5.3-ee","commit":{"created_at":"2026-10-28T05:04:29.000+00:00"}}, +{"name":"v19.5.2-ee","commit":{"created_at":"2026-10-27T09:34:33.000+00:00"}}, +{"name":"v19.5.1-ee","commit":{"created_at":"2026-10-20T23:00:49.000+00:00"}}, +{"name":"v19.5.0-rc43-ee","commit":{"created_at":"2026-10-14T19:43:39.000+00:00"}}, +{"name":"v19.5.0-rc42-ee","commit":{"created_at":"2026-10-13T12:08:07.000+00:00"}}, +{"name":"v19.5.0-ee","commit":{"created_at":"2026-10-15T00:37:08.000+00:00"}}, +{"name":"v19.4.10-ee","commit":{"created_at":"2026-11-19T21:52:01.000+00:00"}}, +{"name":"v19.4.8-ee","commit":{"created_at":"2026-11-16T15:51:20.000+00:00"}}, +{"name":"v19.4.7-ee","commit":{"created_at":"2026-11-11T04:21:19.000+00:00"}}, +{"name":"v19.4.6-ee","commit":{"created_at":"2026-11-06T15:56:03.000+00:00"}}, +{"name":"v19.4.5-ee","commit":{"created_at":"2026-10-28T05:14:24.000+00:00"}}, +{"name":"v19.4.4-ee","commit":{"created_at":"2026-10-27T09:35:49.000+00:00"}}, +{"name":"v19.4.3-ee","commit":{"created_at":"2026-10-20T23:07:57.000+00:00"}}, +{"name":"v19.4.2-ee","commit":{"created_at":"2026-10-07T14:19:10.000+00:00"}}, +{"name":"v19.4.1-ee","commit":{"created_at":"2026-09-22T11:59:12.000+00:00"}}, +{"name":"v19.4.0-rc44-ee","commit":{"created_at":"2026-09-16T05:33:49.000+00:00"}}, +{"name":"v19.4.0-rc43-ee","commit":{"created_at":"2026-09-15T12:46:19.000+00:00"}}, +{"name":"v19.4.0-rc42-ee","commit":{"created_at":"2026-09-15T02:05:20.000+00:00"}}, +{"name":"v19.4.0-ee","commit":{"created_at":"2026-09-16T15:51:13.000+00:00"}}, +{"name":"v19.3.9-ee","commit":{"created_at":"2026-11-16T16:02:35.000+00:00"}}, +{"name":"v19.3.8-ee","commit":{"created_at":"2026-11-06T16:19:00.000+00:00"}}, +{"name":"v19.3.7-ee","commit":{"created_at":"2026-10-27T09:41:55.000+00:00"}}, +{"name":"v19.3.6-ee","commit":{"created_at":"2026-10-20T23:15:49.000+00:00"}}, +{"name":"v19.3.5-ee","commit":{"created_at":"2026-10-12T09:38:10.000+00:00"}}, +{"name":"v19.3.4-ee","commit":{"created_at":"2026-10-07T14:32:16.000+00:00"}}, +{"name":"v19.3.3-ee","commit":{"created_at":"2026-09-22T12:07:51.000+00:00"}}, +{"name":"v19.3.2-ee","commit":{"created_at":"2026-09-10T08:20:41.000+00:00"}}, +{"name":"v19.3.1-ee","commit":{"created_at":"2026-08-25T08:42:17.000+00:00"}}, +{"name":"v19.3.0-rc44-ee","commit":{"created_at":"2026-08-19T18:21:05.000+00:00"}}, +{"name":"v19.3.0-rc43-ee","commit":{"created_at":"2026-08-18T19:52:52.000+00:00"}}, +{"name":"v19.3.0-rc42-ee","commit":{"created_at":"2026-08-18T19:35:00.000+00:00"}}, +{"name":"v19.3.0-ee","commit":{"created_at":"2026-08-20T01:16:27.000+00:00"}}, +{"name":"v19.2.10-ee","commit":{"created_at":"2026-10-28T15:03:32.000+00:00"}}, +{"name":"v19.2.9-ee","commit":{"created_at":"2026-10-20T17:18:17.000+00:00"}}, +{"name":"v19.2.8-ee","commit":{"created_at":"2026-10-07T14:40:40.000+00:00"}}, +{"name":"v19.2.7-ee","commit":{"created_at":"2026-09-22T12:16:30.000+00:00"}}, +{"name":"v19.2.6-ee","commit":{"created_at":"2026-09-10T08:29:18.000+00:00"}}, +{"name":"v19.2.5-ee","commit":{"created_at":"2026-08-25T09:20:04.000+00:00"}}, +{"name":"v19.2.4-ee","commit":{"created_at":"2026-08-14T18:02:15.000+00:00"}}, +{"name":"v19.2.2-ee","commit":{"created_at":"2026-08-11T23:49:23.000+00:00"}}, +{"name":"v19.2.1-ee","commit":{"created_at":"2026-07-29T01:07:58.000+00:00"}}, +{"name":"v19.2.0-rc44-ee","commit":{"created_at":"2026-07-15T11:59:57.000+00:00"}}, +{"name":"v19.2.0-rc43-ee","commit":{"created_at":"2026-07-14T08:15:21.000+00:00"}}, +{"name":"v19.2.0-rc42-ee","commit":{"created_at":"2026-07-14T07:47:00.000+00:00"}}, +{"name":"v19.2.0-ee","commit":{"created_at":"2026-07-15T20:06:11.000+00:00"}}, +{"name":"v19.1.10-ee","commit":{"created_at":"2026-10-28T15:04:27.000+00:00"}}, +{"name":"v19.1.9-ee","commit":{"created_at":"2026-10-20T17:47:42.000+00:00"}}, +{"name":"v19.1.8-ee","commit":{"created_at":"2026-09-10T08:39:07.000+00:00"}}, +{"name":"v19.1.7-ee","commit":{"created_at":"2026-08-25T09:46:12.000+00:00"}}, +{"name":"v19.1.6-ee","commit":{"created_at":"2026-08-14T17:44:15.000+00:00"}}, +{"name":"v19.1.4-ee","commit":{"created_at":"2026-08-12T00:53:23.000+00:00"}}, +{"name":"v19.1.3-ee","commit":{"created_at":"2026-07-29T01:14:45.000+00:00"}}, +{"name":"v19.1.2-ee","commit":{"created_at":"2026-07-07T09:07:17.000+00:00"}}, +{"name":"v19.1.1-ee","commit":{"created_at":"2026-06-23T15:10:23.000+00:00"}}, +{"name":"v19.1.0-rc43-ee","commit":{"created_at":"2026-06-17T04:05:32.000+00:00"}}, +{"name":"v19.1.0-rc42-ee","commit":{"created_at":"2026-06-16T03:50:35.000+00:00"}}, +{"name":"v19.1.0-ee","commit":{"created_at":"2026-06-17T09:24:55.000+00:00"}}, +{"name":"v19.0.11-ee","commit":{"created_at":"2026-10-28T15:04:31.000+00:00"}}, +{"name":"v19.0.10-ee","commit":{"created_at":"2026-10-20T18:55:09.000+00:00"}}, +{"name":"v19.0.9-ee","commit":{"created_at":"2026-09-22T09:18:37.000+00:00"}}, +{"name":"v19.0.8-ee","commit":{"created_at":"2026-08-14T17:35:10.000+00:00"}}, +{"name":"v19.0.6-ee","commit":{"created_at":"2026-08-12T01:01:52.000+00:00"}}, +{"name":"v19.0.5-ee","commit":{"created_at":"2026-07-29T01:22:07.000+00:00"}}, +{"name":"v19.0.4-ee","commit":{"created_at":"2026-07-07T09:16:20.000+00:00"}}, +{"name":"v19.0.3-ee","commit":{"created_at":"2026-06-23T15:19:18.000+00:00"}}, +{"name":"v19.0.2-ee","commit":{"created_at":"2026-06-10T02:43:17.000+00:00"}}, +{"name":"v19.0.1-ee","commit":{"created_at":"2026-05-26T23:13:26.000+00:00"}}, +{"name":"v19.0.0-rc43-ee","commit":{"created_at":"2026-05-20T13:38:20.000+00:00"}}, +{"name":"v19.0.0-rc42-ee","commit":{"created_at":"2026-05-19T02:55:01.000+00:00"}}, +{"name":"v19.0.0-ee","commit":{"created_at":"2026-05-21T00:28:28.000+00:00"}}, +{"name":"v18.11.14-ee","commit":{"created_at":"2026-10-27T09:42:28.000+00:00"}}, +{"name":"v18.11.13-ee","commit":{"created_at":"2026-10-20T17:32:08.000+00:00"}}, +{"name":"v18.11.12-ee","commit":{"created_at":"2026-09-22T09:11:39.000+00:00"}}, +{"name":"v18.11.11-ee","commit":{"created_at":"2026-08-14T17:24:21.000+00:00"}}, +{"name":"v18.11.9-ee","commit":{"created_at":"2026-08-06T04:01:12.000+00:00"}}, +{"name":"v18.11.8-ee","commit":{"created_at":"2026-08-03T08:57:50.000+00:00"}}, +{"name":"v18.11.7-ee","commit":{"created_at":"2026-07-07T09:22:51.000+00:00"}}, +{"name":"v18.11.6-ee","commit":{"created_at":"2026-06-23T15:27:04.000+00:00"}}, +{"name":"v18.11.5-ee","commit":{"created_at":"2026-06-10T02:49:43.000+00:00"}}, +{"name":"v18.11.4-ee","commit":{"created_at":"2026-05-26T23:20:09.000+00:00"}}, +{"name":"v18.11.3-ee","commit":{"created_at":"2026-05-13T10:30:07.000+00:00"}}, +{"name":"v18.11.2-ee","commit":{"created_at":"2026-04-28T16:29:21.000+00:00"}}, +{"name":"v18.11.1-ee","commit":{"created_at":"2026-04-21T13:40:54.000+00:00"}}, +{"name":"v18.11.0-rc43-ee","commit":{"created_at":"2026-04-15T12:17:09.000+00:00"}}, +{"name":"v18.11.0-rc42-ee","commit":{"created_at":"2026-04-14T15:48:21.000+00:00"}}, +{"name":"v18.11.0-ee","commit":{"created_at":"2026-04-15T21:41:05.000+00:00"}}, +{"name":"v18.10.8-ee","commit":{"created_at":"2026-06-10T02:56:44.000+00:00"}}, +{"name":"v18.10.7-ee","commit":{"created_at":"2026-05-26T23:26:31.000+00:00"}}, +{"name":"v18.10.6-ee","commit":{"created_at":"2026-05-13T10:36:35.000+00:00"}}, +{"name":"v18.10.5-ee","commit":{"created_at":"2026-04-28T16:48:26.000+00:00"}}, +{"name":"v18.10.4-ee","commit":{"created_at":"2026-04-21T13:51:03.000+00:00"}}, +{"name":"v18.10.3-ee","commit":{"created_at":"2026-04-07T12:30:23.000+00:00"}} +] diff --git a/plugins/openapi/adapter/testdata/versions/gitlab-tags-2.json b/plugins/openapi/adapter/testdata/versions/gitlab-tags-2.json new file mode 100644 index 0000000..6280b39 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/gitlab-tags-2.json @@ -0,0 +1,86 @@ +[ + { + "name": "v18.10.1-ee", + "commit": { + "created_at": "2026-03-24T16:07:05.000+00:00" + } + }, + { + "name": "v18.10.0-ee", + "commit": { + "created_at": "2026-03-18T13:35:57.000+00:00" + } + }, + { + "name": "v18.9.8-ee", + "commit": { + "created_at": "2026-05-25T20:33:16.000+00:00" + } + }, + { + "name": "v18.9.7-ee", + "commit": { + "created_at": "2026-05-13T10:41:30.000+00:00" + } + }, + { + "name": "v18.9.6-ee", + "commit": { + "created_at": "2026-04-21T13:56:40.000+00:00" + } + }, + { + "name": "v18.9.5-ee", + "commit": { + "created_at": "2026-04-07T12:41:16.000+00:00" + } + }, + { + "name": "v18.9.4-ee", + "commit": { + "created_at": "2026-03-31T13:57:04.000+00:00" + } + }, + { + "name": "v18.9.3-ee", + "commit": { + "created_at": "2026-03-24T16:13:31.000+00:00" + } + }, + { + "name": "v18.9.2-ee", + "commit": { + "created_at": "2026-03-10T17:49:47.000+00:00" + } + }, + { + "name": "v18.9.1-ee", + "commit": { + "created_at": "2026-02-24T20:32:28.000+00:00" + } + }, + { + "name": "v18.9.0-rc43-ee", + "commit": { + "created_at": "2026-02-18T11:31:27.000+00:00" + } + }, + { + "name": "v18.9.0-rc42-ee", + "commit": { + "created_at": "2026-02-17T08:22:20.000+00:00" + } + }, + { + "name": "v18.9.0-ee", + "commit": { + "created_at": "2026-02-18T17:07:38.000+00:00" + } + }, + { + "name": "v18.1.4-ee", + "commit": { + "created_at": "2025-08-12T12:44:06.000+00:00" + } + } +] diff --git a/plugins/openapi/adapter/testdata/versions/sentry-api-releases.json b/plugins/openapi/adapter/testdata/versions/sentry-api-releases.json new file mode 100644 index 0000000..7adc415 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/sentry-api-releases.json @@ -0,0 +1,382 @@ +[ + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.16.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-18T20:55:52Z", + "tag_name": "api@2.16.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.15.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-18T18:56:35Z", + "tag_name": "api@2.15.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.14.2.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-18T18:38:46Z", + "tag_name": "api@2.14.2" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.14.1.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-18T18:30:53Z", + "tag_name": "api@2.14.1" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.14.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-18T12:42:27Z", + "tag_name": "api@2.14.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.13.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-18T09:34:28Z", + "tag_name": "api@2.13.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.9.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-17T16:54:56Z", + "tag_name": "api@2.9.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.8.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-17T16:04:08Z", + "tag_name": "api@2.8.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.12.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-17T23:31:03Z", + "tag_name": "api@2.12.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.11.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-17T22:14:24Z", + "tag_name": "api@2.11.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.10.1.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-17T20:10:08Z", + "tag_name": "api@2.10.1" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.10.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-17T17:59:39Z", + "tag_name": "api@2.10.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.7.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-16T13:56:34Z", + "tag_name": "api@2.7.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.6.1.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-16T13:48:10Z", + "tag_name": "api@2.6.1" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.6.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-16T13:38:47Z", + "tag_name": "api@2.6.0" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.5.3.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-16T13:30:57Z", + "tag_name": "api@2.5.3" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.5.2.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-16T13:08:55Z", + "tag_name": "api@2.5.2" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.5.1.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-16T11:13:34Z", + "tag_name": "api@2.5.1" + }, + { + "assets": [ + { + "name": "api_ownership_stats_dont_modify.json" + }, + { + "name": "openapi-derefed.json" + }, + { + "name": "rpc_method_schema.json" + }, + { + "name": "sentry-api-2.5.0.tgz" + } + ], + "draft": false, + "prerelease": false, + "published_at": "2026-11-14T15:29:13Z", + "tag_name": "api@2.5.0" + } +] diff --git a/plugins/openapi/adapter/testdata/versions/sentry-schema-releases.json b/plugins/openapi/adapter/testdata/versions/sentry-schema-releases.json new file mode 100644 index 0000000..acf2dc1 --- /dev/null +++ b/plugins/openapi/adapter/testdata/versions/sentry-schema-releases.json @@ -0,0 +1,14 @@ +[ + { + "draft": false, + "prerelease": false, + "published_at": "2026-11-14T01:22:13Z", + "tag_name": "2.4.0" + }, + { + "draft": false, + "prerelease": false, + "published_at": "2026-11-14T00:30:35Z", + "tag_name": "2.3.2" + } +] diff --git a/plugins/openapi/adapter/versions.go b/plugins/openapi/adapter/versions.go index 9e6238e..dd2f0af 100644 --- a/plugins/openapi/adapter/versions.go +++ b/plugins/openapi/adapter/versions.go @@ -1,19 +1,26 @@ package adapter import ( + "cmp" "context" + "encoding/json" + "fmt" + "slices" "strings" + "time" + "github.com/patch-it-dev/patch-it-plugins/core/fetch" "github.com/patch-it-dev/patch-it-plugins/core/github" "github.com/patch-it-dev/patch-it-plugins/core/plugin" "github.com/patch-it-dev/patch-it-plugins/core/versions" ) -// Every version of each spec that can be listed, oldest first (Lister): the -// repo's releases for the adapters whose LatestTag is releases/latest, the -// commits that changed the spec for those that follow a file. The others -// (GitHub's dated versions, GitLab, Elasticsearch, Sentry, Algolia, Appwrite) -// are read at LatestTag only, for now. +// Every version of each spec, oldest first (Lister): the repo's releases for +// the adapters whose LatestTag is releases/latest, the commits that changed +// the spec for those that follow a file, and each other adapter's own +// listing (GitHub's dated versions, GitLab's release tags, Elasticsearch's +// released minors, Sentry's releases, Algolia's release tags, Appwrite's +// spec commits). Every adapter is a Lister. func releases(ctx context.Context, repo string, keep func(string) bool) ([]plugin.Version, error) { return versions.GitHubReleases(ctx, github.Get, repo, keep) @@ -73,3 +80,192 @@ var ( _ Lister = Convex{} _ Lister = PlanetScale{} ) + +// Versions are every API version GitHub supports, oldest first: each is a +// spec file of its own, and what a client sends as X-GitHub-Api-Version. +// GitHub publishes no spec for a version it no longer supports. +func (GitHub) Versions(ctx context.Context) ([]plugin.Version, error) { + body, err := fetch.Get(ctx, githubVersionsURL, github.Headers()) + if err != nil { + return nil, fmt.Errorf("looking up github's supported api versions: %w", err) + } + var ids []string + if err := json.Unmarshal(body, &ids); err != nil { + return nil, fmt.Errorf("parsing github versions response: %w", err) + } + slices.Sort(ids) + var out []plugin.Version + for _, id := range ids { + released, _ := time.Parse(time.DateOnly, id) + out = append(out, plugin.Version{ID: id, Released: released, Ref: id, URL: "https://docs.github.com/rest/about-the-rest-api/api-versions"}) + } + return out, nil +} + +// gitlabFirstSpec is the first release whose tag carries openapi_v3.yaml. +var gitlabFirstSpec = [3]int{18, 10, 0} + +// Versions are every stable GitLab release with the OpenAPI 3 spec +// (v18.10.0-ee on), oldest first by version: patch releases of an older +// minor (18.11.14) sit before the next minor's first release. The tags +// listing is read page by page, newest version first, until it passes +// v18.10.0-ee. +func (g GitLab) Versions(ctx context.Context) ([]plugin.Version, error) { + type tag struct { + Name string `json:"name"` + Commit struct { + Created time.Time `json:"created_at"` + } `json:"commit"` + } + var out []plugin.Version + for page := 1; page <= versions.MaxPages; page++ { + body, err := fetch.Get(ctx, fmt.Sprintf("%s&page=%d", cmp.Or(g.TagsURL, gitlabTagsURL), page), nil) + if err != nil { + return nil, fmt.Errorf("listing gitlab's tags: %w", err) + } + var tags []tag + if err := json.Unmarshal(body, &tags); err != nil { + return nil, fmt.Errorf("parsing gitlab tags response: %w", err) + } + older := false + for _, t := range tags { + m := gitlabRelease.FindStringSubmatch(t.Name) + if m == nil { + continue + } + v := [3]int{atoi(m[1]), atoi(m[2]), atoi(m[3])} + if slices.Compare(v[:], gitlabFirstSpec[:]) < 0 { + older = true + continue + } + out = append(out, plugin.Version{ID: gitlabVersion(t.Name), Released: t.Commit.Created.UTC(), Ref: t.Name, + URL: "https://gitlab.com/gitlab-org/gitlab/-/tags/" + t.Name}) + } + if older || len(tags) < 100 { + break + } + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) + return out, nil +} + +// esFirstSpec is the first minor whose branch has the OpenAPI output. +var esFirstSpec = [2]int{8, 14} + +// Versions are every released minor with the OpenAPI output (8.14 on), its +// branch the ref: up to the newest minor Elastic has released (LatestTag), +// never the next, unreleased one. +func (e Elasticsearch) Versions(ctx context.Context) ([]plugin.Version, error) { + newest, branches, err := esMinors(ctx) + if err != nil { + return nil, err + } + var out []plugin.Version + for _, b := range branches { + m := esBranch.FindStringSubmatch(b) + v := [2]int{atoi(m[1]), atoi(m[2])} + if slices.Compare(v[:], esFirstSpec[:]) < 0 || slices.Compare(v[:], newest[:]) > 0 { + continue + } + out = append(out, plugin.Version{ID: b + ".0", Ref: b, URL: "https://github.com/elastic/elasticsearch-specification/tree/" + b}) + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) + return out, nil +} + +// Versions are every release of the spec, oldest first by date: the +// getsentry/sentry-api-schema release tags (0.1.0 to 2.4.0, the archived +// repo) and then getsentry/sentry's api@X.Y.Z releases with the spec +// attached. The ID is the release's date, as Fetch's Version. The schema +// repo's commits before its first tag aren't listed; Fetch still reads one +// by its SHA. +func (s Sentry) Versions(ctx context.Context) ([]plugin.Version, error) { + var out []plugin.Version + for _, src := range []struct { + repo string + keep func(sentryReleaseInfo) bool + }{ + {"getsentry/sentry-api-schema", func(r sentryReleaseInfo) bool { return sentrySchemaTag.MatchString(r.Tag) }}, + {"getsentry/sentry", func(r sentryReleaseInfo) bool { return sentryRelease.MatchString(r.Tag) && r.hasSpec() }}, + } { + rs, err := versions.GitHubPages[sentryReleaseInfo](ctx, github.Get, s.api("/repos/"+src.repo+"/releases")) + if err != nil { + return nil, fmt.Errorf("listing %s's releases: %w", src.repo, err) + } + for _, r := range rs { + if r.Draft || r.Prerelease || !src.keep(r) { + continue + } + at := r.PublishedAt.UTC() + out = append(out, plugin.Version{ID: at.Format(time.DateOnly), Released: at, Ref: r.Tag, + URL: "https://github.com/" + src.repo + "/releases/tag/" + strings.ReplaceAll(r.Tag, "@", "%40")}) + } + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) + return out, nil +} + +// Versions are every release tag, oldest first. A day with several releases +// is ordered by each tag's commit date (LatestTag's rule), one lookup per +// tag on such a day only. +func (a Algolia) Versions(ctx context.Context) ([]plugin.Version, error) { + tags, err := algoliaTags(ctx) + if err != nil { + return nil, err + } + days := map[string]int{} + for _, t := range tags { + days[algoliaTag.FindStringSubmatch(t)[1]]++ + } + var out []plugin.Version + for _, t := range tags { + day := algoliaTag.FindStringSubmatch(t)[1] + released, _ := time.Parse(time.DateOnly, day) + if days[day] > 1 { + if released, err = algoliaCommitDate(ctx, t); err != nil { + return nil, err + } + } + out = append(out, plugin.Version{ID: day, Released: released.UTC(), Ref: t, + URL: "https://github.com/algolia/api-clients-automation/releases/tag/" + t}) + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) + return out, nil +} + +// Versions are the commits on appwrite/specs' default branch that changed +// specs/, oldest first: the ID is the commit's date (Fetch's Version), the +// Ref its SHA, read at the newest minor's directory. +func (a Appwrite) Versions(ctx context.Context) ([]plugin.Version, error) { + cs, err := versions.GitHubPages[struct { + SHA string `json:"sha"` + URL string `json:"html_url"` + Commit struct { + Committer struct { + Date time.Time `json:"date"` + } `json:"committer"` + } `json:"commit"` + }](ctx, github.Get, a.api("/commits?path=specs")) + if err != nil { + return nil, fmt.Errorf("listing the commits that changed appwrite's specs: %w", err) + } + var out []plugin.Version + for _, c := range cs { + if !appwriteCommit.MatchString(c.SHA) || c.Commit.Committer.Date.IsZero() { + continue + } + at := c.Commit.Committer.Date.UTC() + out = append(out, plugin.Version{ID: at.Format(time.DateOnly), Released: at, Ref: c.SHA, URL: c.URL}) + } + slices.SortStableFunc(out, func(a, b plugin.Version) int { return a.Released.Compare(b.Released) }) + return out, nil +} + +var ( + _ Lister = GitHub{} + _ Lister = GitLab{} + _ Lister = Elasticsearch{} + _ Lister = Sentry{} + _ Lister = Algolia{} + _ Lister = Appwrite{} +) diff --git a/plugins/openapi/adapter/versions_test.go b/plugins/openapi/adapter/versions_test.go new file mode 100644 index 0000000..98f10e5 --- /dev/null +++ b/plugins/openapi/adapter/versions_test.go @@ -0,0 +1,169 @@ +package adapter + +import ( + "context" + "net/http" + "net/http/httptest" + "os" + "slices" + "strings" + "testing" + + "github.com/patch-it-dev/patch-it-plugins/core/plugin" +) + +// recorded serves saved API responses (testdata/versions/, recorded +// 2026-11-20 and trimmed: testdata/README.md) by request path and query; +// any other request fails the test. +func recorded(t *testing.T, files map[string]string) *httptest.Server { + t.Helper() + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + key := r.URL.Path + if r.URL.RawQuery != "" { + key += "?" + r.URL.RawQuery + } + file, ok := files[key] + if !ok { + t.Errorf("unexpected request %s", key) + http.NotFound(w, r) + return + } + b, err := os.ReadFile("testdata/versions/" + file) + if err != nil { + t.Error(err) + } + w.Write(b) + })) + t.Cleanup(srv.Close) + return srv +} + +func ids(vs []plugin.Version) string { + var out []string + for _, v := range vs { + out = append(out, v.ID+"@"+v.Ref) + } + return strings.Join(out, " ") +} + +func TestGitHubListsEverySupportedVersion(t *testing.T) { + srv := recorded(t, map[string]string{"/versions": "github-versions.json"}) + old := githubVersionsURL + githubVersionsURL = srv.URL + "/versions" + t.Cleanup(func() { githubVersionsURL = old }) + vs, err := GitHub{}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + if got := ids(vs); got != "2022-11-28@2022-11-28 2026-03-10@2026-03-10" { + t.Errorf("versions %s", got) + } +} + +// Every stable release from v18.10.0-ee (the first with openapi_v3.yaml), in +// version order, release candidates left out; the listing is read a second +// page, and no further once it passes v18.10.0-ee. +func TestGitLabListsEveryReleaseWithTheSpec(t *testing.T) { + srv := recorded(t, map[string]string{ + "/tags?order_by=version&sort=desc&per_page=100&page=1": "gitlab-tags-1.json", + "/tags?order_by=version&sort=desc&per_page=100&page=2": "gitlab-tags-2.json", + }) + vs, err := GitLab{TagsURL: srv.URL + "/tags?order_by=version&sort=desc&per_page=100"}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + if vs[0].ID != "18.10.0" || vs[0].Ref != "v18.10.0-ee" || vs[len(vs)-1].ID != "19.6.1" { + t.Errorf("first %v, last %v", vs[0], vs[len(vs)-1]) + } + seen := map[string]bool{} + for _, v := range vs { + if strings.Contains(v.Ref, "rc") || v.Released.IsZero() || seen[v.ID] { + t.Errorf("version %v", v) + } + seen[v.ID] = true + } + at := func(id string) int { return slices.IndexFunc(vs, func(v plugin.Version) bool { return v.ID == id }) } + if !(at("18.11.14") < at("19.0.0") && at("19.0.0") < at("19.6.0") && at("18.10.1") > at("18.10.0")) { + t.Errorf("not in version order: %s", ids(vs)) + } +} + +// Every released minor from 8.14 (the first with the OpenAPI output) to the +// newest released one, 9.5: not 9.6, the next minor's branch. +func TestElasticsearchListsEveryReleasedMinor(t *testing.T) { + srv := recorded(t, map[string]string{"/releases": "es-releases.json", "/branches": "es-branches.json"}) + a, b := esReleasesURL, esBranchesURL + esReleasesURL, esBranchesURL = srv.URL+"/releases", srv.URL+"/branches" + t.Cleanup(func() { esReleasesURL, esBranchesURL = a, b }) + vs, err := Elasticsearch{}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + want := "8.14.0@8.14 8.15.0@8.15 8.16.0@8.16 8.17.0@8.17 8.18.0@8.18 8.19.0@8.19 9.0.0@9.0 9.1.0@9.1 9.2.0@9.2 9.3.0@9.3 9.4.0@9.4 9.5.0@9.5" + if got := ids(vs); got != want { + t.Errorf("versions\n %s\nwant\n %s", got, want) + } +} + +// The archived schema repo's tags, then getsentry/sentry's api@ releases, +// by date; the IDs are dates, as Fetch's Version. +func TestSentryListsBothRepos(t *testing.T) { + srv := recorded(t, map[string]string{ + "/repos/getsentry/sentry-api-schema/releases?per_page=100&page=1": "sentry-schema-releases.json", + "/repos/getsentry/sentry/releases?per_page=100&page=1": "sentry-api-releases.json", + }) + vs, err := Sentry{APIBase: srv.URL}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + if len(vs) != 21 || vs[0].Ref != "2.3.2" || vs[1].Ref != "2.4.0" || vs[2].Ref != "api@2.5.0" || vs[len(vs)-1].Ref != "api@2.16.0" { + t.Fatalf("versions %s", ids(vs)) + } + for i := 1; i < len(vs); i++ { + if vs[i].Released.Before(vs[i-1].Released) || vs[i].ID != vs[i].Released.Format("2006-01-02") { + t.Errorf("%v after %v", vs[i], vs[i-1]) + } + } +} + +// Every release tag, oldest first; the five tags of 2024-09-18 and -19 are +// ordered by their commits' dates, not their names. +func TestAlgoliaListsEveryReleaseTag(t *testing.T) { + files := map[string]string{"/refs": "algolia-refs.json"} + for _, tag := range []string{"2024-09-18-45edcd844", "2024-09-18-cc190fae3", "2024-09-19-6e91dbf55", "2024-09-19-a62c27d3b", "2024-09-19-e47df6533"} { + files["/commits/released-"+tag] = "algolia-commit-released-" + tag + ".json" + } + srv := recorded(t, files) + a, b := algoliaRefsURL, algoliaCommitURL + algoliaRefsURL, algoliaCommitURL = srv.URL+"/refs", srv.URL+"/commits/%s" + t.Cleanup(func() { algoliaRefsURL, algoliaCommitURL = a, b }) + vs, err := Algolia{Spec: "search"}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + var refs []string + for _, v := range vs { + refs = append(refs, strings.TrimPrefix(v.Ref, "released-")) + } + want := "2023-08-22 2023-08-29 2024-09-18-45edcd844 2024-09-18-cc190fae3 2024-09-19-a62c27d3b 2024-09-19-6e91dbf55 2024-09-19-e47df6533 2026-11-10-8d91e3d8a3 2026-11-17-31c309fe2a" + if got := strings.Join(refs, " "); got != want { + t.Errorf("refs\n %s\nwant\n %s", got, want) + } +} + +// Every commit that changed specs/, oldest first, dated. +func TestAppwriteListsEverySpecCommit(t *testing.T) { + srv := recorded(t, map[string]string{"/repos/appwrite/specs/commits?path=specs&per_page=100&page=1": "appwrite-commits.json"}) + vs, err := Appwrite{APIBase: srv.URL}.Versions(context.Background()) + if err != nil { + t.Fatal(err) + } + if len(vs) != 40 { + t.Fatalf("%d versions, want 40", len(vs)) + } + for i := 1; i < len(vs); i++ { + if vs[i].Released.Before(vs[i-1].Released) || len(vs[i].Ref) != 40 { + t.Errorf("%v after %v", vs[i], vs[i-1]) + } + } +}