Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
name: Build

on:
push:
branches: ["ow-fork-*"]
tags: ["*-*ow"]

jobs:
calc_ver:
# calculate versions from git tags
runs-on: ubuntu-latest
outputs:
project_ver: ${{steps.vers.outputs.project_ver}}
build_ver: ${{steps.vers.outputs.build_ver}}
full_ver: ${{steps.vers.outputs.full_ver}}
release_flag: ${{steps.vers.outputs.release_flag}}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Calculate versions
id: vers
shell: bash
run: ${{github.workspace}}/build-scripts/for-github/calc-version-from-git.bash

build:
needs: [calc_ver]
env:
# There are not enough free 19 Gb mounted in "/" to build and create rpm and deb packages.
# So, we use /mnt/bld which is mounted to a bigger space. In /mnt there is 66 Gb free space in github action server.
BLD_DIR: /mnt/bld


strategy:
matrix:
include:
- run_on: ubuntu-latest
for: linux
prepare: "debian-based"
build_on: linux
parallel: 5
image: foundationdb-build:8.0.0-0.ow.build
owner: ${GITHUB_REPOSITORY_OWNER@L}
runs-on: ${{ matrix.run_on }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set building repo
run: |
echo "use_image=ghcr.io/${{matrix.owner}}/${{matrix.image}}" >> "$GITHUB_ENV"

- name: Build
run: |
sudo mkdir -p ${{ env.BLD_DIR }}
sudo chmod 777 ${{ env.BLD_DIR }}

echo "=== Disk space before build ==="
df -h

podman run --rm \
--name build \
--mount=type=tmpfs,dst=/tmp \
--mount=type=tmpfs,dst=/var/tmp \
--security-opt label=disable \
--mount=type=bind,src=${{github.workspace}},dst=/home/runner/src,readonly \
--mount=type=bind,src=${{ env.BLD_DIR }},dst=/home/runner/bld \
$use_image \
/home/runner/src/build-scripts/for-${{ matrix.for }}/build-on-${{ matrix.build_on }}.bash \
${{needs.calc_ver.outputs.project_ver}} \
${{needs.calc_ver.outputs.build_ver}} \
${{needs.calc_ver.outputs.release_flag}} \
${{ matrix.parallel }}

echo "=== Disk space after building and creating packages ==="
df -h

# - name: Minimal tests
# working-directory: ${{ env.BLD_DIR }}
# shell: bash
# run: ctest --output-on-failure -V

- name: Upload result
uses: nanoufo/action-upload-artifacts-and-release-assets@v2
with:
path: |
${{ env.BLD_DIR }}/linux/packages/*${{needs.calc_ver.outputs.full_ver}}*
if-no-files-found: error

tests:
needs: [calc_ver, build]
uses: ./.github/workflows/run-tests.yml
with:
full_ver: ${{needs.calc_ver.outputs.full_ver}}
build_run_id: ${{ github.run_id }}
secrets: inherit
95 changes: 95 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Run Tests (reusable)

on:
workflow_call:
inputs:
full_ver:
description: 'Version of the build to test (e.g. 7.4.0-3.1.ow)'
required: true
type: string
build_run_id:
description: 'Run ID to download the correctness package from'
required: true
type: string

jobs:
tests:
runs-on: ubuntu-latest
env:
JOSHUA_DB_VER: "7.1.57"
N_OF_TESTS: 500 # to fit in 360 minutes job run limit
JOSHUA_AGENT_TAG: "rockylinux9.6-20260309"
# parameter that controls the maximum lifetime of the Joshua agent (in seconds).
AGENT_TIMEOUT: 18000

steps:
- name: Set agent URL
run: |
echo "JOSHUA_AGENT_URL=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV
echo "Agent URL: ghcr.io/${GITHUB_REPOSITORY_OWNER,,}"

- name: Checkout
uses: actions/checkout@v4
with:
path: ${{github.workspace}}/src

- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y sudo wget crudini git python3 python3-pip
sudo pip3 install wheel setuptools python-dateutil lxml boto3

- name: Install FoundationDb
shell: bash
run: |
mkdir deb
pushd deb
MY_ARCH=`dpkg-architecture -q DEB_BUILD_ARCH`
wget https://github.com/apple/foundationdb/releases/download/${{ env.JOSHUA_DB_VER }}/foundationdb-clients_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb https://github.com/apple/foundationdb/releases/download/${{ env.JOSHUA_DB_VER }}/foundationdb-server_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb
sudo apt-get install -y ./foundationdb-clients_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb ./foundationdb-server_${{ env.JOSHUA_DB_VER }}-1_${MY_ARCH}.deb
popd
sudo systemctl stop foundationdb
MY_IP=`hostname -I | awk '{print $1}'`
sudo sed -i s/127.0.0.1/$MY_IP/ /etc/foundationdb/fdb.cluster
sudo crudini --set /etc/foundationdb/foundationdb.conf fdbserver memory 4GiB
sudo systemctl start foundationdb
pip3 install 'foundationdb==${{ env.JOSHUA_DB_VER }}'

- name: Download the correctness package
uses: actions/download-artifact@v4
id: download_correctness
with:
name: correctness-${{ inputs.full_ver }}.tar.gz
run-id: ${{ inputs.build_run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Echo download path
run: echo ${{steps.download_correctness.outputs.download-path}}

- name: Display structure of downloaded files
run: ls -R
working-directory: ${{github.workspace}}

- name: Download joshua
shell: bash
run: |
git clone https://github.com/FoundationDB/fdb-joshua.git

- name: run joshua-agent
shell: bash
run: |
podman pull ${{ env.JOSHUA_AGENT_URL }}/joshua-agent:${{ env.JOSHUA_AGENT_TAG }}
for i in 1 2 3 4; do
podman run -d \
-v /etc/foundationdb:/etc/foundationdb \
-e AGENT_TIMEOUT=${{ env.AGENT_TIMEOUT }} \
joshua-agent:${{ env.JOSHUA_AGENT_TAG }}
done

- name: run tests
shell: bash
working-directory: ${{github.workspace}}/fdb-joshua
run: |
podman ps
${{github.workspace}}/src/build-scripts/for-linux/test-joshua.bash ${{github.workspace}}/correctness-${{ inputs.full_ver }}.tar.gz ${{env.N_OF_TESTS}}
19 changes: 19 additions & 0 deletions .github/workflows/tests-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Tests only

on:
workflow_dispatch:
inputs:
full_ver:
description: 'Version of the build to test (e.g. 7.4.0-3.1.ow)'
required: true
build_run_id:
description: 'Run ID of the build workflow (find it in the URL of the build run)'
required: true

jobs:
tests:
uses: ./.github/workflows/run-tests.yml
with:
full_ver: ${{ github.event.inputs.full_ver }}
build_run_id: ${{ github.event.inputs.build_run_id }}
secrets: inherit
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,26 @@ message(STATUS "Current git version ${CURRENT_GIT_VERSION}")
###############################################################################
# Version information
###############################################################################
if(DEFINED VERSION AND NOT VERSION STREQUAL CMAKE_PROJECT_VERSION)
message(FATAL_ERROR "The version parameter ${VERSION} differs from the project version ${CMAKE_PROJECT_VERSION}")
endif()
if(FDB_RELEASE_CANDIDATE)
set(FDB_RELEASE_CANDIDATE_VERSION
1
CACHE STRING "release candidate version")
set(FDB_VERSION ${PROJECT_VERSION}-rc${FDB_RELEASE_CANDIDATE_VERSION})
else()
set(FDB_VERSION ${PROJECT_VERSION})
if(NOT DEFINED BUILD_VERSION)
if(NOT FDB_RELEASE)
if(CURRENT_GIT_VERSION)
set(git_string ".${CURRENT_GIT_VERSION}")
endif()
set(BUILD_VERSION "0${git_string}.PRERELEASE")
else()
set(BUILD_VERSION "1")
endif()
endif()
set(FDB_VERSION "${PROJECT_VERSION}-${BUILD_VERSION}")
endif()
if(NOT FDB_RELEASE)
string(TIMESTAMP FDB_BUILD_TIMESTMAP %Y%m%d%H%M%S)
Expand All @@ -129,7 +142,7 @@ if(NOT FDB_RELEASE)
set(FDB_BUILDTIME_STRING ".${FDB_BUILDTIME}")
set(PRERELEASE_TAG "prerelease")
endif()
set(FDB_VERSION_PLAIN ${FDB_VERSION})
set(FDB_VERSION_PLAIN ${PROJECT_VERSION})
string(REPLACE "." ";" FDB_VERSION_LIST ${FDB_VERSION_PLAIN})
list(GET FDB_VERSION_LIST 0 FDB_MAJOR)
list(GET FDB_VERSION_LIST 1 FDB_MINOR)
Expand Down
24 changes: 24 additions & 0 deletions build-scripts/for-github/calc-version-from-git.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Calculate version numbers from git tags and set them to github output
# Assume that current directory is a github repository

# Do not set github variables when running outside github
[[ -z "$GITHUB_OUTPUT" ]] && GITHUB_OUTPUT=/dev/null

git fetch --prune --unshallow --tags --force
GIT_VERSION=`git describe --tags`
PROJECT_VERSION=`echo $GIT_VERSION | cut -d- -f1`
BUILD_VERSION=`echo $GIT_VERSION | cut -d- -f2-3 --output-delimiter=.`
GIT_CHANGE_NUM=`echo $GIT_VERSION | cut -d- -f3`
if [[ -n "$GIT_CHANGE_NUM" ]] || [[ "$BUILD_VERSION" < "1" ]]; then
RELEASE_FLAG=OFF
else
RELEASE_FLAG=ON
fi

# Display versions and set Github environment
echo "project_ver=$PROJECT_VERSION" | tee -a $GITHUB_OUTPUT
echo "build_ver=$BUILD_VERSION" | tee -a $GITHUB_OUTPUT
echo "full_ver=$PROJECT_VERSION-$BUILD_VERSION" | tee -a $GITHUB_OUTPUT
echo "release_flag=$RELEASE_FLAG" | tee -a $GITHUB_OUTPUT
83 changes: 83 additions & 0 deletions build-scripts/for-linux/build-on-linux.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

# $1 - Version
# $2 - Build version
# $3 - Release flag
# $4 - Paralllel threads
# $5 - Source Dir. If not set then relative to the script dir

get_oldest_java_path()
{
if [ -x "$(command -v update-java-alternatives)" ]
then
update-java-alternatives -l | sort -Vk1 | head -n 1 | awk '{print $3}'
else
echo 'update-java-alternatives is not installed' >&2
ls -d /etc/alternatives/java_sdk_*[0-9] | sort -V | head -n 1
fi
}

set -e

BASE_DIR="$(readlink -f $(dirname $0))"
source $BASE_DIR/../set-ver-prms.sh "$1" "$2"
RELEASE_FLAG=${3:-OFF}
PARALLEL_PRMS="-j ${4:-$(nproc)}"
SRC_DIR=${5:-$(readlink -f $BASE_DIR/../..)}

START_DIR=`pwd`
BUILD_DIR=$START_DIR/bld/linux

mkdir -p $BUILD_DIR
pushd $BUILD_DIR

rm -rf *
export LANG=C

APP_PRMS="\
$CMAKE_VERSION_PRMS \
-DFDB_RELEASE=$RELEASE_FLAG \
-DGENERATE_DEBUG_PACKAGES=OFF \
-DUSE_LIBCXX=ON \
-DUSE_LD=LLD \
-DSTATIC_LINK_LIBCXX=ON \
-DENABLE_SIMULATION_TESTS=ON"

[ ! -e /usr/lib64/libcrypto.a -a -e /opt/openssl/lib/libcrypto.a ] && \
APP_PRMS="$APP_PRMS -DOPENSSL_ROOT_DIR=/opt/openssl"

# find swift
APP_PRMS="$APP_PRMS -DCMAKE_Swift_COMPILER=`$BASE_DIR/find-swift.bash`"

# set oldest java
JAVA_OLDEST_PATH=$(get_oldest_java_path)


echo "env JAVA_HOME=$JAVA_OLDEST_PATH CC=clang CXX=clang++ cmake -G Ninja $APP_PRMS $SRC_DIR"
env JAVA_HOME=$JAVA_OLDEST_PATH CC=clang CXX=clang++ cmake -G Ninja $APP_PRMS $SRC_DIR

echo "number of parallel jobs: [$PARALLEL_PRMS]"

ninja $PARALLEL_PRMS -k 0

echo "=== Disk space after build ==="
df -h

cpack -G RPM
for fn in packages/*.rpm; do echo "$fn:"; rpm -qpRv $fn; echo; done

cpack -G DEB
for fn in packages/*.deb; do echo "$fn:"; dpkg -I $fn; done

ninja $PARALLEL_PRMS -k 0 documentation/package_html

# make all-binaries and libraries archives
# calculate filenames
# TO DO: calculate the processor architecture instead of hardcoding x86_64
BINS_FILENAME=`ls -1 packages/foundationdb-docs-* | sed s/-docs/-bins/ | sed s/.tgz/.x86_64.tgz/`
LIBS_FILENAME=`ls -1 packages/foundationdb-docs-* | sed s/-docs/-libs/ | sed s/.tgz/.x86_64.tgz/`
tar -I pigz -cvf $BINS_FILENAME -C packages/bin .
tar -I pigz -cvf $LIBS_FILENAME -C packages/lib .

popd

14 changes: 14 additions & 0 deletions build-scripts/for-linux/find-swift.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# find swift installation
# print the path to swift installed or return non zero rc


if ! which swiftc 2>/dev/null; then
WILDCARDS="/opt/swift*/usr/bin/swiftc"
if ls $WILDCARDS 2>/dev/null; then
ls -1d $WILDCARDS | tail -n 1
else
return $? 2>/dev/null || exit $?
fi
fi
Loading
Loading