Skip to content

Commit

Permalink
core: Add support for building on Centos Stream 9 and drop support fo…
Browse files Browse the repository at this point in the history
…r building on Centos 7.4 (fixes y-scope#521). (y-scope#528)

Co-authored-by: Lin Zhihao <[email protected]>
  • Loading branch information
kirkrodrigues and LinZhihao-723 authored Sep 6, 2024
1 parent a3a3f35 commit decdc2d
Show file tree
Hide file tree
Showing 24 changed files with 129 additions and 166 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/clp-core-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
filter-relevant-changes:
runs-on: "ubuntu-latest"
outputs:
centos74_image_changed: "${{steps.filter.outputs.centos74_image}}"
centos_stream_9_image_changed: "${{steps.filter.outputs.centos_stream_9_image}}"
ubuntu_focal_image_changed: "${{steps.filter.outputs.ubuntu_focal_image}}"
ubuntu_jammy_image_changed: "${{steps.filter.outputs.ubuntu_jammy_image}}"
clp_changed: "${{steps.filter.outputs.clp}}"
Expand All @@ -63,12 +63,12 @@ jobs:
# image (since it would be different from the published image).
base: "main"
filters: |
centos74_image:
centos_stream_9_image:
- ".github/actions/**"
- ".github/workflows/clp-core-build.yaml"
- "components/core/tools/scripts/lib_install/*.sh"
- "components/core/tools/docker-images/clp-env-base-centos7.4/**"
- "components/core/tools/scripts/lib_install/centos7.4/**"
- "components/core/tools/docker-images/clp-env-base-centos-stream-9/**"
- "components/core/tools/scripts/lib_install/centos-stream-9/**"
ubuntu_focal_image:
- ".github/actions/**"
- ".github/workflows/clp-core-build.yaml"
Expand All @@ -94,8 +94,8 @@ jobs:
- "Taskfile.yml"
- "tools/scripts/deps-download/**"
centos74-deps-image:
if: "needs.filter-relevant-changes.outputs.centos74_image_changed == 'true'"
centos-stream-9-deps-image:
if: "needs.filter-relevant-changes.outputs.centos_stream_9_image_changed == 'true'"
needs: "filter-relevant-changes"
runs-on: "ubuntu-latest"
steps:
Expand All @@ -109,7 +109,7 @@ jobs:

- uses: "./.github/actions/clp-core-build-containers"
env:
OS_NAME: "centos7.4"
OS_NAME: "centos-stream-9"
with:
image_name: "${{env.DEPS_IMAGE_NAME_PREFIX}}${{env.OS_NAME}}"
docker_context: "components/core"
Expand Down Expand Up @@ -169,18 +169,18 @@ jobs:
${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}}
token: "${{secrets.GITHUB_TOKEN}}"

centos74-binaries:
centos-stream-9-binaries:
# Run if the ancestor jobs succeeded OR they were skipped and clp was changed.
if: >-
success()
|| (!cancelled() && !failure() && needs.filter-relevant-changes.outputs.clp_changed == 'true')
needs:
- "centos74-deps-image"
- "centos-stream-9-deps-image"
- "filter-relevant-changes"
strategy:
matrix:
use_shared_libs: [true, false]
name: "centos74-${{matrix.use_shared_libs && 'dynamic' || 'static'}}-linked-bins"
name: "centos-stream-9-${{matrix.use_shared_libs && 'dynamic' || 'static'}}-linked-bins"
continue-on-error: true
runs-on: "ubuntu-latest"
steps:
Expand All @@ -194,12 +194,12 @@ jobs:

- uses: "./.github/actions/clp-core-build"
env:
OS_NAME: "centos7.4"
OS_NAME: "centos-stream-9"
with:
image_name: "${{env.DEPS_IMAGE_NAME_PREFIX}}${{env.OS_NAME}}"
use_shared_libs: "${{matrix.use_shared_libs}}"
use_published_image: >-
${{needs.filter-relevant-changes.outputs.centos74_image_changed == 'false'
${{needs.filter-relevant-changes.outputs.centos_stream_9_image_changed == 'false'
|| (github.event_name != 'pull_request' && github.ref == 'refs/heads/main')}}
upload_binaries: "false"

Expand Down
4 changes: 2 additions & 2 deletions components/core/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ IncludeCategories:
# NOTE: A header is grouped by first matching regex
# Library headers. Update when adding new libraries.
# NOTE: clang-format retains leading white-space on a line in violation of the YAML spec.
- Regex: "<(absl|antlr4|archive|boost|bsoncxx|catch2|curl|date|fmt|json|log_surgeon|mariadb\
|mongocxx|msgpack|openssl|outcome|regex_utils|simdjson|spdlog|sqlite3|string_utils|yaml-cpp|zstd)"
- Regex: "<(absl|antlr4|archive|boost|bsoncxx|catch2|curl|date|fmt|json|log_surgeon|mongocxx\
|msgpack|mysql|openssl|outcome|regex_utils|simdjson|spdlog|sqlite3|string_utils|yaml-cpp|zstd)"
Priority: 3
# C system headers
- Regex: "^<.+\\.h>"
Expand Down
18 changes: 14 additions & 4 deletions components/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ endif()

# Detect linking mode (static or shared); Default to static.
set(CLP_USE_STATIC_LIBS ON CACHE BOOL "Whether to link against static libraries")
if (CLP_USE_STATIC_LIBS AND APPLE)
message(AUTHOR_WARNING "Building with static libraries is unsupported on macOS."
" Switching to shared libraries.")
set(CLP_USE_STATIC_LIBS OFF)
if (CLP_USE_STATIC_LIBS)
if (APPLE)
set(CLP_STATIC_LIBS_UNSUPPORTED_PLATFORM "macOS")
elseif (EXISTS "/etc/centos-release")
set(CLP_STATIC_LIBS_UNSUPPORTED_PLATFORM "CentOS")
endif()

if (DEFINED CLP_STATIC_LIBS_UNSUPPORTED_PLATFORM)
message(
AUTHOR_WARNING
"Building with static libraries is unsupported on"
" ${CLP_STATIC_LIBS_UNSUPPORTED_PLATFORM}. Switching to shared libraries.")
set(CLP_USE_STATIC_LIBS OFF)
endif()
endif ()
if(CLP_USE_STATIC_LIBS)
set(CLP_LIBS_STRING "static")
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/clp/MySQLDB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <string>

#include <mariadb/mysql.h>
#include <mysql.h>

#include "Defs.h"
#include "ErrorCode.hpp"
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/clp/MySQLParamBindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdint>
#include <vector>

#include <mariadb/mysql.h>
#include <mysql.h>

#include "ErrorCode.hpp"
#include "TraceableException.hpp"
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/clp/MySQLPreparedStatement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string>
#include <vector>

#include <mariadb/mysql.h>
#include <mysql.h>

#include "ErrorCode.hpp"
#include "MySQLParamBindings.hpp"
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/glt/MySQLDB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <string>

#include <mariadb/mysql.h>
#include <mysql.h>

#include "Defs.h"
#include "ErrorCode.hpp"
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/glt/MySQLParamBindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdint>
#include <vector>

#include <mariadb/mysql.h>
#include <mysql.h>

#include "ErrorCode.hpp"
#include "TraceableException.hpp"
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/glt/MySQLPreparedStatement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <string>
#include <vector>

#include <mariadb/mysql.h>
#include <mysql.h>

#include "ErrorCode.hpp"
#include "MySQLParamBindings.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM dokken/centos-stream-9 AS base

WORKDIR /root

RUN mkdir -p ./tools/scripts/lib_install
ADD ./tools/scripts/lib_install ./tools/scripts/lib_install

RUN ./tools/scripts/lib_install/centos-stream-9/install-all.sh

# NOTE:
# 1. `task` doesn't have an apt/dnf package so we use its install script.
# 2. We don't want to install it using `install-prebuilt-packages.sh` since users may use that on
# their own machines and it would change their environment in a way that can't easily be undone.
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin

# Remove cached files
RUN dnf clean all \
&& rm -rf /tmp/* /var/tmp/*

# Flatten the image
FROM scratch
COPY --from=base / /
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
component_root="${script_dir}/../../../"

docker build \
--tag clp-core-dependencies-x86-centos-stream-9:dev \
"$component_root" \
--file "${script_dir}/Dockerfile"

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ set -u

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

"$script_dir"/install-prebuilt-packages.sh
"$script_dir"/install-packages-from-source.sh
"${script_dir}/install-prebuilt-packages.sh"
"${script_dir}/install-packages-from-source.sh"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
lib_install_scripts_dir="${script_dir}/.."

# NOTE: The remaining installation scripts depend on boost, so we install it beforehand.
"${lib_install_scripts_dir}/install-boost.sh" 1.76.0

"${lib_install_scripts_dir}/fmtlib.sh" 8.0.1
"${lib_install_scripts_dir}/spdlog.sh" 1.9.2
"${lib_install_scripts_dir}/mongocxx.sh" 3.10.2
"${lib_install_scripts_dir}/msgpack.sh" 6.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

dnf install -y \
cmake \
gcc-c++ \
git \
java-11-openjdk \
libarchive-devel \
libcurl-devel \
libzstd-devel \
make \
mariadb-connector-c-devel \
openssl-devel

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ fi
source /etc/os-release
if [ $ID = "ubuntu" ] ; then
os_version=ubuntu-$UBUNTU_CODENAME
elif [ $ID = "centos" ] ; then
os_version=centos${VERSION_ID}
else
echo "Unsupported OS ID: $ID"
exit 1
fi

# Download
Expand Down
Loading

0 comments on commit decdc2d

Please sign in to comment.