Skip to content

sg: add a sg check command to run existing checks

Administrator requested to merge devx/sg-check into main

Created by: jhchabran

Adds a new command to sg, sg check [topic] which will concurrently run every scripts currently run on the CI by the checks step. This is the first step to remove bash scripts as it opens the way to write those in Go which is much more reliable (but not exclusively). This is also the first step toward providing better annotations on failed builds.

It merges seamlessly with the existing check scripts through a helper that wraps them for the time being.

The subcommands are organized by usage, focusing on what kind of activity the user is currently doing. This opens up the path to selectively run those checks on the CI, depending on the changes in the PR being built.

Presently, it does not run frontend linters as this set of changes does not modify in any way the CI steps, which are to be shipped in an ulterior PR.

$ sg check --help
USAGE
  sg check [go|client|shell|docsite|docker|urls]

Run all checks on the codebase and display failures, if any.
Run sg check --help for a list of all checks.


SUBCOMMANDS
  urls     Check for broken urls in the codebase.
  go       Check go code for linting errors, forbidden imports, generated files...
  docsite  Check the code powering docs.sourcegraph.com for broken links and linting errors.
  docker   Check for forbidden docker base images
  client   Check client code for linting errors, forbidden imports, ...
  shell    Check shell code for linting errors, formatting, ...
$ sg check shell
✅ Shell formatting (0s)
❌ Shell lint (1s)
--- shellcheck
^^^ +++

In dev/ci/test/code-intel/test-against-server.sh line 22:
source /root/.profile
       ^------------^ SC1091: Not following: /root/.profile: openBinaryFile: does not exist (No such file or directory)

For more information:
  https://www.shellcheck.net/wiki/SC1091 -- Not following: /root/.profile: op...
^^^ +++

error: failed checks: 'bash -c dev/check/shellcheck.sh' failed: --- shellcheck
^^^ +++
In dev/ci/test/code-intel/test-against-server.sh line 22:
source /root/.profile
       ^------------^ SC1091: Not following: /root/.profile: openBinaryFile: does not exist (No such file or directory)
For more information:
  https://www.shellcheck.net/wiki/SC1091 -- Not following: /root/.profile: op...
^^^ +++: exit status 1
exit status 1

Merge request reports

Loading