Note that you do need a full installation of XCode to build on macOS. (No, a command-line tools instance does not suffice.) If you’ve already installed a command-line tools instance as part of setting up Homebrew or other tools, switch to the full XCode instance and accept the XCode license agreement with:
./dev build short also works as an aliasand will stage the binary at
./cockroach. Bazel will pretty-print build output to the terminal.
./dev build (or equivalently,
./dev build cockroach) is a synonym for thiswill do the same and will stage the binary at
./cockroach like above.
dev build is a light wrapper for
bazel build that supports aliases for common targets (for example,
./dev build crlfmt instead of the harder-to-remember
bazel build @com_github_cockroachdb_crlfmt//:crlfmt).
dev also copies binaries out of the Bazel output directories for you into your workspace; for example,
bazel build pkg/cmd/cockroach-short puts the binary in
_bazel/bin/pkg/cmd/cockroach-short/cockroach-short_/cockroach-short, but if you
dev build short the binary will be staged at
dev testhas a
--stressflag for running tests under
--racefor running tests with the race detector enabled.
Next to the
test.logfile produced by your test, you can find a
test.xmlfile. This file contains specific information on each test run and its status, as well as timing information.
dev testwill result in more verbose logging as well as more detailed information written to the
test.xml. You can make this the default behavior on your machine by adding
test --test_env=GO_TEST_WRAP_TESTV=1to your
dev testallows you to pass additional arguments directly to Bazel by putting them after
--: for example,
dev test pkg/sql/types -- --verbose_failures --sandbox_debug.
To get test results printed as tests are being run add
-v -- --test_output streamedto the test command. Note that this reduces test parallelism.For more tips on debugging test failures, see “How to
To attach a debugger to a hung
dev testprocess tack
-- -c dbgto the end of your command and it will disable stripping which breaks dlv (https://github.com/bazelbuild/intellij/issues/2313).
For more tips on debugging test failures, see “How to ensure your tests can run in the Bazel sandbox”
Update local sources in
dev script uses Bazel to build
pkg/cmd/dev before running unless another
dev binary with the same increasing integer ID has already been built. Generally
dev will invoke the
dev binary “as of” that commit, which should usually be the correct behavior. However, if the default behavior does not work for some reason, you can find all the built versions of
A (hopefully) fast and error proof
TODO(a UI developer): fill in gaps for UI dev workflow
11. Switch to a new branch
2. If your workflow involves an IDE, generate your protos
./dev gen protobuf
Your IDE relies on generated files for many tasks (e.g. code navigation, IntelliSense, debugging), and will complain unless you have re-generated those files.
If you need to re-generate all generated go files, use the slower
./dev gen go
If the above fails, run the slowest
./dev gento update all of your generated files.
You may recall that with
make, this step was not necessary. If you’re curious why, see this slack thread.
If you’re curious why, see this slack thread.
3. If your workflow involves UI development, you’ll want additionally do the following:
./dev gen protobuf ./dev generate js # start a cockroach node, e.g. ./dev build && ./cockroach start-single-node # in separate window, start UI watch for incremental UI builds ./dev ui watch # now you're ready to write UI code!
4. Write some code!
If you add new files or imports, run
./dev gen bazelbefore compiling or running a test.
compilepkg: missing strict dependencies:is usually the indicator that
./dev gen bazelneeds to be re-run.
to skip this step, see tip below on
Build the binary:
./dev build short
45. Run a test
On an IDE: your normal workflow should work if your generated files are up to date (See step 2).
From the command line:
./dev test [path/to/pkg] --filter [test_name]
56. Before opening/updating a PR: