aboutsummaryrefslogtreecommitdiff
path: root/internal/testing
AgeCommit message (Collapse)Author
5 daysinternal/testing/fakedatasource: improve docJonathan Amsterdam
This was inadvertently left out of an earlier CL. Change-Id: I5ec5d82c9fa2efcc27c076360cb50097c86655d7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/764821 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
6 daysinternal/api: test licenses and imports paramsJonathan Amsterdam
Test the "licenses" and "imports" query params for the packages route. Change-Id: I46c7dd18f0eb2e104d124d2d724039f920247e5b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/764540 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Bypass: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ethan Lee <ethanalee@google.com> Auto-Submit: Jonathan Amsterdam <jba@google.com>
7 daysinternal/api: add examples parameter to PackageParamsEthan Lee
- Enable conditional population of examples by introducing a new examples parameter. Change-Id: I53314344a414c41b423185c115e600ec8b63e6bf Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/763282 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ethan Lee <ethanalee@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2026-03-30internal/api: implement package imported-by endpointEthan Lee
- Implement ServePackageImportedBy handler and GetImportedBy and GetImportedByCount datasource methods. Change-Id: I8c4cc65fbff7172eaf48e5426e4f3f41c82bd38e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754865 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ethan Lee <ethanalee@google.com>
2026-03-26all: run go fix -stringsbuilderHana Kim
Change-Id: I839e47c2b39ee592909f7ecb03603d4fb1d1954b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753430 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-26all: run go fix -slicescontainsHana Kim
Change-Id: I14479d9e612dfa7eed9188206746af5b51c10201 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753428 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2026-03-26internal: consolidate build context and unit resolution logicEthan Lee
- Centralize logic for resolving units and selecting the best matching build context. - New helpers MatchingBuildContext, SortedBuildContexts provide a consistent, efficient approach to build context selection. - DocumentationForBuildContext now finds the best match based on precdence rules rather than just returning the first match. - A new getUnitContext helper resolves unit metadata and the best build context in a single query. - GetSymbols and GetUnit are now both optimized to use pre-resolved IDs, simplifying their queries and removing redundant joins. - Replaced redundant matchingDoc functions in fetchdatasource and fakedatasource. Change-Id: I9207d3bfe03404483c816090a0b99666f14a36e3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/759162 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ethan Lee <ethanalee@google.com>
2026-03-26all: fix rangeintHana Kim
Change-Id: I58ed5e7d2a3bbc13bc389ac7239737e18856dbfe Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/753427 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-26internal/api: implement package symbols endpointEthan Lee
- Introduce a new ServePackageSymbols handler that utilizes the new db.GetSymbols method. - Consolidated module resolution logic shared by ServePackages into resolveModulePath. - Updated Datasource with GetSymbols, which provides a more efficient way to retrieve all symbols for a package at a given version and build context. This differs from the existing getPackageSymbols, since that will return symbols for the latest release/compatible version. - Refactored packageSymbolQueryJoin into a generic helper by removing hardcoded version filters. This allows GetSymbols to query for any specific version, while getPackageSymbols was updated to explicitly include release-only filters to preserve its existing behavior. - GetSymbols still utilizes the same underlying packageSymbolQueryJoin, but it will also attempt to match the most relevant BuildContext for the query. It will also provide a mapping of parent and child symbols. Change-Id: Ib18d2511d24ac6bc5b75c7b3809c4ce126245036 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754864 Auto-Submit: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-25all: add LatestVersion to ModuleInfoEthan Lee
- Add LatestVersion field to internal.ModuleInfo and update tests accordingly. - Changed some test formatting to improve readability. Change-Id: I1238e54614ef276d219b31d125cd2cad6b5a66f7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/756901 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Ethan Lee <ethanalee@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2026-03-24internal/api: implement module packages endpointEthan Lee
- Implement the ServeModulePackages handler and introduce GetModulePackages to return the list of packages for a given module version. Change-Id: I20c1618e2fdbf0126cb913665a1d7457b8951177 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754863 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Ethan Lee <ethanalee@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2026-03-23internal/api: implement module versions endpointEthan Lee
- Implement module versions endpoint using ds.GetVersionsForPath - Introduce paginate helper to generalize paginaton logic - Update fakedatasource to correctly use V1Path to return all versions Change-Id: Icc028bf8ca9c13978bb6eba84afe9736ccd6bcee Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754862 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2026-03-20internal: conditionally return documentation in GetUnitEthan Lee
- Large documentations blobs should avoid being returned unless explicitly requested. Add a WithDocsSource to enable retrieval of unit information without the large documentation source information. - This does not functionally change existing GetUnit callsites. Change-Id: Ie983b7eaeb61bb92f2716ae64a3d1e1ea738dbe2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/756480 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Ethan Lee <ethanalee@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-19internal/api: implement module metadata endpointEthan Lee
Change-Id: Id6b8686012803c88c9b7ea71e4b1c0058b7967b0 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754861 Auto-Submit: Ethan Lee <ethanalee@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2026-02-25internal/queue: move InMemory queue to its own packageJean Barkhuysen
Currently, InMemory queue sits in queue, and is instantiated in gcpqueue for convenience. In preparation for a third queue type (Postgres), this CL separates the two more cleanly, making it more ergonomic for the new queue type to slot in next to the existing two. This CL doesn't change any logic: it just exists to make the next CL smaller and easier to review. I also took the liberty of adding some tests specific to the InMemory queue, since I didn't find any. Let me know if it's tested in another place, though, and if you'd prefer me to remove it. Updates golang/go#74027. Change-Id: I44bd92129f33bc7975fcd138c905e0b7ab49d257 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/747881 kokoro-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ethan Lee <ethanalee@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2025-11-13internal/testing: avoid data race to NonRedistributableLicenseRob Findley
During insertion, pkgsite may mutate non-redistributable licenses to purge their contents. This leads to data races and path dependence in tests that were reusing the sample.NonRedistributableLicense value. Turn this variable into a function, so that we return a new value each time. This revealed a logic error in TestGetLicensesBypass: the test which was nominally checking that the non-redistributable contents were returned, was in fact also emptying out the expected contents, probably to make the test pass given the bug fixed above. Change-Id: I957014d009ae41638599d61592766b7ae1c175e7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/720260 Reviewed-by: Ethan Lee <ethanalee@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-24Revert "internal/frontend: recycle database connections every 5m"Robert Findley
This reverts commit 4b544d88ef33b543889e92d50bcc7b02d4b95ff0. Reason for revert: From slack, this causes the following error: 2025/06/23 21:17:14 Error: middleware.Panic: sql: Register called twice for driver ocWrapper-pgx Change-Id: I7caf80f4e13ca341e2f29d20c4b5b9ed963695b2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/683635 Auto-Submit: Robert Findley <rfindley@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2025-06-23internal/frontend: recycle database connections every 5mRob Findley
In order to avoid imbalance between pkgsite's two database instances, recycle connections every 5 minutes. Change-Id: I9ca1e686a90f8c61619fd76454ec66163e501ee1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/680175 kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2025-01-03all: make function and struct comments match the namescuishuang
Change-Id: Ic939b5b002e881f8041ccb95114010fe7e751f9a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/639558 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-02-21internal/postgres: support module@version exclusionsJonathan Amsterdam
Allow a specific module@version to be excluded. Previously, only entire module paths or path prefixes (at every version) could be excluded. This will allow us to exclude specific versions that we can't process, because they are too large for instance. A necessary part of the change is adding a version argument to the IsExcluded method. While we are there, we drop the error return value, since it's always nil. Change-Id: I68fd1c8f66ee654e56bd7dcf230a88959b32bbc8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/565815 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2024-01-23internal: move UnitMeta.IsRedistributable to UnitMichael Matloob
Change-Id: Ia0a18df32d752f20b0400b47860638c7d0910eb7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/556435 Reviewed-by: Jonathan Amsterdam <jba@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
2024-01-22internal: move UnitMeta.Licenses to UnitMichael Matloob
Change-Id: If2b3c1acd4830948e2d134517608f89771a7abcb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/555735 kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
2023-11-15internal/testing/htmlcheck: replace use of cascadia in InMichael Matloob
This cl implements the :nth-child() and :nth-of-type() pseudoclasses for the css selector query function, allowing it to be used for htmlcheck.In. It also replaces the single use of a a child combinator '>' in a test with a descendant combinator ' ' so that we don't need to implement the child combinator. The test should have the same behavior. For golang/go#61399 Change-Id: I09d9b8fbcd0eafd37aceb5994515687c85244ef8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/542058 kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-15internal/testing/htmlcheck: replace cascadia for htmlcheck.NotInMichael Matloob
This change reimplements a subset of cascadia's query functionality so we can replace it for htmlcheck.NotIn. It adds code that parses a subset of the css selector syntax (currently it's more than we need for NotIn but not enough for In) and adds a query function to query the selector in the given html node. Unlike cascadia, our query function can match the node itself. Future cls will add support for more selector syntax so we can support everything htmlcheck.In is used for but we only intend so support just what we need. I also limit the selector syntax to ascii for simplicity. For #61399 Change-Id: Ia03cc8a9ab42ae11d445a650e1ca0a07ee8a391f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/541437 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-10internal/testing/htmlcheck: delete InAllMichael Matloob
It doesn't seem to be used anywhere. For #61399 Change-Id: I068ed8638ec24702a210b269097bec735ce0368b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/539483 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2023-09-07static/frontend: added fix for screen reader to announce complete info.Prudhvi Krishna Chintala
Change-Id: I2a4ead59d213388c09b1d7a98bc6e62f9ba85e0c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/517455 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-29internal/source: inject *http.Client into source.NewClientMichael Matloob
This removes the dependency from package source onto ochttp. The users of source.NewClient that want an ochttp.Transport can set the transport on the *http.Client. For golang/go#61399 Change-Id: Ifb7126c482f664ee5a359f594d9324f0fd90f8b2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/523510 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com>
2023-08-25internal/frontend/versions: remove test dependence on postgres dbMichael Matloob
This CL implements GetVersionsForPath on FakeDataSource (and removes the error return from GetSymbolHistory) so that the FakeDataSource can be used to replace the postgres db in TestFetchPackageVersionsDetails, and remove the postgresdb from the test entirely. For golang/go#61399 Change-Id: I84833a35029457d0a0a30f8d96b8b6238934e65c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/521123 kokoro-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2023-08-22internal/testing/fakedatasource: implement PostgresDB interfaceMichael Matloob
This change adds the rest of the methods from the PostgresDB interface to the fake data source so it can be used to test some functions that expect a postgres db. Most of the methods are left unimplemented. I removed the IsPostgresDB that I originally put on the PostgresDB interface since now we will have other types try to be PostgresDBs. In an upcoming CL, I will extend the DataSource interface so that it's the same as PostgresDB, and just have the frontend handle errors that are errors.ErrUnsupported. The CL then updates tests on some of the methods on the frontend that need a PostgresDB to use the FakeDataSource instead. This CL then removes the code that sets up and runs the internal/frontend tests with a PostgresDB. For golang/go#61399 Change-Id: I3bae5adc5ec03536b2074eee32b4e5558dfa7478 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/520878 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-21internal/testing/fakedatasource: add a fake for internal.DataSourceMichael Matloob
This CL creates a new FakeDataSource type that has enough of an implementation to replace some of the uses of the postgres database (though not yet all) in the internal/frontend tests. Parts of the implementation have been taken from the pre-existing datasource implementation in FetchDataSource and postgres.DB. For golang/go#61399 Change-Id: I761178d8d4f65457738c46c4733f1231ee32c645 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/520615 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
2023-08-21internal/frontend: move fetchserver and versions to their own packagesMichael Matloob
Moving fetchserver to its own package will allow us to to move the fetch logic, which isn't used by cmd/pkgsite because it doesn't have a postgres database, out of the frontend and pkgsite. The tests, which depend on a postgres database are moved out too, removing a few users of the postgres database in the tests. The versions code is moved into its own package as well so it can be used by the fetchserver code without depending on the frontend package. Most of server_test.go, which was testing features that are provided by what is now the FetchServer has been moved to the fetchserver package. To ensure that git properly realizes it as a move, the rest of server_test has been moved to frontend_test. In some cases I made copies of functions (absoluteTime, insertTestModules) instead of creating intermediate packages to contain them. For golang/go#61399 Change-Id: Ic94419f9d75f766e289cc3fb9a1521173cefb4d1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/519335 Reviewed-by: Robert Findley <rfindley@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org>
2023-08-21internal/frontend: separate fetch and 404 logic into fetchserverMichael Matloob
ServeFetch and ServePathNotFoundPage only work when a postgres database is present. Separate them out into a different fetchserver type which can be moved into a different package (in a followup cl). This will allow their behavior, which is not used by cmd/pkgsite, to be removed from that server. More importantly, their tests, which depend on a real postgres database can be separated from the tests of package internal/frontend. For golang/go#61399 Change-Id: I73677fd06750fd48580071b8a895b322d9e3ac5d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/518817 kokoro-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2023-08-04internal/frontend: add an interface for creating request cachesMichael Matloob
This change adds a new Cacher interface that is used to create middlewares for caching requests. This abstracts away the use of redis so that the frontend doesn't depend on redis. The tests still depend on redis for the 404 page testing logic, but the 404 page logic will be moved out into a different package so those tests will go too. The Expirer and Middleware interfaces are not present on the Cache function so that the interface can be defined in package internal/frontend without needing the dependency on the Middleware package. For golang/go#61399 Change-Id: I6518b2ed1d772cb4deda3308c4190f0f1b8a35a0 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/514518 kokoro-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org>
2023-07-10internal: add build tags guarding code that doesn't build on plan9Michael Matloob
This is intended to get the misc-compile-plan9 builder passing. internal/static adds a stub for plan9 that panics since the esbuild module it uses doesn't build on plan9. A bunch of tests that use miniredis are build tagged since miniredis doesn't build on plan9 The setup of testDB in server_test.go is moved to its own file frontend_test so it can be used by other test files in the package while allowing us to disable server_test which uses miniredis. For #61209 Change-Id: Iacb39180459e31c946d02b62e8c03e91368c087a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/508448 TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Michael Matloob <matloob@google.com>
2023-03-14cmd/pkgsite: add multi-module support, invalidation, and searchRobert Findley
This change adds a new goPackagesModuleGetter, which uses x/tools/go/packages to query package information for modules requested by the pkgsite command. Additionally, add new extension interfaces that allow getters to add support for search and content invalidation. The go/packages getter uses these extensions to implement search (via a simple fuzzy-matching algorithm copied from x/tools), and invalidation via statting package files. Along the way, refactor slightly for testing ergonomics. Updates golang/go#40371 Updates golang/go#50229 Fixes golang/go#54479 Change-Id: Iea91a4d6327707733cbbc4f74a9d93052f33e295 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/474295 TryBot-Result: kokoro <noreply+kokoro@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2022-06-17many: re-enable staticcheck and fix problemsJonathan Amsterdam
Most of the checks were about io/ioutil. There were a couple of other minor ones. I didn't address the check for strings.Title; instead, I turned off that check globally with a staticcheck.conf file. Change-Id: I286a6894fb1fd891818ab9e451c891f52a3828fc Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/412675 Reviewed-by: Jamal Carvalho <jamal@golang.org> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com>
2022-04-11all: gofmtRuss Cox
Gofmt to update doc comments to the new formatting. For golang/go#51082. Change-Id: Ia9e71e7ecac75822ff43d6c7e60f512442a5fa50 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/399617 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-11-16internal/frontend: add debug handlersJonathan Amsterdam
Add handlers that: - serve basic info about the Cloud Run revision and instance - serve pprof information, so we can track memory leaks These are only live if the "debug" experiment is active, so we can turn them on and off dynamically. Change-Id: I71a14f3893066d44432cd26b0a327deddb2040d9 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/364354 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-11-15internal/licenses: remove Metadata.OldCoverageJonathan Amsterdam
We don't need the OldCoverage field anymore. All DBs have only the new Coverage information. Change-Id: Ib2d8e0cdacdc2f7b6514a8a5310d6905be15136c Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/363954 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-10-28many: cmd/pkgsite embeds static assetsJonathan Amsterdam
The `pkgsite` command now embeds all the static assets it needs, so it need not be told the location of the static/ directory with a flag. The binary is self-contained and can be placed and invoked from anywhere. This required embedding the static/ and third_party/ directories. Since //go:embed cannot reference files outside the containing package's tree, we had to add trivial Go packages in static/ and third_party/ to construct `embed.FS`s for those directories. Also, the frontend needed to accept `fs.FS` values where it previously took paths, and `template.TrustedFS` values where it previously used `template.TrustedSources`. We ended up clumsily requiring four separate config values: - A TrustedFS to load templates. - Two fs.FSs, one for static and one for third_party, to load other assets. - The path to the static directory as a string, solely to support dynamic loading in dev mode. For golang/go#48410 Change-Id: I9eeb351b1c6f23444b9e65b60f2a1d3905d59ef9 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/359395 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-09-07internal/fetch: get source info from module getterJonathan Amsterdam
Make it the ModuleGetter's responsibility to provide links to source files, instead of passing around a separate source.Client. This will allow getters that fetch from disk to serve those local files. For golang/go#47982 Change-Id: I6c7cd7890b03ad61d9410850a510c1c9a63f1c9a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/347749 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-09-01internal: change m=json to content=jsonJulie Qiu
The m=json query param that is allowed when serve stats is enabled to changed to content=json, to avoid clashing with the m=package or m=symbol param on the search page. Change-Id: I5037da00323e1c721485347c6616418edb1c64fe Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/346410 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-09-01internal/{worker/fetch}: include DB activity in load-sheddingJonathan Amsterdam
Move the load-shedding logic to the worker and have it span both the fetch and processing of the module (as previously) as well as inserting it into the database. This is a more accurate estimation of load, since running a lot of concurrent queries definitely slows down processing. Most of the time this won't make much difference, but under high load, such as when processing multiple large modules, it will reduce DB contention and should result in greater throughput. For golang/go#48010 Change-Id: I7d0922e02d00182e867fd3b29fc284c32ecab5ee Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/346749 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-08-24internal/fetch: populate Unit.BuildContextsJonathan Amsterdam
Populate the lists of build contexts when fetching a module. Currently we only do this when reading from the DB. We want DataSources that rely only on fetch to have the right value. For golang/go#47780 Change-Id: Ie85fba8ccb318bb4ed5c1f2153b0ba4216358022 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/344670 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-08-23static,internal: remove new-unit-layout experimentJamal Carvalho
Change-Id: Ib7d3a51fdc427cabcbec998130c6973497c1a750 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/344394 Trust: Jamal Carvalho <jamal@golang.org> Run-TryBot: Jamal Carvalho <jamal@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-08-23internal/fetch: use fs.FSJonathan Amsterdam
Rewrite fetch code to use fs.FS instead of zip.Reader. For golang/go#47834 Change-Id: Iefdd16b367218690c4e5bea2a4688bea10a94be1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/343952 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-08-20internal,tests: delete symbol history experimentsJulie Qiu
Change-Id: If780b7339dfb415c2060dc1fc9f020a5af57665d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/343709 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-08-18internal/proxy/proxytest: proxy test codeJonathan Amsterdam
Most of the code in internal/proxy was only for testing. Move it to a separate package for clarity. Change-Id: Ie9d241bc8a12923b579a7dd69ae7b36aaa1fd42a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/343209 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-08-06all: delete redis HA clientsJulie Qiu
The redis HA was used by search autocomplete and is no longer used by anything. Change-Id: I39a2c81c47da53823d7b668a980159c4726c6b13 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/340393 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-08-05tests/api,internal/frontend: add compare scriptJulie Qiu
The tests/api/main.go script is updated to compare the frontend symbol history data with data in tests/api/testdata. For golang/go#37102 Change-Id: I5eb5fc367343ce386c7a2d2d7a53c0d3fad9da4f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/339490 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>