Skip to content

Commit

Permalink
Add support for RelWithDebInfo (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoBarisic committed May 22, 2024
1 parent 69aa9f3 commit d84b664
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 18 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/package_mage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ on:
- "without ML"
mage_build_target:
type: choice
description: "Mage image target"
description: "Mage image target. By default 'dev' uses 'RelWithDebInfo' and 'with ML'."
default: 'prod'
options:
- "prod"
- "dev"
mage_build_type:
type: choice
description: "Mage build type"
default: 'Release'
options:
- "Release"
- "RelWithDebInfo"
memgraph_version:
type: string
description: "Memgraph version to build into the package (format: X.Y.Z)."
Expand All @@ -50,6 +57,7 @@ jobs:
arch: ${{ github.event.inputs.mage_build_arch || 'amd' }}
mage_build_scope: ${{ github.event.inputs.mage_build_scope || 'all' }}
mage_build_target: ${{ github.event.inputs.mage_build_target || 'prod' }}
mage_build_type: ${{ github.event.inputs.mage_build_type || 'Release' }}
mage_version: ${{ github.event.inputs.mage_version }}
memgraph_version: ${{ github.event.inputs.memgraph_version }}
memgraph_download_link: ${{ github.event.inputs.memgraph_download_link || '' }}
Expand Down
54 changes: 40 additions & 14 deletions .github/workflows/reusable_package_mage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
type: string
description: "Mage build target"
default: 'prod'
mage_build_type:
type: string
description: "Mage build type"
default: 'Release'
memgraph_version:
type: string
description: "Memgraph version built into this image (format: X.Y.Z)"
Expand Down Expand Up @@ -71,7 +75,20 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set image tag
- name: Set build scope, target and type
run: |
BUILD_TARGET="${{ inputs.mage_build_target }}"
BUILD_SCOPE="${{ inputs.mage_build_scope }}"
BUILD_TYPE="${{ inputs.mage_build_type }}"
if [[ "$BUILD_TARGET" == 'dev' ]]; then
BUILD_SCOPE="with ML"
BUILD_TYPE="RelWithDebInfo"
fi
echo "MAGE_BUILD_SCOPE=$BUILD_SCOPE" >> $GITHUB_ENV
echo "MAGE_BUILD_TARGET=$BUILD_TARGET" >> $GITHUB_ENV
echo "MAGE_BUILD_TYPE=$BUILD_TYPE" >> $GITHUB_ENV
- name: Set image tag and artifact name
run: |
MEMGRAPH_VERSION=${{ inputs.memgraph_version }}
MAGE_VERSION=${{ inputs.mage_version }}
Expand All @@ -85,22 +102,30 @@ jobs:
MAGE_VERSION=${MAGE_VERSION%.*}
fi
fi
BUILD_TAGS=""
IMAGE_TAG="${MAGE_VERSION}-memgraph-${MEMGRAPH_VERSION}"
ARTIFACT_NAME="mage-${IMAGE_TAG}"
if [[ "${{ inputs.arch }}" == 'arm' ]]; then
BUILD_TAGS="${BUILD_TAGS}-arm"
ARTIFACT_NAME="${ARTIFACT_NAME}-arm"
fi
if [[ "${{ env.MAGE_BUILD_SCOPE }}" == 'without ML' ]]; then
ARTIFACT_NAME="${ARTIFACT_NAME}-no-ml"
IMAGE_TAG="${IMAGE_TAG}-no-ml"
fi
if [[ "${{ inputs.mage_build_scope }}" == 'without ML' ]]; then
BUILD_TAGS="${BUILD_TAGS}-no-ML"
if [[ "${{ env.MAGE_BUILD_TARGET }}" == 'dev' ]]; then
ARTIFACT_NAME="${ARTIFACT_NAME}-dev"
IMAGE_TAG="${IMAGE_TAG}-dev"
fi
if [[ "${{ inputs.mage_build_target }}" == 'dev' ]]; then
BUILD_TAGS="${BUILD_TAGS}-dev"
if [[ "${{ env.MAGE_BUILD_TYPE }}" == 'RelWithDebInfo' ]]; then
ARTIFACT_NAME="${ARTIFACT_NAME}-relwithdebinfo"
IMAGE_TAG="${IMAGE_TAG}-relwithdebinfo"
fi
echo "IMAGE_TAG=${MAGE_VERSION}-memgraph-${MEMGRAPH_VERSION}${BUILD_TAGS}" >> $GITHUB_ENV
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
- name: Set target dockerfile
run: |
DOCKERFILE="Dockerfile.release"
if [[ "${{ inputs.mage_build_scope }}" == "without ML" ]]; then
if [[ "${{ env.MAGE_BUILD_SCOPE }}" == "without ML" ]]; then
DOCKERFILE="Dockerfile.no_ML"
fi
echo "DOCKERFILE=${DOCKERFILE}" >> $GITHUB_ENV
Expand Down Expand Up @@ -147,22 +172,23 @@ jobs:
- name: Build docker image
run: |
docker buildx build \
--target ${{ inputs.mage_build_target }} \
--target ${{ env.MAGE_BUILD_TARGET }} \
--platform linux/${{ inputs.arch }}64 \
--tag ${DOCKER_REPOSITORY_NAME}:${{ env.IMAGE_TAG }} \
--file ${{ env.DOCKERFILE }} \
--build-arg BUILD_TYPE=${{ env.MAGE_BUILD_TYPE }} \
--load .
- name: Save docker image
run: |
mkdir output
docker save ${DOCKER_REPOSITORY_NAME}:${{ env.IMAGE_TAG }} > output/mage_${{ env.IMAGE_TAG }}.tar.gz
docker save ${DOCKER_REPOSITORY_NAME}:${{ env.IMAGE_TAG }} > output/${{ env.ARTIFACT_NAME }}.tar.gz
- name: Push to GitHub
uses: actions/upload-artifact@v4
with:
name: "mage_${{ env.IMAGE_TAG }}"
path: "output/mage_${{ env.IMAGE_TAG }}.tar.gz"
name: "${{ env.ARTIFACT_NAME }}"
path: "output/${{ env.ARTIFACT_NAME }}.tar.gz"

- name: Push to DockerHub
if: ${{ inputs.push_to_dockerhub == 'true' }}
Expand All @@ -177,4 +203,4 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "eu-west-1"
SOURCE_DIR: "output"
DEST_DIR: "mage-unofficial/mage_${{ env.IMAGE_TAG }}/"
DEST_DIR: "mage-unofficial/${{ env.ARTIFACT_NAME }}/"
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ RUN apt-get update && apt-get install -y \
git `mage-memgraph` \
unixodbc `mage-memgraph` \
libboost-all-dev `mage-memgraph` \
gdb \
procps \
linux-perf \
libc6-dbg \
--no-install-recommends \
# Download and install Memgraph
&& curl https://download.memgraph.com/memgraph/v${MG_VERSION}/debian-11/memgraph_${MG_VERSION}-1_amd64.deb --output memgraph.deb \
&& dpkg -i memgraph.deb \
&& rm memgraph.deb \
&& ln -s /usr/bin/$(ls /usr/bin | grep perf) /usr/bin/perf \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV LD_LIBRARY_PATH /usr/lib/memgraph/query_modules
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.cugraph
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ RUN apt-get update && apt-get install -y \
software-properties-common `mage-cugraph` \
lsb-release `mage-cugraph` \
wget `mage-cugraph` \
gdb \
procps \
linux-perf \
libc6-dbg \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
# Install newest CMake (cuGraph requires >= 20.01)
Expand Down
9 changes: 8 additions & 1 deletion Dockerfile.no_ML
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ RUN apt-get update && apt-get install -y \
clang `mage-memgraph` \
git `mage-memgraph` \
unixodbc-dev `mage-memgraph` \
gdb \
procps \
linux-perf \
libc6-dbg \
--no-install-recommends \
&& ln -s /usr/bin/$(ls /usr/bin | grep perf) /usr/bin/perf \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY memgraph-${TARGETARCH}.deb .
Expand All @@ -40,6 +45,8 @@ EXPOSE 7687

FROM base as dev

ARG BUILD_TYPE=Release

WORKDIR /mage
COPY . /mage

Expand All @@ -49,7 +56,7 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& export PATH="/root/.cargo/bin:${PATH}" \
&& python3 -m pip install -r /mage/python/tests/requirements.txt \
&& python3 -m pip install -r /mage/python/requirements_no_ml.txt \
&& python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ --no-ml \
&& python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ --no-ml --cpp-build-flags CMAKE_BUILD_TYPE=${BUILD_TYPE} \
&& chown -R memgraph: /mage/e2e


Expand Down
9 changes: 8 additions & 1 deletion Dockerfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ RUN apt-get update && apt-get install -y \
clang `mage-memgraph` \
git `mage-memgraph` \
unixodbc-dev `mage-memgraph` \
gdb \
procps \
linux-perf \
libc6-dbg \
--no-install-recommends \
&& ln -s /usr/bin/$(ls /usr/bin | grep perf) /usr/bin/perf \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY memgraph-${TARGETARCH}.deb .
Expand All @@ -42,6 +47,8 @@ EXPOSE 7687

FROM base as dev

ARG BUILD_TYPE=Release

WORKDIR /mage
COPY . /mage

Expand All @@ -52,7 +59,7 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& python3 -m pip install -r /mage/python/requirements.txt \
&& python3 -m pip install -r /mage/python/tests/requirements.txt \
&& python3 -m pip install torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+cu102.html \
&& python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ \
&& python3 /mage/setup build -p /usr/lib/memgraph/query_modules/ --cpp-build-flags CMAKE_BUILD_TYPE=${BUILD_TYPE} \
&& chown -R memgraph: /mage/e2e

#DGL build from source
Expand Down
5 changes: 4 additions & 1 deletion setup
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Lang(Enum):
class BuildType(Enum):
DEBUG = "Debug"
RELEASE = "Release"
RELWITHDEBINFO = "RelWithDebInfo"

def __str__(self):
return str(self.value)
Expand Down Expand Up @@ -296,7 +297,9 @@ def build_and_copy_rust_modules(args: Dict[str, Any]) -> bool:
rs_build_mode = BuildType.DEBUG
if args[Parameter.TYPE.value] == BuildType.RELEASE:
rs_build_mode = BuildType.RELEASE
rs_build_mode = rs_build_mode.lower()
if args[Parameter.TYPE.value] == BuildType.RELWITHDEBINFO:
rs_build_mode = BuildType.RELWITHDEBINFO
rs_build_mode = rs_build_mode.value.lower()
rs_build_flags = ["--release"]
if (
args[Parameter.TYPE.value] is not None
Expand Down

0 comments on commit d84b664

Please sign in to comment.