Repository navigation
no pinned release in plugin code: every major's removed-members guide #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adssib
wants to merge
1
commit into
main
Choose a base branch
from
pl5-pins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+388
−182
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,21 @@ func TestPyPIReleasesAreFinalAndNotYanked(t *testing.T) { | |
| if !vs[0].Released.Equal(time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)) { | ||
| t.Errorf("released %v", vs[0].Released) | ||
| } | ||
| all, err := PyPIReleasesWithYanked(context.Background(), get, "acme") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if got := ids(all); got != "[email protected] [email protected] [email protected] [email protected]" { | ||
| t.Errorf("with yanked: got %s", got) | ||
| } | ||
| } | ||
|
|
||
| func TestFirstOfMajor(t *testing.T) { | ||
| for v, want := range map[string]bool{"2.0.0": true, "11.0.0": true, "2.0.1": false, "2.1.0": false, "0.0.0": false, "2.0": false, "2.0.0rc1": false} { | ||
| if got := FirstOfMajor(v); got != want { | ||
| t.Errorf("FirstOfMajor(%q) = %v, want %v", v, got, want) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestNPMReleases(t *testing.T) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package all | ||
|
|
||
| import ( | ||
| "go/ast" | ||
| "go/parser" | ||
| "go/token" | ||
| "io/fs" | ||
| "path/filepath" | ||
| "regexp" | ||
| "strconv" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| // release is a specific release in a string: a version number with three | ||
| // parts ("2.0.0", "v0.86.0", "posthog-v8.0.0", "python-agent-110000" aside) | ||
| // or a full commit SHA. A source lists its versions (PyPI, npm, tags, | ||
| // commits); only a test pins one, through its saved fixtures. | ||
| var release = regexp.MustCompile(`(^|[^0-9A-Za-z.])v?\d+\.\d+\.\d+([^0-9]|$)|(^|[^0-9a-f])[0-9a-f]{40}([^0-9a-f]|$)`) | ||
|
|
||
| // No plugin's code names a specific release or commit: every version comes | ||
| // from where the source publishes them. Comments may name the release a | ||
| // reader was checked at; a string the code uses may not. | ||
| func TestNoPinnedReleaseInPluginCode(t *testing.T) { | ||
| fset := token.NewFileSet() | ||
| err := filepath.WalkDir("..", func(path string, d fs.DirEntry, err error) error { | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if d.IsDir() && d.Name() == "testdata" { | ||
| return filepath.SkipDir | ||
| } | ||
| if d.IsDir() || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") { | ||
| return nil | ||
| } | ||
| f, err := parser.ParseFile(fset, path, nil, 0) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| ast.Inspect(f, func(n ast.Node) bool { | ||
| lit, ok := n.(*ast.BasicLit) | ||
| if !ok || lit.Kind != token.STRING { | ||
| return true | ||
| } | ||
| s, err := strconv.Unquote(lit.Value) | ||
| if err == nil && release.MatchString(s) { | ||
| t.Errorf("%s: %q names a specific release; list versions from the source and pin one only in a test", fset.Position(lit.Pos()), s) | ||
| } | ||
| return true | ||
| }) | ||
| return nil | ||
| }) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package changelog | ||
|
|
||
| // The releases the golden files pin. Only a test names a release: the | ||
| // registered sources list theirs from PyPI. | ||
| var ( | ||
| Textual0860 = Textual.At("0.86.0") | ||
| Urllib3200 = Urllib3.At("2.0.0") | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes behaviour for five other sources, not just New Relic.
LatestCommitis also called by the OpenAPI adapters for Appwrite, Convex, Neon, PlanetScale and Supabase (plugins/openapi/adapter/{appwrite,convex,neon,planetscale,supabase}.go), and each one wraps the error with%w. So if one of those providers moves or renames its spec, the empty commit list now reaches the runner asErrNothingToRead. The pair gets skipped quietly, where today it fails and someone notices the broken source.Suggestion: keep a neutral sentinel here, e.g.
var ErrNoCommit = errors.New("github lists no commit"), and turn it into "nothing to read" only inmembers.Guide.GuideURL, where an empty list really does mean "this major has no note":As a side effect,
core/githubwould no longer need to importcore/plugin.