Build and test YDB using Ya Make

Ya Make is a build and test system used historically for YDB development. Initially designed for C++, now it supports number of programming languages including Java, Go, and Python.

Ya Make build configuration language is a primary one for YDB, with a ya.make file in each directory representing Ya Make targets.

Setup the development environment as described in Working on a change - Setup environment arcticle to work with Ya Make.

Running Ya commands

There's a ya script in the YDB repository root to run Ya Make commands from the console. You can add it to the PATH evniromnet variable to enable launching without specifiying a full path. For Linux/Bash and GitHub repo cloned to ~/ydbwork/ydb you can use the following command:

echo "alias ya='~/ydbwork/ydb/ya'" >> ~/.bashrc
source ~/.bashrc

Run ya without parameters to get help:

$ ya
Yet another build tool.

Usage: ya [--precise] [--profile] [--error-file ERROR_FILE] [--keep-tmp] [--no-logs] [--no-report] [--no-tmp-dir] [--print-path] [--version] [-v] [--diag] [--help] <SUBCOMMAND> [OPTION]...

Options:
...

Available subcommands:
...

You can get detailed help on any subcommand launching it with a --help flag, for instance:

$ ya make --help
Build and run tests
To see more help use -hh/-hhh

Usage:
  ya make [OPTION]... [TARGET]...

Examples:
  ya make -r               Build current directory in release mode
  ya make -t -j16 library  Build and test library with 16 threads
  ya make --checkout -j0   Checkout absent directories without build

Options:
...

The ya script downloads required platform-specific artifacts when started, and caches them locally. Periodically, the script is updated with the links to the new versions of the artifacts.

Setup IDE

If you're using IDE for development, there's a command ya ide which helps you create a project with configured tools. The following IDEs are supported: goland, idea, pycharm, venv, vscode (multilanguage, clangd, go, py).

Go to the directory in the source code which you need to be a root of your project. Run the ya ide command specifying the IDE name, and the target directory to write the IDE project configuration in a -P parameter. For instance, to work on the YQL library changes in vscode you can run the following command:

cd ~/ydbwork/ydb/library/yql
ya ide vscode -P=~/ydbwork/vscode/yqllib

Now you can open the ~/ydbwork/vscode/yqllib/ide.code-workspace from vscode.

Build a target

There are 3 basic types of targets in Ya Make: Program, Test, and Library. To build a target run ya make with the directory name. For instance, to build a YDB CLI run:

cd ~/ydbwork/ydb
ya make ydb/apps/ydb

You can also run ya make from inside a target directory without parameters:

cd ~/ydbwork/ydb/ydb/apps/ydb
ya make

Run tests

Running a ya test command in some directory will build all test binaries located inside its subdirectories, and start tests.

For instance, to run YDB Core small tests run:

cd ~/ydbwork/ydb
ya test ydb/core

To run medium and large tests, add options -tt and -ttt to the ya test call, respectively.