Compare commits

...

25 Commits

Author SHA1 Message Date
Deda
3086e8569a Fix test script call 2024-02-02 15:24:17 +01:00
Deda
8e27ce9fc6 Improve cleanup and modify reusable workflows 2024-02-02 14:04:32 +01:00
Deda
de81eb3d98 Test release build tests 2024-02-02 12:38:05 +01:00
Deda
741cc7091a Test run id 2024-02-02 11:23:55 +01:00
Deda
08021ecf01 Fix typo in reusable build 2024-02-02 11:22:00 +01:00
Deda
8634ffd953 Restructure testflow 2024-02-02 11:21:15 +01:00
Deda
15ffc6422f Add experimental_mt 2024-02-02 10:59:36 +01:00
Deda
a56a6116ed Fix inputs type 2024-02-02 10:58:00 +01:00
Deda
1997eddc8e Test all build with resuable build 2024-02-02 10:55:53 +01:00
Deda
4cdb536c3f Fix inputs in reusable build 2024-02-02 10:39:13 +01:00
Deda
cae54f5308 Test reusable build secrets 2024-02-02 10:37:45 +01:00
Deda
d89d53712c Test reusable build 2024-02-02 10:34:27 +01:00
Deda
d5a06f7539 Test reusable build 2024-02-02 10:33:41 +01:00
Deda
71c035b5a6 Test reusable build 2024-02-02 10:32:55 +01:00
Deda
7179ced028 Fix env var reference syntax 2024-02-02 01:10:19 +01:00
Deda
99d9675e08 Fix env var reference syntax 2024-02-02 00:59:32 +01:00
Deda
c6839fdfa0 Test all builds 2024-02-02 00:55:53 +01:00
Deda
5af434d5df Fix env var 2024-02-01 23:40:22 +01:00
Deda
935fda33df Fix tag env var name 2024-02-01 19:09:19 +01:00
Deda
15676f2557 Merge branch 'ci-in-docker' of github.com:memgraph/memgraph into ci-in-docker 2024-02-01 18:25:50 +01:00
Deda
efdd450b09 Test build push and pull 2024-02-01 18:25:38 +01:00
Marko Barišić
ce665d2c1b Merge branch 'master' into ci-in-docker 2024-01-31 19:19:29 +01:00
Deda
dd53f8d6b1 Progress 2024-01-31 16:33:15 +01:00
Marko Barišić
74fa6184b1 Merge branch 'master' into ci-in-docker 2024-01-31 15:51:09 +01:00
Deda
892f948866 Add directory structure and Dockerfiles for mgubilder and mgbuilder-base 2024-01-31 15:50:18 +01:00
7 changed files with 475 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ on:
branches:
- master
workflow_dispatch:
pull_request:
# pull_request:
paths-ignore:
- "docs/**"
- "**/*.md"

61
.github/workflows/reusable_build.yaml vendored Normal file
View File

@@ -0,0 +1,61 @@
name: Build Memgraph
on:
workflow_call:
inputs:
build_name:
description: Which build type will be used (community, debug, release ...)?
required: true
type: string
threads:
description: How many threads will be used to build memgraph?
default: 24
type: number
os:
description: Base image with which os will be used?
default: debian-10
type: string
toolchain_version:
description: Which toolchain version will be used in the build?
default: 4
type: number
env:
TAG: "memgraph/mgbuilder:${{ github.sha }}-${{ inputs.build_name }}"
OS: ${{ inputs.os }}
TOOLCHAIN_VERSION: ${{ inputs.toolchain_version }}
THREADS: ${{ inputs.threads }}
MEMGRAPH_ENTERPRISE_LICENSE: ${{ secrets.MEMGRAPH_ENTERPRISE_LICENSE }}
MEMGRAPH_ORGANIZATION_NAME: ${{ secrets.MEMGRAPH_ORGANIZATION_NAME }}
jobs:
build:
name: "${{ github.sha }}-${{ inputs.build_name }}"
runs-on: [self-hosted, Linux, X64, Diff]
timeout-minutes: 60
steps:
- name: Set up repository
uses: actions/checkout@v4
with:
# Number of commits to fetch. `0` indicates all history for all
# branches and tags. (default: 1)
fetch-depth: 0
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build memgraph/mgbuilder:${{ github.sha }}-${{ inputs.build_name }}
run: ./docker/ci.bash build ${{ inputs.build_name }}
- name: Push mgbuilder image
run: docker push $TAG
- name: Clean up
if: ${{ always() }}
run: |
docker container prune -f
docker image prune -f
docker builder prune -f
docker image rm $TAG

60
.github/workflows/reusable_test.yaml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: Run a test
on:
workflow_call:
inputs:
test_name:
description: Which test will be run?
required: true
type: string
mgbuilder:
description: Which mgbuilder image is needed to perform the test?
type: string
required: true
threads:
description: How many threads will be used to build memgraph?
default: 24
type: number
os:
description: Base image with which os will be used?
default: debian-10
type: string
toolchain_version:
description: Which toolchain version will be used in the build?
default: 4
type: number
env:
OS: ${{ inputs.os }}
TOOLCHAIN_VERSION: ${{ inputs.toolchain_version }}
THREADS: ${{ inputs.threads }}
MEMGRAPH_ENTERPRISE_LICENSE: ${{ secrets.MEMGRAPH_ENTERPRISE_LICENSE }}
MEMGRAPH_ORGANIZATION_NAME: ${{ secrets.MEMGRAPH_ORGANIZATION_NAME }}
TEST_CONTAINER: "${{ inputs.test_name }}-${{ github.run_id }}"
jobs:
RunTest:
name: "Run ${{ inputs.test_name }} test"
runs-on: [self-hosted, Linux, X64, Diff]
timeout-minutes: 60
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull ${{ inputs.mgbuilder_tag }}
run: docker pull ${{ inputs.mgbuilder }}
- name: Run ${{ inputs.test_name }}
run: |
docker run --rm \
--name $TEST_CONTAINER \
--entrypoint /bin/bash \
${{ inputs.mgbuilder }} \
-c "./memgraph/docker/ci.bash test ${{ inputs.test_name }}"
- name: Clean up
if: ${{ always() }}
run: |
docker image rm ${{ inputs.mgbuilder }}

126
.github/workflows/testflow.yaml vendored Normal file
View File

@@ -0,0 +1,126 @@
name: Test workflow
concurrency:
group: ${{ github.head_ref || github.sha }}
cancel-in-progress: true
on:
push:
branches:
- master
workflow_dispatch:
pull_request:
paths-ignore:
- "docs/**"
- "**/*.md"
- ".clang-format"
- "CODEOWNERS"
- "licenses/*"
env:
THREADS: 24
MEMGRAPH_ENTERPRISE_LICENSE: ${{ secrets.MEMGRAPH_ENTERPRISE_LICENSE }}
MEMGRAPH_ORGANIZATION_NAME: ${{ secrets.MEMGRAPH_ORGANIZATION_NAME }}
OS: "debian-10"
TOOLCHAIN_VERSION: "4"
jobs:
########################################################################################
######################################## BUILDS ########################################
########################################################################################
MgbuilderCommunity:
if: false
uses: ./.github/workflows/reusable_build.yaml
with:
build_name: community
threads: 24
os: debian-10
toolchain_version: 4
secrets: inherit
MgbuilderDebug:
if: false
uses: ./.github/workflows/reusable_build.yaml
with:
build_name: debug
threads: 24
os: debian-10
toolchain_version: 4
secrets: inherit
MgbuilderRelease:
# if: false
uses: ./.github/workflows/reusable_build.yaml
with:
build_name: release
threads: 24
os: debian-10
toolchain_version: 4
secrets: inherit
MgbuilderExperimentalHA:
if: false
uses: ./.github/workflows/reusable_build.yaml
with:
build_name: experimental_ha
threads: 24
os: debian-10
toolchain_version: 4
secrets: inherit
MgbuilderExperimentalMT:
if: false
uses: ./.github/workflows/reusable_build.yaml
with:
build_name: experimental_mt
threads: 24
os: debian-10
toolchain_version: 4
secrets: inherit
########################################################################################
######################################## TESTS #########################################
########################################################################################
StressTestPlain:
needs: [MgbuilderRelease]
uses: ./.github/workflows/reusable_test.yaml
with:
test_name: stress
mgbuilder: "memgraph/mgbuilder:${{ github.sha }}-release"
threads: 24
secrets: inherit
StressTestSSL:
needs: [MgbuilderRelease]
uses: ./.github/workflows/reusable_test.yaml
with:
test_name: stress_ssl
mgbuilder: "memgraph/mgbuilder:${{ github.sha }}-release"
threads: 24
secrets: inherit
DurabilityTest:
needs: [MgbuilderRelease]
uses: ./.github/workflows/reusable_test.yaml
with:
test_name: durability
mgbuilder: "memgraph/mgbuilder:${{ github.sha }}-release"
threads: 24
secrets: inherit
UnitTest:
needs: [MgbuilderRelease]
uses: ./.github/workflows/reusable_test.yaml
with:
test_name: unit
mgbuilder: "memgraph/mgbuilder:${{ github.sha }}-release"
threads: 24
secrets: inherit
GQLBehaveTest:
needs: [MgbuilderRelease]
uses: ./.github/workflows/reusable_test.yaml
with:
test_name: gql_behave
mgbuilder: "memgraph/mgbuilder:${{ github.sha }}-release"
threads: 24
secrets: inherit

169
docker/ci.bash Executable file
View File

@@ -0,0 +1,169 @@
#!/usr/bin/env bash
set -eo pipefail
DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ROOT_DIR=$DIR/..
BUILD_DIR=$ROOT_DIR/build
OS=${OS:-debian-10}
TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION:-4}
THREADS=${THREADS:-$(nproc)}
TAG=${TAG:-memgraph/mgbuilder:12345}
DOCKERFILE_PATH=${DOCKERFILE_PATH:-$DIR/mgbuilder/Dockerfile}
DOCKER_CONTEXT_PATH=${DOCKER_CONTEXT_PATH:-$DIR/..}
TOOLCHAIN_ACTIVATE=${TOOLCHAIN_ACTIVATE:-"source /opt/toolchain-v${TOOLCHAIN_VERSION}/activate"}
print_help() {
echo -e "$0 build BUILD_TYPE | test TEST_NAME"
exit 1
}
build() {
case "$1" in
community)
cmake_cmd="cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMG_ENTERPRISE=OFF .."
make_cmd="make -j$THREADS"
;;
debug)
cmake_cmd="cmake -DCMAKE_BUILD_TYPE=Debug .."
make_cmd="make -j$THREADS"
;;
jepsen)
cmake_cmd="cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .."
make_cmd="make -j$THREADS memgraph"
;;
release)
cmake_cmd="cmake -DCMAKE_BUILD_TYPE=Release .."
make_cmd="make -j$THREADS"
;;
experimental_mt)
cmake_cmd="cmake -DCMAKE_BUILD_TYPE=Release -DMG_EXPERIMENTAL_REPLICATION_MULTITENANCY=ON .."
make_cmd="make -j$THREADS"
;;
experimental_ha)
cmake_cmd="cmake -DCMAKE_BUILD_TYPE=Release -DMG_EXPERIMENTAL_HIGH_AVAILABILITY=ON .."
make_cmd="make -j$THREADS"
;;
*)
print_help build
;;
esac
docker buildx build \
-f $DOCKERFILE_PATH \
-t $TAG \
--build-arg CMAKE_CMD="$cmake_cmd" \
--build-arg MAKE_CMD="$make_cmd" \
--build-arg OS=$OS \
--build-arg THREADS=$THREADS \
--build-arg TOOLCHAIN_VERSION=$TOOLCHAIN_VERSION \
$DOCKER_CONTEXT_PATH
}
unit_test() {
$TOOLCHAIN_ACTIVATE
cd $BUILD_DIR
ctest -R memgraph__unit --output-on-failure -j$THREADS
}
leftover_ctests() {
$TOOLCHAIN_ACTIVATE
cd $BUILD_DIR
ctest -E "(memgraph__unit|memgraph__benchmark)" --output-on-failure
}
drivers_test() {
cd $ROOT_DIR
./tests/drivers/run.sh
}
integration_test() {
cd $ROOT_DIR
tests/integration/run.sh
}
cppcheck_and_clang_format() {
$TOOLCHAIN_ACTIVATE
cd $ROOT_DIR/tools/github
./cppcheck_and_clang_format diff
}
stress_test () {
cd $ROOT_DIR/tests/stress
source ve3/bin/activate
case "$1" in
plain)
./continuous_integration
;;
ssl)
./continuous_integration --use-ssl
;;
*)
print_help test
;;
esac
}
durability_test() {
cd $ROOT_DIR/tests/stress
source ve3/bin/activate
python3 durability --num-steps 5
}
gql_behave_test() {
$TOOLCHAIN_ACTIVATE
cd $ROOT_DIR/tests/gql_behave
./continuous_integration
}
run_test() {
case "$1" in
unit)
unit_test
;;
leftover-CTest)
leftover_ctest
;;
drivers)
drivers_test
;;
integration)
integration_test
;;
cppcheck-and-clang-format)
cppcheck_and_clang_format
;;
stress)
stress_test plain
;;
stress_ssl)
stress_test ssl
;;
durability)
durability_test
;;
gql_behave)
gql_behave_test
;;
*)
print_help test
;;
esac
}
if [[ "$#" -eq 0 ]]; then
print_help
else
case "$1" in
build)
build $2
;;
test)
run_test $2
;;
*)
print_help
;;
esac
fi

View File

@@ -0,0 +1,32 @@
FROM debian:10
ARG TOOLCHAIN_VERSION=4
ENV TOOLCHAIN="toolchain-v${TOOLCHAIN_VERSION}"
ENV TOOLCHAIN_ACTIVATE="source /opt/$TOOLCHAIN/activate"
ENV OS=debian-10
ENV TARGETARCH=amd64
# Stops tzdata interactive configuration.
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y \
ca-certificates wget git
# Do NOT be smart here and clean the cache because the container is used in the
# stateful context.
RUN wget -q https://s3-eu-west-1.amazonaws.com/deps.memgraph.io/$TOOLCHAIN/$TOOLCHAIN-binaries-$OS-$TARGETARCH.tar.gz \
-O $TOOLCHAIN-binaries-$OS-$TARGETARCH.tar.gz \
&& tar xzvf $TOOLCHAIN-binaries-$OS-$TARGETARCH.tar.gz -C /opt \
&& rm $TOOLCHAIN-binaries-$OS-$TARGETARCH.tar.gz
COPY . /memgraph
SHELL ["/bin/bash", "-c"]
RUN cd memgraph && \
git remote set-url origin https://github.com/memgraph/memgraph.git && \
./environment/os/$OS.sh install TOOLCHAIN_RUN_DEPS && \
./environment/os/$OS.sh install MEMGRAPH_BUILD_DEPS && \
cd / && rm -rf memgraph
ENTRYPOINT ["sleep", "infinity"]

View File

@@ -0,0 +1,26 @@
ARG TOOLCHAIN_VERSION=4
ARG OS=debian-10
FROM memgraph/mgbuilder-base:toolchain-v${TOOLCHAIN_VERSION}_${OS}
ARG BUILD_TYPE=Release
ARG THREADS
ENV BUILD_TYPE=${BUILD_TYPE}
ENV THREADS=${THREADS}
ARG CMAKE_CMD="cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .."
ARG MAKE_CMD="make -j$THREADS"
COPY . /memgraph
SHELL ["/bin/bash", "-c"]
# Initialize deps
RUN cd memgraph && \
git remote set-url origin https://github.com/memgraph/memgraph.git && \
$TOOLCHAIN_ACTIVATE && \
./init && \
cd build && \
$CMAKE_CMD && \
$MAKE_CMD
ENTRYPOINT ["sleep", "infinity"]