Skip to content

Commit 8e17039

Browse files
legleuxmanojsdoshi
authored andcommitted
Build Clio with CentOS 7
1 parent 1310e5d commit 8e17039

File tree

17 files changed

+319
-28
lines changed

17 files changed

+319
-28
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

.github/actions/lint/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
runs:
2+
using: composite
3+
steps:
4+
# Github's ubuntu-20.04 image already has clang-format-11 installed
5+
- run: |
6+
find src unittests -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-11 -i
7+
shell: bash
8+
9+
- name: Check for differences
10+
id: assert
11+
shell: bash
12+
run: |
13+
git diff --color --exit-code | tee "clang-format.patch"

.github/actions/sign/action.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Sign packages'
2+
runs:
3+
using: "composite"
4+
5+
steps:
6+
- name: Sign
7+
shell: bash
8+
run: |
9+
set -ex -o pipefail
10+
echo "$GPG_KEY_B64"| base64 -d | gpg --batch --no-tty --allow-secret-key-import --import -
11+
unset GPG_KEY_B64
12+
export GPG_PASSPHRASE=$(echo $GPG_KEY_PASS_B64 | base64 -di)
13+
unset GPG_KEY_PASS_B64
14+
export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5)
15+
for PKG in $(ls *.deb); do
16+
dpkg-sig \
17+
-g "--no-tty --digest-algo 'sha512' --passphrase '${GPG_PASSPHRASE}' --pinentry-mode=loopback" \
18+
-k "${GPG_KEYID}" \
19+
--sign builder \
20+
$PKG
21+
done

.github/actions/test/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM cassandra:4.0.4
2+
3+
RUN apt-get update && apt-get install -y postgresql
4+
COPY entrypoint.sh /entrypoint.sh
5+
6+
ENTRYPOINT ["/entrypoint.sh"]

.github/actions/test/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
pg_ctlcluster 12 main start
4+
su postgres -c"psql -c\"alter user postgres with password 'postgres'\""
5+
su cassandra -c "/opt/cassandra/bin/cassandra -R"
6+
sleep 90
7+
chmod +x ./clio_tests
8+
./clio_tests

.github/workflows/build.yml

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,61 @@ jobs:
1111
name: Lint
1212
runs-on: ubuntu-20.04
1313
steps:
14-
- name: Get source
15-
uses: actions/checkout@v3
16-
14+
- uses: actions/checkout@v3
1715
- name: Run clang-format
18-
uses: XRPLF/clio-gha/lint@main
16+
uses: ./.github/actions/lint
1917

2018
build_clio:
2119
name: Build Clio
2220
runs-on: [self-hosted, Linux]
23-
steps:
21+
needs: lint
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
type:
26+
- suffix: deb
27+
image: rippleci/clio-dpkg-builder:2022-09-17
28+
script: dpkg
29+
- suffix: rpm
30+
image: rippleci/clio-rpm-builder:2022-09-17
31+
script: rpm
32+
container:
33+
image: ${{ matrix.type.image }}
2434

25-
- name: Clone Clio repo
26-
uses: actions/checkout@v3
35+
steps:
36+
- uses: actions/checkout@v3
2737
with:
28-
path: clio_src
38+
path: clio
2939

30-
- name: Clone Clio CI repo
40+
- name: Clone Clio packaging repo
3141
uses: actions/checkout@v3
3242
with:
33-
path: clio_ci
34-
repository: 'XRPLF/clio-ci'
43+
path: clio-packages
44+
repository: XRPLF/clio-packages
3545

3646
- name: Build
37-
uses: XRPLF/clio-gha/build@main
47+
shell: bash
48+
run: |
49+
export CLIO_ROOT=$(realpath clio)
50+
if [ ${{ matrix.type.suffix }} == "rpm" ]; then
51+
source /opt/rh/devtoolset-11/enable
52+
fi
53+
cmake -S clio-packages -B clio-packages/build -DCLIO_ROOT=$CLIO_ROOT
54+
cmake --build clio-packages/build --parallel $(nproc)
55+
cp ./clio-packages/build/clio-prefix/src/clio-build/clio_tests .
56+
mv ./clio-packages/build/*.${{ matrix.type.suffix }} .
3857
3958
- name: Artifact packages
4059
uses: actions/upload-artifact@v3
4160
with:
42-
name: clio_packages
43-
path: ${{ github.workspace }}/*.deb
61+
name: clio_${{ matrix.type.suffix }}_packages
62+
path: ${{ github.workspace }}/*.${{ matrix.type.suffix }}
4463

4564
- name: Artifact clio_tests
4665
uses: actions/upload-artifact@v3
4766
with:
48-
name: clio_tests
49-
path: clio_tests
67+
name: clio_tests-${{ matrix.type.suffix }}
68+
path: ${{ github.workspace }}/clio_tests
5069

5170
sign:
5271
name: Sign packages
@@ -56,22 +75,34 @@ jobs:
5675
env:
5776
GPG_KEY_B64: ${{ secrets.GPG_KEY_B64 }}
5877
GPG_KEY_PASS_B64: ${{ secrets.GPG_KEY_PASS_B64 }}
59-
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
type:
82+
- suffix: deb
83+
image: ubuntu:20.04
84+
script: dpkg
85+
# - suffix: rpm
86+
# image: centos:7
87+
# script: rpm
88+
container:
89+
image: ${{ matrix.type.image }}
6090
steps:
91+
- uses: actions/checkout@v3
92+
- name: Install dpkg-sig
93+
run: |
94+
apt-get update && apt-get install -y dpkg-sig gnupg
6195
- name: Get package artifact
6296
uses: actions/download-artifact@v3
6397
with:
64-
name: clio_packages
98+
name: clio_${{ matrix.type.suffix }}_packages
6599

66100
- name: find packages
67-
run: find . -name "*.deb"
101+
run: find . -name "*.${{ matrix.type.suffix }}"
68102

69-
- name: Install dpkg-sig
70-
run: |
71-
sudo apt-get update && sudo apt-get install -y dpkg-sig
103+
- name: Sign packages
104+
uses: ./.github/actions/sign
72105

73-
- name: Sign Debian packages
74-
uses: XRPLF/clio-gha/sign@main
75106

76107
- name: Verify the signature
77108
run: |
@@ -84,22 +115,28 @@ jobs:
84115
id: shortsha
85116
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
86117

87-
- name: Artifact Debian package
118+
- name: Artifact signed packages
88119
uses: actions/upload-artifact@v2
89120
with:
90-
name: clio-deb-packages-${{ steps.shortsha.outputs.sha8 }}
121+
name: signed-clio-deb-packages-${{ steps.shortsha.outputs.sha8 }}
91122
path: ${{ github.workspace }}/*.deb
92123

93124
test_clio:
94125
name: Test Clio
95126
runs-on: [self-hosted, Linux]
96127
needs: build_clio
128+
strategy:
129+
fail-fast: false
130+
matrix:
131+
suffix: [rpm, deb]
97132
steps:
133+
- uses: actions/checkout@v3
134+
98135
- name: Get clio_tests artifact
99136
uses: actions/download-artifact@v3
100137
with:
101-
name: clio_tests
138+
name: clio_tests-${{ matrix.suffix }}
102139

103140
- name: Run tests
104141
timeout-minutes: 10
105-
uses: XRPLF/clio-gha/test@main
142+
uses: ./.github/actions/test

docker/centos/Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# FROM centos:7 as deps
2+
FROM centos:7 as build
3+
4+
ENV CLIO_DIR=/opt/clio/
5+
# ENV OPENSSL_DIR=/opt/openssl
6+
7+
RUN yum -y install git epel-release centos-release-scl perl-IPC-Cmd openssl
8+
RUN yum install -y devtoolset-11
9+
ENV version=3.16
10+
ENV build=3
11+
# RUN curl -OJL https://cmake.org/files/v$version/cmake-$version.$build.tar.gz
12+
COPY docker/shared/install_cmake.sh /install_cmake.sh
13+
RUN /install_cmake.sh 3.16.3 /usr/local
14+
RUN source /opt/rh/devtoolset-11/enable
15+
WORKDIR /tmp
16+
# RUN mkdir $OPENSSL_DIR && cd $OPENSSL_DIR
17+
COPY docker/centos/build_git_centos7.sh build_git_centos7.sh
18+
19+
RUN ./build_git_centos7.sh
20+
RUN git clone https://github.com/openssl/openssl
21+
WORKDIR /tmp/openssl
22+
RUN git checkout OpenSSL_1_1_1q
23+
#--prefix=/usr --openssldir=/etc/ssl --libdir=lib no-shared zlib-dynamic
24+
RUN SSLDIR=$(openssl version -d | cut -d: -f2 | tr -d [:space:]\") && ./config -fPIC --prefix=/usr --openssldir=${SSLDIR} zlib shared && \
25+
make -j $(nproc) && \
26+
make install_sw
27+
WORKDIR /tmp
28+
# FROM centos:7 as build
29+
30+
RUN git clone https://github.com/xrplf/clio.git
31+
COPY docker/shared/build_boost.sh build_boost.sh
32+
ENV OPENSSL_ROOT=/opt/local/openssl
33+
ENV BOOST_ROOT=/boost
34+
RUN source scl_source enable devtoolset-11 && /tmp/build_boost.sh 1.75.0
35+
RUN yum install -y bison flex
36+
RUN yum install -y rpmdevtools rpmlint
37+
RUN source /opt/rh/devtoolset-11/enable && cd /tmp/clio && \
38+
cmake -B build -DBUILD_TESTS=1 && \
39+
cmake --build build --parallel $(nproc)
40+
RUN mkdir output
41+
RUN strip clio/build/clio_server && strip clio/build/clio_tests
42+
RUN cp clio/build/clio_tests output/ && cp clio/build/clio_server output/
43+
RUN cp clio/example-config.json output/example-config.json
44+
45+
FROM centos:7
46+
COPY --from=build /tmp/output /clio
47+
RUN mkdir -p /opt/clio/etc && mv /clio/example-config.json /opt/clio/etc/config.json
48+
49+
CMD ["/clio/clio_server", "/opt/clio/etc/config.json"]

docker/centos/build_git_centos7.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
GIT_VERSION="2.37.1"
5+
curl -OJL https://github.com/git/git/archive/refs/tags/v${GIT_VERSION}.tar.gz
6+
tar zxvf git-${GIT_VERSION}.tar.gz
7+
cd git-${GIT_VERSION}
8+
9+
yum install -y centos-release-scl epel-release
10+
yum update -y
11+
yum install -y devtoolset-11 autoconf gnu-getopt gettext zlib-devel libcurl-devel
12+
13+
source /opt/rh/devtoolset-11/enable
14+
make configure
15+
./configure
16+
make git -j$(nproc)
17+
make install git
18+
git --version | cut -d ' ' -f3

docker/centos/install_cmake.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
CMAKE_VERSION=${1:-"3.16.3"}
6+
cd /tmp
7+
URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz"
8+
curl -OJLs $URL
9+
tar xzvf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz
10+
mv cmake-${CMAKE_VERSION}-Linux-x86_64 /opt/
11+
ln -s /opt/cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake /usr/local/bin/cmake
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -exu
3+
4+
#yum install wget lz4 lz4-devel git llvm13-static.x86_64 llvm13-devel.x86_64 devtoolset-11-binutils zlib-static
5+
# it's either those or link=static that halves the failures. probably link=static
6+
BOOST_VERSION=$1
7+
BOOST_VERSION_=$(echo ${BOOST_VERSION} | tr . _)
8+
echo "BOOST_VERSION: ${BOOST_VERSION}"
9+
echo "BOOST_VERSION_: ${BOOST_VERSION_}"
10+
curl -OJLs "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_}.tar.gz"
11+
tar zxf "boost_${BOOST_VERSION_}.tar.gz"
12+
cd boost_${BOOST_VERSION_} && ./bootstrap.sh && ./b2 --without-python link=static -j$(nproc)
13+
mkdir -p /boost && mv boost /boost && mv stage /boost

0 commit comments

Comments
 (0)