aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/unit_test.go
AgeCommit message (Collapse)Author
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-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-02-03internal/postgres: optimize unit metadata lookup for unknown module pathsEthan Lee
When a user requests a package with a symbolic version (e.g., @master) and the module boundary is not yet known, pkgsite currently triggers a "greedy" index scan on the modules table's series_path index to find the best match. This change optimizes the lookup by explicitly providing candidate module paths using internal.CandidateModulePaths. This allows the Postgres optimizer to perform efficient point lookups on the module_path index rather than a linear scan. Fixes golang/go#77367 Change-Id: I072a72dc043ff7fb704977f07ba9fbd4ec821815 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/741300 kokoro-CI: kokoro <noreply+kokoro@google.com> 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>
2025-08-14internal/postgres: apply bypassLicenseCheck to IsRedistributable columnJean Barkhuysen
This enables symbol search for non-LICENSE'd repos when -bypass_license_check is supplied. I think the way this works is that when these get insert into units, we don't consider bypassLicenseCheck, and the IsRedistributable column gets set to false. That all seems reasonable by itself. But later, in upsertSymbolSearchDocuments, we only upsert symbol docs for units that are redistributable. That check happens in SQL, so it's hard to factor in the bypassLicenseCheck flag. It's not really clear to me whether we should "pollute" the database with this column set to true under the flag. If you run the program again with the flag turned off, your database keeps the values set under the old run. Anyways, I think this CL is probably the pragmatic take: it's a small code change that achieves the desired result without added complexity, and it's unlikely that anyone will run into the undesired outcome I describe above (who is running this program sometimes with the flag on, sometimes with it off?). Change-Id: Ie15bcf0605b945e4af6574abf689827ea946ddae Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/685457 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Commit-Queue: Jonathan Amsterdam <jba@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-08-23all: remove arbitrary hard-coded timeouts in testsBryan C. Mills
If a test times out, that implies that it got stuck on something. By default, the Go testing package dumps goroutines when its own timeout is passed, which prints a goroutine dump, helping to reveal what was stuck. Adding an arbitrary timeout on top of the testing package's own timeout is, in my experience, almost always counterproductive. If the arbitrary timeout catches a real hang, it causes the test to fail instead of dumping goroutines, making it much harder to see what was stuck. On the other hand, if the timeouts are set aggressively enough to make the test fail early, they are often too aggressive for CI testing, causing flakes that then have to be triaged on an ongoing basis. On balance, the value of saving a minute or two for developers who have introduced a hang is not worth the cost of suppressing debugging information and causing flakes that have to be triaged. Fixes #61556. For #59347. Change-Id: I0263d0d9b18283470f100e5a0155818b87b5312f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/521837 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Michael Matloob <matloob@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-06-18many: remove read-imports experimentJonathan Amsterdam
Remove the read-imports experiment and all references to the package_imports table. Change-Id: If926c47e1d01b3ab0f31bb6efb9c2234418fca1b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/329229 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-06-10internal/postgres: read from imports tableJonathan Amsterdam
Read from the imports table instead of package_imports, under an experiment. Change-Id: Id5b61285325f28a168faeb25651839663269feaf Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/326450 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
2021-06-07internal/version: drop Version suffix from constantsJulie Qiu
To avoid repetition, the "Version" suffix in version.LatestVersion, version.MainVersion, and version.MasterVersion are dropped. The current version.Latest function is renamed to version.LatestVersion. Change-Id: I649229939223b686dd95a137df4871a899f48aab Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/325390 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-06-07internal: move version constants to internal/versionJulie Qiu
Because the constants for "latest", "master" and "main" were in package internal, we couldn't use them in internal/stdlib due to an import cycle. They are now moved to internal/version to avoid this cycle. Change-Id: I6ebe7c0f50037be2b047c4a25054a0531dcfd3f8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/325389 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-05-05internal: enable symbol history for stdlibJulie Qiu
Symbol history for standard library packages are now always displayed. For golang/go#37102 Change-Id: I323c7735726a22d4caac39bebd2e8d912fd03aad Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/317013 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2021-04-29internal/postgres: read only one doc source from DBJonathan Amsterdam
If GetUnit is passed a build context, it will read documentation source only for that build context. It still reads all the build context values, just only one serialized blob of file ASTs. This sped up getUnitWithAllFields by about 2x on net/http, using detail-stats against the staging DB from a local frontend. Change-Id: Ib8e988940b7f8f8ef2c270129c4338bb3d56b9eb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/312269 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-13internal: remove unit-meta-with-latest experimentJonathan Amsterdam
For golang/go#43265 Change-Id: I1d056a893fdff60744ff328ab9f4a1b6665b3e32 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/309709 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-04-13many: remove "retractions" experimentJonathan Amsterdam
For golang/go#43265 Change-Id: Iac39814ce532adf5846bb768802a46ad7a77fa84 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/309609 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-04-08internal/postgres,etc: finish MustInsertModule cleanupJonathan Amsterdam
Now that there are no callers of MustInsertModule, rename MustInsertModuleLatest to MustInsertModule. We can also remove MustInsertModuleLMV. Change-Id: Ieb554ee32696c168be4cc0a14ecece9f4c6b91b4 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/308271 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-08internal/postgres: continue MustInsertModule cleanupJonathan Amsterdam
Remove calls to MustInsertModuleLMV. It helped to reorganize TestGetLatestUnitVersion to be clearer about the go.mod contents of the various module versions. Change-Id: I7fa41bd742cf8bba2b5274172ad5b79fc22e73a9 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/308270 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-08internal/postgres: remove MustInsertModule from remaining testsJonathan Amsterdam
Change-Id: Ife8d5918c63cfc509696aaa273186752fac0652e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/308269 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-04-07internal/postgres: use MustInsertModuleLatestJonathan Amsterdam
For most internal/postgres tests, update latest-version information when we insert a module. That is more like what actually happens on the worker, and some features now rely on it, so we should do it everywhere. Some tests still use a custom go.mod file, so we can't switch to MustInsertModuleLatest for those, because it uses a minimal go.mod file. Change-Id: Ie5030aee4ed9c837931fddb8757e37bf6373a8c7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/307871 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
2021-03-16internal/worker,etc.: improvements to latest-version infoJonathan Amsterdam
- Fetch and update the latest-version info before processing a module rather than after, so the information in the DB matches what InsertModule is using. - Pass latest-version info to InsertModule so it can use it to decide whether the version being inserted is the latest version. - InsertModule writes the good latest version to the latest_module_versions table while holding the advisory lock, avoiding a race condition where two different versions both think they're the latest. For golang/go#44710 Change-Id: Id5e8fa7a384ec6d4d86257362fd33a8fcd5215f7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/301929 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-03-15internal/postgres: remove special treatment of incompatible versionsJonathan Amsterdam
When finding the latest version of a unit, if there are no unretracted compatible versions and we should ignore incompatible versions, don't treat the situation specially. After the loop we'll pick the latest incompatible version anyway. Change-Id: I9a3a698f9ba18308b04f3e2f851ef76650af2755 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/301509 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-03-10internal/postgres: rewrite GetUnitMeta with latest versionsJonathan Amsterdam
Behind an experiment flag, rewrite GetUnitMeta to use latest-version information when available. For golang/go#44710 Change-Id: Ife3dc13e518c3bd28ce13073b0f255265980f0a3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/300429 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-03-03internal/postgres: use latest versions to populate ModuleInfoJonathan Amsterdam
Replace the use of the raw_latest_versions table with the latest_module_versions table. For golang/go#44710 Change-Id: I69eff3f19d209e45d5a568209087eca9cf13a0f2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/298232 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-02-25internal/postgres: add retraction/deprecation info to GetUnitMetaJonathan Amsterdam
For golang/go#43265 For golang/go#41321 Change-Id: I8dc86d87882b96d3c3ffe7c1d035937f210b9a91 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296229 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-02-25internal: embed ModuleInfo into UnitMetaJonathan Amsterdam
UnitMeta had most of the fields of ModuleInfo, but did not embed it. Now that we have added four more fields to ModuleInfo for deprecation and retraction, it makes sense to embed it rather than duplicate those fields. For golang/go#43265 For golang/go#41321 Change-Id: I20e2b922b49c7873a5535745d644631123de37cd Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296209 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-02-19internal/testing/sample: make a fresh copy of ImportsJonathan Amsterdam
Create a new slice of imports each time it's used. This ensures that memory isn't shared between sample modules. It addresses a race condition we saw when running postgres tests concurrently. Change-Id: I0c1e0112ff7b944433565c7cacdd7226a32ad4eb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294149 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-02-17internal/sample: improve treatment of sample licensesJonathan Amsterdam
To avoid sharing between tests, which can lead to race conditions, create new sample license slices and structs each time we need them. This uncovered some problems in the postgres tests. - The UpsertModule test was changing the top-level module license, but didn't propagate that change through all the units. We sample.ReplaceLicense to address that. - The checkModule was filling in missing license with defaults, instead of the correct data. Change-Id: I6074914155eb33d6ed6882f81a9d57b20135e422 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/292929 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-02-12internal/postgres: parallelize testsJonathan Amsterdam
Run tests in parallel on separate databases. With four DBs, the time to run all the package's tests is cut in about half, from 50s to 25s (the time varies from run to run). Instead of a global variable holding a single DB, we set up a channel populated with DBs. Each test receives from the channel to get a DB to use, and sends it to the channel when done. Because a test may have to wait to get a DB, we can't set an individual timeout for some tests because acquiring the DB can take some time. Individual test timeouts aren't really important, because `go test` will time out the entire run after 10 minutes anyway. The only test that can't be run in parallel is TestSearch, because it reads metrics before and after each sub-test to compute a delta, thereby implicitly assuming that no other Search calls are running in parallel. Change-Id: Icb35dbd2f146e27d82d4eef81343cf9725252155 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/291449 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-11internal/postgres: add MustInsertModule for testingJonathan Amsterdam
Simplifies frequent calls to InsertModule. Change-Id: Iafcf5ec8d71eb9ab541ceecb2d85eb0d9b5119b1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/291269 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-02-09internal/sample: generate sample doc dynamicallyJonathan Amsterdam
Generate all internal.Documentation values for testing during the test run, removing the need for running `go generate`. - Move godoc.DocumentationForTesting to sample.Documentation, now that the import cycle is broken. - Add sample.Doc for tests that don't care about the Documentation contents. - Delete gen_documentation.go, the program that previously generated the documentation, as well as its output, documentation.gen.go. Change-Id: I81116aa133837a80047031c890b00f30cdd2e825 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290372 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-02-08internal: support "all" in BuildContextJonathan Amsterdam
Handle BuildContexts where one or more parts are "all". These should only occur when searching for a matching Documentation, not sorting. (Because we sort only when there is more than one Documentation, and if there is an all/all Documentation then there aren't any others.) For golang/go#37232 Change-Id: I898aba8f73d2682798d56c47cc6773709f10c702 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290094 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-02-03internal/postgres: handle multiple documentations for a packageJonathan Amsterdam
Insert and retrieve documentation for all of a package's build contexts. For golang/go#37232 Change-Id: Ib3c7b32be66502c3f343bddd247de700e390c53d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/288831 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-02-02many: allow for multiple documentations for a UnitJonathan Amsterdam
Change internal.Unit.Documentation from a single internal.Documentation to a slice, so that a Unit can have doc for multiple build contexts. However, don't use this ability yet: fetch takes only the first build context it finds, postgres inserts only the first, frontend renders only the first, etc. For golang/go#37232 Change-Id: I17fd1ff2378e0862c029c8077057c207001f6136 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/288217 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> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2021-01-13internal/licenses: rename Coverage fieldsJonathan Amsterdam
Coverage -> OldCoverage NewCoverage -> Coverage Change-Id: I05b41e1525700b3539dad9894b6b678f6c88c67d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/283653 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-01-11internal/postgres: move code from path_test.go to unit_test.goJulie Qiu
Pure code in motion. Change-Id: Ib2615e00f27a358de2321314c19001f21c11f648 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/282619 Reviewed-by: Jonathan Amsterdam <jba@google.com> Trust: Julie Qiu <julie@golang.org>
2021-01-05internal/postgres: remove get-unit-meta-query experimentJulie Qiu
Change-Id: Iebd900374295793727e3ac8f17c883bfc3847861 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280161 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>
2020-12-28internal/postgres: list non-redistributable packagesJulie Qiu
Currently, non-redistributable packages are not listed in the directories section, since they won't have a row in the documentation section. These are now listed with an empty synopsis. Change-Id: Id787b91cd58c698daf547e9dff8921df5c0f097f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280094 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jamal Carvalho <jamal@golang.org>
2020-12-16internal/postgres: fix GetUnitMeta with experiment flagJulie Qiu
getUnitMetaQuery was missing "m.has_go_mod" in the SELECT, due to a merge conflict. Tests are updated to catch errors with and without the experiment flag for the future. Change-Id: I4c8f5db7fb014bd81ff379e3cd93b65831958fd0 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/278753 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>
2020-12-14internal/frontend: fix commitTime for testsJulie Qiu
CL 268638 added `.In(time.UTC)` to the commitTime for several tests. This was causing tests to fail when run locally, due to different outputs of absoluteTime. absoluteTime for these commit times are now computed within the tests. sample.UnitMeta also now sets the CommitTime to NowTruncated(). Change-Id: I3187c9a5eacd5d136c73080b2803241cb2022729 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/271808 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>
2020-11-25internal: delete ExperimentGetUnitWithOneQueryJulie Qiu
Change-Id: Iae5acfddb846b0a223967d563a7597a5909f8f65 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/272946 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>
2020-11-24internal: add WithMain field setJulie Qiu
The WithDocumentation, WithReadme and WithSubdirectories field set are replaced by WithMain, since the main page always requires all of that information. WithMain also returns NumImports and NumImportedBy. Change-Id: I15d8aa7a1332da78d5dee49b418d7773c87b115b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/271418 Trust: Julie Qiu <julie@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-11-24internal/postgres: delete use of ExperimentUnitPageJulie Qiu
ExperimentUnitPage is no longer used by internal/postgres. Change-Id: I19a9f7953a87e559a4acdb5f4a3712f9b2a79f01 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/272609 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>
2020-11-24many: remove Documentation.HTMLJonathan Amsterdam
HTML is always generated from source, so the Documentation.HTML field is no longer necessary. Change-Id: I13cddbfbd983c8a2ff0cb9389e854887caadcc13 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/272509 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-10-28internal: remove insert-package-source experimentJonathan Amsterdam
It is at 100% in all environments. Change-Id: I4e2b859e9cd81df1ddfa9e677afe8d13d31b400f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265878 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>
2020-10-27internal/testing/sample,etc.: add package sourceJonathan Amsterdam
Add encoded source to the sample Documentation value, and render it to get the documentation HTML. Use the package in internal/godoc/testdata. I had hoped to use the godoc package in an init function to create the needed values, but that caused an import cycle between sample and the godoc test package. So instead, a small program invoked with `go generate` uses godoc to generate the values and embed them in a Go file. This change required a few other changes: internal/postgres: Always insert source when comparing Documentation. internal/frontend: Change the strings we look for in doc to match the one in the sample package. internal/frontend: Remove the check on HTML ids. This was added when I was doing safehtml, when I was being strict about HTML ids. The safehtml package wants ids to conform to some strict rules to avoid certain attacks, and I tried to follow those rules. But in the end I had to be more forgiving, or I would have broken anchor tags to Go symbols, like pkg.go.dev/fmt#Println. (safehtml does not consider "Println" a safe identifier unless it is a constant string.) The checkIDs function was added somewhere in the middle of that process, and it worked until now because the value of sample.DocumentationHTML was an ordinary text string with no ids, not real HTML doc. It was actually only checking the ids for license files, and those do contain a hyphen. I don't think its loss is important. Change-Id: I4019c56b216aaf1a4e92a6167c2af1eef4cfbf89 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265297 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>
2020-10-26internal/{frontend,postgres,testing}: set unit.NumImportsJonathan Amsterdam
Set the NumImports field whenever we set Imports. Fixes b/171487247 Change-Id: I144fc2c36503c204712c694e0ff8a6ea4ece4bfb Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/264860 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2020-10-26internal/testing/sample: rename LegacyModule to ModuleJulie Qiu
For golang/go#39629 Change-Id: I83c2afdf32b58594e9ab00b545ae1bfebbd5491b Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265005 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>
2020-10-21internal/postgres: fetch unit page data with one queryJulie Qiu
Data for the unit page can now be fetched using a single query. Running this query in staging: golang.org/x/net/context: 27.394 ms (26.526 ms on second run) cloud.google.com/go/firestore: 77.537 ms (0.810 ms on second run) go.uber.org/zap: 1515.823 ms (13.242 ms on second run) net/http: 17694.337 ms (232.138 ms on second run) Change-Id: I337379551cd2b842212107ccd51edd961df5fd1e Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/263778 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>