diff options
author | Nikita Kozlovskiy <nikitka@gmail.com> | 2023-06-13 12:10:21 +0000 |
---|---|---|
committer | nkozlovskiy <nmk@ydb.tech> | 2023-06-13 15:10:21 +0300 |
commit | a3ff846aff3c30ea9f5d8d2fb96f731bde92c501 (patch) | |
tree | 64a9700efa52bd0ac486f168c959fb0b4090c941 | |
parent | ee667cd44821a70db31f825b3b921c63166dab30 (diff) | |
download | ydb-a3ff846aff3c30ea9f5d8d2fb96f731bde92c501.tar.gz |
ci: add prepare-vm action, update build documentation
ci: add prepare-vm action, update build documentation
Pull Request resolved: #254
-rw-r--r-- | .github/actions/prepare_vm/action.yaml | 40 | ||||
-rw-r--r-- | .github/workflows/build_and_test_ondemand.yml | 15 | ||||
-rw-r--r-- | .github/workflows/prepare_vm_for_build.yml | 44 | ||||
-rw-r--r-- | BUILD.md | 49 |
4 files changed, 87 insertions, 61 deletions
diff --git a/.github/actions/prepare_vm/action.yaml b/.github/actions/prepare_vm/action.yaml new file mode 100644 index 0000000000..ed0e4579be --- /dev/null +++ b/.github/actions/prepare_vm/action.yaml @@ -0,0 +1,40 @@ +name: Prepare VM for YDB build +description: Install required packages + +runs: + using: "composite" + steps: + - name: get ubuntu version + shell: bash + id: init + run: | + echo "distro_name=$(lsb_release -si)" | tee -a $GITHUB_OUTPUT + echo "distro_release=$(lsb_release -sr)" | tee -a $GITHUB_OUTPUT + - name: Add cmake + shell: bash + if: steps.init.outputs.distro_name == 'Ubuntu' && contains(fromJSON('["18.04", "20.04"]'), steps.init.outputs.distro_release) + run: | + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add - + echo "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null + - name: Add cmake, llvm apt repositories for Ubuntu < 22.04 + shell: bash + if: steps.init.outputs.distro_name == 'Ubuntu' && steps.init.outputs.distro_release == '18.04' + run: | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + echo "deb https://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-12 main" | sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null + - name: Install YDB Build dependencies + shell: bash + run: | + sudo apt-get update + sudo apt-get -y install --no-install-recommends \ + python-is-python3 git cmake python3-pip ninja-build antlr3 m4 \ + clang-12 lld-12 llvm-12 libidn11-dev libaio1 libaio-dev parallel + sudo pip3 install conan==1.59 pytest==7.1.3 pytest-timeout grpcio grpcio-tools PyHamcrest tornado xmltodict pyarrow + - name: install ccache + shell: bash + run: | + export CCACHE_VERSION=4.8.1 + export OS_ARCH=$(uname -m) + curl -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-${OS_ARCH}.tar.xz \ + | tar -xJ -C /usr/local/bin/ --strip-components=1 --no-same-owner ccache-${CCACHE_VERSION}-linux-${OS_ARCH}/ccache + ls -la /usr/local/bin/ccache diff --git a/.github/workflows/build_and_test_ondemand.yml b/.github/workflows/build_and_test_ondemand.yml index 57fe691bb2..081ac77be5 100644 --- a/.github/workflows/build_and_test_ondemand.yml +++ b/.github/workflows/build_and_test_ondemand.yml @@ -67,10 +67,19 @@ jobs: prepare-vm: name: Prepare runner - uses: ./.github/workflows/prepare_vm_for_build.yml needs: provide-runner - with: - runner_label: ${{ needs.provide-runner.outputs.label }} + runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ] + steps: + - name: Checkout PR + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha != '' + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Checkout + uses: actions/checkout@v3 + if: github.event.pull_request.head.sha == '' + - name: Prepare VM + uses: ./.github/actions/prepare_vm main: name: Build and test diff --git a/.github/workflows/prepare_vm_for_build.yml b/.github/workflows/prepare_vm_for_build.yml index 24d8b3e5b7..e69de29bb2 100644 --- a/.github/workflows/prepare_vm_for_build.yml +++ b/.github/workflows/prepare_vm_for_build.yml @@ -1,44 +0,0 @@ -name: Prepare VM for YDB build - -on: - workflow_call: - inputs: - runner_label: - required: true - type: string - secrets: - rc_auth: - required: false - workflow_dispatch: - inputs: - runner_label: - required: true - type: string - -jobs: - prepare: - runs-on: ${{ inputs.runner_label }} # run the job on a particular runner - steps: - - name: Install YDB Build dependencies - shell: bash - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add - - echo "deb http://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null - echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null - sudo apt-get update - sudo apt-get -y install python-is-python3 git cmake python3-pip ninja-build antlr3 m4 clang-12 lld-12 libidn11-dev libaio1 libaio-dev parallel - sudo pip3 install conan==1.59 pytest==7.1.3 pytest-timeout grpcio grpcio-tools PyHamcrest tornado xmltodict pyarrow - - name: Install AllureCtl - if: false - shell: bash - run: | - wget https://github.com/allure-framework/allurectl/releases/latest/download/allurectl_linux_386 -O ~/allurectl - chmod +x ~/allurectl - - name: install ccache - shell: bash - run: | - export CCACHE_VERSION=4.8.1 - curl -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-x86_64.tar.xz \ - | tar -xJ -C /usr/local/bin/ --strip-components=1 --no-same-owner ccache-${CCACHE_VERSION}-linux-x86_64/ccache - ls -la /usr/local/bin/ccache
\ No newline at end of file @@ -1,7 +1,7 @@ # Building YDB from sources ## Build Requirements - We have tested YDB builds using Ubuntu 18.04 and Ubuntu 20.04. Other Linux distributions are likely to work, but additional effort may be needed. Only x86_64 Linux is currently supported. + We have tested YDB builds using Ubuntu 18.04, 20.04 and 22.04. Other Linux distributions are likely to work, but additional effort may be needed. Only x86_64 Linux is currently supported. Below is a list of packages that need to be installed before building YDB. 'How to Build' section contains step by step instructions to obtain these packages. @@ -9,7 +9,6 @@ - clang-12 - lld-12 - git 2.20+ - - python2.7 - python3.8 - pip3 - antlr3 @@ -27,26 +26,42 @@ # How to Build -## Add repositories for dependencies +## (optional) Add CMake and LLVM APT repositories (for Ubuntu 18.04 and 20.04) + +## Ubuntu 18.04 + +For Ubuntu 18.04, you have to add CMake and LLVM APT repositories: -Note: the following repositories are required for **Ubuntu 18.04 and Ubuntu 20.04**. You may skip this step if your GNU/Linux distribution has all required packages in their default repository. -For more information please read your distribution documentation and https://apt.llvm.org as well as https://apt.kitware.com/ ```bash +wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add - +echo "deb http://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - +echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-12 main" | sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null + +sudo apt-get update + +``` + +## Ubuntu 20.04 + +For Ubuntu 20.04, you have to add CMake APT repository: + +```bash wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add - echo "deb http://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null -echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/llvm.list >/dev/null sudo apt-get update + ``` -For Ubuntu 18, use `llvm-toolchain-$(lsb_release -cs)-12` in the command above. ## Install dependencies ```bash -sudo apt-get -y install git cmake python3-pip ninja-build antlr3 m4 clang-12 lld-12 libidn11-dev libaio1 libaio-dev +sudo apt-get -y install git cmake python3-pip ninja-build antlr3 m4 clang-12 lld-12 libidn11-dev libaio1 libaio-dev llvm-12 sudo pip3 install conan==1.59 + ``` ## Create the work directory. @@ -55,6 +70,7 @@ sudo pip3 install conan==1.59 ```bash mkdir ~/ydbwork && cd ~/ydbwork mkdir build + ``` ## Clone the ydb repository. @@ -74,10 +90,11 @@ Run cmake to generate build configuration: ```bash cd build cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain ../ydb + ``` -### (optionally) Configure with Ccache +### (optional) Configure with Ccache With enabled Ccache, you can finish the compilation of all targets on supported Linux distributions in a few minutes. Or just `ydbd` or `ydb` binary in a couple of seconds. To optionally enable `Ccache` and enhance the compilation speed, follow these steps: @@ -86,27 +103,30 @@ With enabled Ccache, you can finish the compilation of all targets on supported ```bash (V=4.8.1; curl -L https://github.com/ccache/ccache/releases/download/v${V}/ccache-${V}-linux-x86_64.tar.xz | \ sudo tar -xJ -C /usr/local/bin/ --strip-components=1 --no-same-owner ccache-${V}-linux-x86_64/ccache) + ``` 2. Configure `Ccache` to use remote storage using environment variables ```bash - export CCACHE_REMOTE_STORAGE="http://158.160.20.102:8080|layout=bazel" + export CCACHE_REMOTE_STORAGE="http://158.160.20.102:8080|read-only|layout=bazel" export CCACHE_SLOPPINESS=locale export CCACHE_BASEDIR=~/ydbwork/ + ``` <details> <summary>or using Ccache config file</summary> ```bash - ccache -o remote_storage="http://158.160.20.102:8080|layout=bazel" + ccache -o remote_storage="http://158.160.20.102:8080|read-only|layout=bazel" ccache -o sloppiness=locale ccache -o basedir=~/ydbwork/ + ``` </details> 3. Also, you should change Conan's home folder to the build folder for better cache hit - ```bash - export CONAN_USER_HOME=~/ydbwork/build - ``` + ```bash + export CONAN_USER_HOME=~/ydbwork/build + ``` 4. Genreate build configuration using `ccache` ```bash @@ -115,6 +135,7 @@ With enabled Ccache, you can finish the compilation of all targets on supported -DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache \ -DCMAKE_TOOLCHAIN_FILE=../ydb/clang.toolchain \ ../ydb + ``` ## Build |