Граф коммитов

45 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Amsterdam 3aae7e77f9 all.bash: run go vet -all
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>
2020-07-09 21:18:25 +00:00
Rob Findley ea15bff89b devtools: add a script for running pure docker CI
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>
2020-07-09 12:11:21 +00:00
Jonathan Amsterdam 1705eb3beb devtools/cmd/csphash: check script hashes for CSP
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>
2020-06-30 15:51:38 +00:00
Jonathan Amsterdam b7f0b200a9 all.bash: link to prettier install page
Change-Id: I73efcea136731bcb80a08cdc3702ba62e65b138f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/237977
Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-29 21:25:41 +00:00
Jonathan Amsterdam ccd36309fc all.bash,internal: force DB testing in CI
If the environment variable GO_DISCOVERY_TESTDB is "true" wherever we
would skip DB tests, fail instead.

Set it to "true" in all.bash.

Fixes golang/go#39713.

Change-Id: I80fe27578a05610e29cc3ad9f6d477c9768fd51a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/239257
Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-22 14:34:26 +00:00
Daniel Martí 7f8957e3c7 fix two typos in root files
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>
2020-06-16 16:36:00 +00:00
Julie Qiu 986e858ed8 all.bash: run prettier by default
Prettier now runs when./all.bash is executed.

Change-Id: I7fe105d683e93a9a6b2774117289ced951824ea5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/756681
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-15 14:57:44 +00:00
Julie Qiu 23f4a4a759 all: run prettier on markdown files
./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>
2020-05-29 14:48:09 +00:00
Julie Qiu 947bb6d235 devtools: renamed from scripts
Change-Id: I1bf0f8a3297b2a83bb6515db25cb04e1b67220d0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752611
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-21 19:10:19 +00:00
Julie Qiu ae04dfa4db all.bash: use unparam
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>
2020-04-16 18:20:53 +00:00
Julie Qiu d55ca17b72 all.bash: add mvdan.cc/unparam
Change-Id: Ie0090704380ffb3d7de0387c7d468d2922d82ee6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/701078
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00
Andrew Bonventre daab3b7569 content/static: rename thirdparty directory to third_party
Updates b/150138132

Change-Id: Id8cd371dbcace53d81cae1b40ba2f8af2d08769c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/692262
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-04-06 17:09:52 -04:00
Jonathan Amsterdam 253be6be2b internal/secrets: use environment variables
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>
2020-04-06 17:09:52 -04:00
Julie Qiu 56be005a3a all: modify all.bash to use scripts/lib.sh
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>
2020-04-06 15:50:53 -04:00
Julie Qiu b0f1a8f66c all.bash: remove check_js_compiled
Updates b/151162757

Change-Id: I9ee627f63e5152184d028971edf1ce1448f08a57
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/687552
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 15:50:53 -04:00
Rob Findley 46aa9d8dcc all.bash: update verify_header check
Change-Id: If5076bf53e23d1f8b8b0613676f6d0b902cece42
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/684250
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 15:50:52 -04:00
Jonathan Amsterdam 4a397dce96 content/static/js: minimize and concatenate javascript
Change-Id: I34b94fccbade72f57c2bc33d7e5388cf114b873e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/664687
Reviewed-by: Alexander Rakoczy <rakoczy@google.com>
2020-04-06 15:50:51 -04:00
Rob Findley 56d6d980f0 internal: fix staticcheck errors
Also fix the broken 'lint' subcommand in all.bash.

Change-Id: Ic91876f1e03e38be2c3369b14fd428f47f397ea9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/658564
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:52 -04:00
Rob Findley 029b4419ae all.bash: clean up some unnecessary indirection
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>
2020-03-27 16:46:51 -04:00
Jonathan Amsterdam b0e18b0785 content/static: add dialog polyfill
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>
2020-03-27 16:46:46 -04:00
Julie Qiu dfdbae3d2d all.bash: update misspell check)
Change-Id: I99c5654e253cc81b57ea2cddbaebbadf2d561a3a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/580781
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:45 -04:00
Rob Findley 6ef1800bd5 all.bash: don't use -count=1 by default
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>
2020-03-27 16:46:45 -04:00
Jonathan Amsterdam eec45b0374 all.bash: test with -race in CI mode
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>
2020-03-27 16:46:43 -04:00
Rob Findley dada16267b all.bash: fix inconsistency
Change-Id: I83b711ff13f8c3bfa5d6ada8bfda25118e01c3c2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/550935
Reviewed-by: Jonathan Amsterdam <jba@google.com>
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-03-27 16:46:43 -04:00
Jonathan Amsterdam 8f3e11f3f4 all.bash: factor out functions
Change-Id: Ibc54f17163145bb6d3a268f5ccdfc539a8510d9e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/543857
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:43 -04:00
Rob Findley 5657b81f03 all.bash: run go get in $HOME when installing tools
Fixes b/140443579

Change-Id: I681f41912cb43fb8f0cd4ff6113cf21c836c789b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/541503
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:42 -04:00
Jonathan Amsterdam c15d04b786 all.bash: run tests on Cloud Build
Change-Id: I12db5df7202bc21ad39dd2855b060bb6589f8932
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/535477
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:42 -04:00
Jonathan Amsterdam 38987470bf all.bash: check that it's run from repo root
Obscure errors happen if it isn't.

Change-Id: Id41890c24facf33b68d7bca8a4d6d44f2efd0d25
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/526012
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:41 -04:00
Rob Findley b3bb932540 all.bash: truncate 'Running' logs to 80 chars
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>
2020-03-27 16:46:41 -04:00
Jonathan Amsterdam 8a2487598a all.bash: exit 1 on failure
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>
2020-03-27 16:46:41 -04:00
Rob Findley 144701ca0b all.bash: add new linters and fix lint errors
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>
2020-03-27 16:46:40 -04:00
Dmitri Shuralyov 4063ee0777 internal/etl/dochtml: add start of feature-complete documentation rendering
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>
2020-03-27 16:46:40 -04:00
Rob Findley 17386b461f all.bash: add a check for abnormal migrations files
This catches the case where a rebase resulted in overlapping sequence
numbers.

Change-Id: I07e0a3729fabbbef895fae079ff70e8862201cd2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/460456
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:37 -04:00
Dmitri Shuralyov 9374a2399f all.bash: skip running staticcheck on thirdparty packages
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>
2020-03-27 16:46:36 -04:00
Rob Findley 4d9c2f76a4 internal: make presubmit errors louder and fix missing headers
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>
2020-03-27 16:46:36 -04:00
Rob Findley 53e2ab19f1 all.bash: remove stale comment about test parallelism
Change-Id: I583da888e37d4483faa6d4b463b0bceac6374166
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456458
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-03-27 16:46:36 -04:00
Rob Findley 8f70f0b541 internal/postgres: isolate DB tests to separate databases
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>
2020-03-27 16:46:36 -04:00
Andrew Bonventre 569181649f internal/secrets: add package for storing and retrieving secrets
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>
2020-03-27 16:46:36 -04:00
Julie Qiu fcc513bf9d internal/fetch: use github.com/google/licensecheck for license detection
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>
2020-03-27 16:46:35 -04:00
Rob Findley 83c075957a frontend: refactor template parsing and fix active nav tab
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>
2020-03-27 16:46:34 -04:00
Julie Qiu 995f0d2aea discovery: add misspell to all.bash
Change-Id: I4e68a66553182908b1108cfd9139c65b04c09bfb
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/445469
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:34 -04:00
Rob Findley f96a8cb1bd internal/postgres: fix two sources of test flakes
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>
2020-03-27 16:46:34 -04:00
Julie Qiu 7010dcd7f2 discovery: update all.bash to finish even if no files are staged
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>
2020-03-27 16:46:34 -04:00
Julie Qiu 9990d4f355 discovery: add additional logs to all.bash; update license header check
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>
2020-03-27 16:46:34 -04:00
Julie Qiu a5422cb6dc discovery: create all.bash
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>
2020-03-27 16:46:34 -04:00