Add `go vet -all` to our standard checks.
It checks some things that staticcheck doesn't. Notably, closing over
loop variables.
Currently none of the checks are false positives, so might as well run
them all (it takes about 2s). If we later find one we disagree with,
we can disable it.
Change-Id: Ie11b5d8fd7250f8b55b474a662fe78f139f23a6e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241797
Reviewed-by: Julie Qiu <julie@golang.org>
For simplicity, add a new script that runs all.bash CI using Docker
only. This will facilitate hooking into Kokoro (a Google internal CI
runner).
Change-Id: I2faa6190e6ecc35a2b2dc9151f173dc07f80d9b5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241603
Reviewed-by: Julie Qiu <julie@golang.org>
Add a tool that checks the script hashes used
for our Content Security Policy (CSP).
Run the tool from all.bash.
(Also, prettier decided to change CONTRIBUTING.md.)
Fixes b/159711607.
Change-Id: I4498a19143c53fb90bcf0560ccaf529f4fb72a81
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240138
Reviewed-by: Julie Qiu <julie@golang.org>
If the environment variable GO_DISCOVERY_TESTDB is "true" wherever we
would skip DB tests, fail instead.
Set it to "true" in all.bash.
Fixesgolang/go#39713.
Change-Id: I80fe27578a05610e29cc3ad9f6d477c9768fd51a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/239257
Reviewed-by: Julie Qiu <julie@golang.org>
Found while reading those introductory files. They weren't caught by
misspell, for some reason.
Change-Id: Ia90db9e6d131683a3813eaa98bd70cb50db0279d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/238044
Reviewed-by: Julie Qiu <julie@golang.org>
./all.bash prettier now runs on files with a .md file extension. Several
existing .md files are formatted.
Change-Id: Id083a932cdd5db105ae7494b71bcad340b080132
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/756682
Reviewed-by: Andrew Bonventre <andybons@google.com>
unparam wasn't being used previously - it now runs when running
all.bash.
Change-Id: I71ee838b817ce1eb32c0fb60b34c5ef4c7cd4d25
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/718554
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Get the bucket and key names from environment variables to avoid hard-coding them.
Use the same environment variables for the test. To run the test locally,
just set those environment variables locally.
Change-Id: Ic6433470a2db7f173e8be9d60f29ccf9c7845024
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/686712
Reviewed-by: Julie Qiu <julieqiu@google.com>
Terminal colors for log levels and the runcmd helper function is
added to scripts/lib.sh. all.bash now these functions.
Updates b/151162757
Change-Id: Ic0ce1c89214bfa8704571647ead784d2b7ee37fb
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/687549
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
In retrospect, some things in all.bash are unnecessarily indirect, and
seem silly now. In particular:
+ One line commands invoke one line commands
+ Having special commands for 'test' or 'tidy', when you'd really just
run them directly.
+ Having an 'all' grouping of checks. I don't think anyone uses this.
Change-Id: I7feddb0bfb06695be73332abde5181e9fa9705f3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/638039
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Support the jump-to-identifier dialog on Safari by adding
Chrome's dialog polyfill (drop-in replacement) for the <dialog>
element.
- I started a thirdparty directory under content/static
and copied the css and js for the polyfill there, along with
its license.
- This CL always loads the css and js for the polyfill, regardless
of browser. This could be fixed with clever javascript if
necessary.
Fixes b/143456593.
Change-Id: Iffb35d44f90755df1a989550c388b4f0e03200ce
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/586896
Reviewed-by: Alexander Rakoczy <rakoczy@google.com>
Tests are still fast enough not to warrant engineering effort on
speeding them up... but it can be annoying to have a 20-30s delay before
entering a commit message. I find myself more and more frequently
running `git commit --amend -n` to skip the hook.
So let's just allow for cached test results. It might miss some
flakiness, but that should be captured by the CI.
Change-Id: I4cd2c25849997499237fabfc9328ae5a7420911d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/575058
Reviewed-by: Julie Qiu <julieqiu@google.com>
Our CI can take its time, so run it with the race detector enabled.
Required increasing a test timeout because the race detector slows
things down.
Change-Id: Ifd8b6bf585c642d5e96fb889787cdc13ebb46df4
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/556098
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Sometimes I work on narrow terminals, this is just a convenience to
avoid line-wraps.
Change-Id: Ia1be82dc80744da5fc3e47e22ab7fcd29dafbeda
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/524988
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Have err remember that it was called, and exit with 1 if
anything called err.
Also, make everything go through runcmd.
Fixes b/139185529.
Change-Id: I03b673df070ea9a1cae3e458f820c566439478de
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/524055
Reviewed-by: Robert Findley <rfindley@google.com>
all.bash is refactored for readability and to allow for selectively
running actions. This also allows for actions that are not always
executed when running ./all.bash, due to their noisiness or
dependencies.
Two new actions are added that fall into the latter category:
+ go-template-lint, which doesn't quite work due to a failure to detect
our helper templates, but which can still be helpful.
+ prettier, which has a dependency on nodejs and might not be installed
on all our workstations (and is only needed when modifying js/css).
Fixes b/137543085
Change-Id: Ie5931db4d0bd167f238b650beb0b01bb41f10482
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/510437
Reviewed-by: Julie Qiu <julieqiu@google.com>
This change makes use of the two new packages added in previous CLs
to implement the starting point of a more feature-complete, secure,
testable and modern Go package documentation rendering approach.
It's based on previous work by Joe Tsai in CL 94855 and CL 72890
(golang.org/cl/94855 and golang.org/cl/72890).
The largest visible changes are that the index is now populated,
and all examples are also displayed.
It includes additional improvements to match feature parity with
documentation rendering in x/tools/cmd/godoc and github.com/golang/gddo,
such as linking identifiers within code blocks to their documentation,
highlighting comments in green, trimming excessively long entries,
placing parmalink anchors for struct fields such that documentation
remains visible on screen, and many more small and subtle things.
This change serves as a starting point and a foundation for the rest
of the iterative work on documentation rendering, eventually leading
to the documentation rendering code being factored out and shared
between more projects that need this functionality.
Modify fetch code to start processing _test.go files and propagating
them to doc.New. This is needed to extract and display examples.
Add a missing space to page title for packages that aren't commands.
There is some minimal JavaScript to allow expanding and collapsing
examples that will be added in a following CL. Until then, examples
cannot be expanded.
Updates b/137567588
Fixes b/131827600
Fixes b/135952865
Change-Id: Ie2540b6c7b9847e08852967cacb58ff915fff8f9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/504150
Reviewed-by: Julie Qiu <julieqiu@google.com>
The output is not actionable because thirdparty packages are copied
from an external source, and we can't modify them directly in this
project.
Remove trailing slash from a relative import path "./internal/secrets".
It's more common to not include a trailing slash when specifying import
paths.
Fixes b/131821500
Change-Id: Id7458b1474a4218422035cb15e305e2b2a356b64
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457840
Reviewed-by: Robert Findley <rfindley@google.com>
Clearly I've missed a couple warnings from our presubmit, so I'm making
it louder:
+ Use terminal colors to call out errors and warnings.
+ Always run header check on all (known) internal files, so that it
doesn't go silent after a bad commit is merged.
Change-Id: I88116e1dcb0ed6c15b8c1369cbb37de00bd57efd
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/457641
Reviewed-by: Julie Qiu <julieqiu@google.com>
This change modifies the postgres test_helper API to make it easier to
use separate databases for each test suite. It also automates the test
database migration, to ensure that tests are run on an up-to-date
database schema.
Updates b/130719094
Change-Id: Iec0c2404b5859f9bb3c403bdec2581b4636f61a6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/454237
Reviewed-by: Julie Qiu <julieqiu@google.com>
This allows callers to store and retrieve secrets stored in GCS and
encrypted using KMS. A simple API is exposed (Get and Set) and the
mechanisms used for storage and encryption are transparent to the
caller.
Initial support is added for the frontend binary. Some various
cleanup is also performed in that file.
Updates b/129370804
Change-Id: I8ebe08a8bf6c246b2b39a0a8d177147c32034758
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/454236
Reviewed-by: Robert Findley <rfindley@google.com>
sos.googlesource.com/sos/license has been open sourced and now lives at
github.com/google/licensecheck. Use the open source license checker
instead of our private copy.
Fixes b/124309210
Change-Id: I3ac5d6c436dccca4d930d22df0d1162d89a0750f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/451329
Reviewed-by: Robert Findley <rfindley@google.com>
This CL implements a pattern similar to that used in
github.com/golang/gddo to implement an active tab selector for the nav.
Along the way, refactor a bit so that the frontend package is fully
responsible for templates.
Also replace the pattern of Make*HandlerFunc with handler methods.
Also fix a minor typo in all.bash that was causing misspell not to be
installed.
Updates b/124309095
Change-Id: I802ba69b91b81be13c6314140326fe8783608a0c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/445973
Reviewed-by: Julie Qiu <julieqiu@google.com>
This CL addresses two causes of flaky tests:
+ Non-deterministic sorting in search results, due to results of the
same rank.
+ Transactional issues due to multiple non-hermetic package tests
running in parallel.
Fixes b/129855505
Fixes b/129963750
Fixes b/129696857
Change-Id: Ic69cb1f6393325f4c3955d721a4dbdcf73d8258d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/444670
Reviewed-by: Julie Qiu <julieqiu@google.com>
all.bash is updated so that it does not exit at the check for missing
license headers if no files are staged.
The cmd `go get -u honnef.co/go/tools/cmd/staticcheck` is also now only
run if the cmd staticcheck is not executable.
Change-Id: Id973970ba5e7b93820c9b074947e6f1b09f2c918
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/437554
Reviewed-by: Channing Kimble-Brown <ckimblebrown@google.com>
Print statements are added to all.bash to provide additional context for
the user.
The logic for checking missing license headers is updated because it was not
working properly for some files.
Change-Id: I94755e563dd188061270569b625cb7815ec07ae4
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/437335
Reviewed-by: Channing Kimble-Brown <ckimblebrown@google.com>
An all.bash file is created, which:
- clones sso://sos/sos if it does not exist
- updates and runs staticcheck
- runs go mod tidy
- runs all tests
- checks all .go and .sql files for a license header
Change-Id: Icdc85a7befe9f524fce69e4484c9978995de3e3a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/436924
Reviewed-by: Andrew Bonventre <andybons@google.com>