Skip to content

Commit db54747

Browse files
authored
Fix CentOS CI by using docker (#190)
* create docker image for github action Signed-off-by: Nicolas Rol <[email protected]> * fix image name Signed-off-by: Nicolas Rol <[email protected]> * fix Dockerfile Signed-off-by: Nicolas Rol <[email protected]> * fix Dockerfile Signed-off-by: Nicolas Rol <[email protected]> * fix Dockerfile Signed-off-by: Nicolas Rol <[email protected]> * fix Dockerfile Signed-off-by: Nicolas Rol <[email protected]> * fix Dockerfile Signed-off-by: Nicolas Rol <[email protected]> * fix Dockerfile Signed-off-by: Nicolas Rol <[email protected]> * test Signed-off-by: Nicolas Rol <[email protected]> * test with full checkout Signed-off-by: Nicolas Rol <[email protected]> * fix test with full checkout Signed-off-by: Nicolas Rol <[email protected]> * try with user root in dockerfile Signed-off-by: Nicolas Rol <[email protected]> * fix boost maybe Signed-off-by: Nicolas Rol <[email protected]> * clean dev-ci.yml Signed-off-by: Nicolas Rol <[email protected]> * fix review comments Signed-off-by: Nicolas Rol <[email protected]> * test Signed-off-by: Nicolas Rol <[email protected]> * test2 Signed-off-by: Nicolas Rol <[email protected]> --------- Signed-off-by: Nicolas Rol <[email protected]>
1 parent be449be commit db54747

File tree

2 files changed

+82
-66
lines changed

2 files changed

+82
-66
lines changed

Diff for: .github/workflows/dev-ci.yml

+14-66
Original file line numberDiff line numberDiff line change
@@ -75,80 +75,28 @@ jobs:
7575
cpp_centos7:
7676
name: Build C++ CentOS7
7777
runs-on: ubuntu-latest
78-
container: 'centos:centos7'
79-
env:
80-
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
8178
steps:
82-
- name: Update mirrors
83-
run: |
84-
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
85-
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
86-
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
87-
88-
- name: Update Dependencies
89-
run: |
90-
yum update -y
91-
92-
- name: Install Dependencies 1
93-
run: |
94-
yum install -y epel-release
95-
96-
- name: Install Dependencies 2
97-
run: |
98-
yum install -y git redhat-lsb-core make wget centos-release-scl scl-utils
99-
100-
- name: Update mirrors again because why not
101-
run: |
102-
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
103-
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
104-
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
105-
106-
- name: Install Dependencies 3
107-
run: |
108-
yum install -y devtoolset-9
109-
110-
- name: Setup cmake
111-
uses: jwlawson/[email protected]
112-
with:
113-
cmake-version: '3.22.x'
114-
115-
- name: Checkout sources
116-
uses: actions/checkout@v3
117-
118-
- name: Download Boost-release
119-
uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 # v1.1.1
120-
with:
121-
repo: 'ARnDOSrte/Boost'
122-
file: 'boost_1_73_0.zip'
123-
target: 'boost_1_73_0.zip'
124-
token: ${{ secrets.GITHUB_TOKEN }}
125-
126-
- name: Unzip Boost
127-
run: unzip boost_1_73_0.zip
128-
129-
- name: Configure 3rd parties
130-
run: |
131-
source /opt/rh/devtoolset-9/enable
132-
cmake -S $GITHUB_WORKSPACE/metrix-simulator/external -B $GITHUB_WORKSPACE/metrix-simulator/build/external
79+
- name: Checkout
80+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
13381

134-
- name: Build 3rd parties
82+
- name: Build the Docker image
13583
run: |
136-
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build/external --parallel 2
84+
docker build -t centos7withcmake:latest $GITHUB_WORKSPACE --file $GITHUB_WORKSPACE/.github/workflows/docker/Dockerfile
13785
138-
- name: Configure CMake
86+
- name: Run build steps in Docker container
13987
run: |
140-
source /opt/rh/devtoolset-9/enable
141-
cmake -S $GITHUB_WORKSPACE/metrix-simulator -Wno-dev -DCMAKE_BUILD_TYPE=Release -DBoost_ROOT=$GITHUB_WORKSPACE/__w/Boost/Boost/boost_1_73_0/installBoost -DBoost_INCLUDE_DIR=$GITHUB_WORKSPACE/__w/Boost/Boost/boost_1_73_0/installBoost -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/metrix-simulator/build/install -B $GITHUB_WORKSPACE/metrix-simulator/build
142-
143-
- name: Build
144-
run: cmake --build $GITHUB_WORKSPACE/metrix-simulator/build --target install --parallel 2
145-
146-
- name: Tests
147-
run: cd $GITHUB_WORKSPACE/metrix-simulator/build && ctest -j2 --output-on-failure
88+
docker run --name build_container -v $GITHUB_WORKSPACE:/workspace centos7withcmake:latest /bin/bash -c "
89+
source /opt/rh/devtoolset-9/enable &&
90+
cmake -S /workspace/metrix-simulator/external -B /workspace/metrix-simulator/build/external &&
91+
cmake --build /workspace/metrix-simulator/build/external --parallel 2 &&
92+
cmake -S /workspace/metrix-simulator -Wno-dev -DCMAKE_BUILD_TYPE=Release -DBoost_ROOT=/usr/local/src/__w/Boost/Boost/boost_1_73_0/installBoost -DBoost_INCLUDE_DIR=/usr/local/src/__w/Boost/Boost/boost_1_73_0/installBoost -DCMAKE_INSTALL_PREFIX=/workspace/metrix-simulator/build/install -B /workspace/metrix-simulator/build &&
93+
cmake --build /workspace/metrix-simulator/build --target install --parallel 2 &&
94+
cd /workspace/metrix-simulator/build && ctest -j2 --output-on-failure
95+
"
14896
14997
- name: Upload Metrix Simulator archive
15098
if: ${{ github.event_name == 'workflow_dispatch' && inputs.generate_artifacts }}
151-
uses: actions/upload-artifact@v3
99+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3
152100
with:
153101
name: metrix-simulator-centos7
154102
path: |

Diff for: .github/workflows/docker/Dockerfile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM centos:7 AS builder1
2+
3+
# Set versions
4+
ENV OPENSSL_VERSION="1.1.1w"
5+
ENV CMAKE_VERSION=3.28.4
6+
ENV PYTHON_VERSION=3.10.8
7+
ENV LDFLAGS="-L/usr/local/ssl/lib"
8+
ENV CPPFLAGS="-I/usr/local/ssl/include"
9+
10+
# Downloads
11+
ADD https://github.com/ARnDOSrte/Boost/releases/download/Test_tag_6/boost_1_73_0.zip /usr/local/src/
12+
ADD https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-${OPENSSL_VERSION}.tar.gz /usr/local/src/
13+
ADD https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz /usr/local/src/
14+
15+
# First set of dependencies
16+
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \
17+
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \
18+
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo \
19+
&& yum update -y \
20+
&& yum install -y epel-release \
21+
&& yum install -y git redhat-lsb-core make wget centos-release-scl scl-utils
22+
23+
# Second set of dependencies
24+
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \
25+
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \
26+
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo \
27+
&& yum install -y devtoolset-9 \
28+
&& yum groupinstall -y "Development Tools" \
29+
&& yum install -y openssl openssl-devel bzip2-devel libffi-devel \
30+
&& yum clean all
31+
32+
# Start on a clean image
33+
FROM builder1 AS builder2
34+
35+
# Unarchive all
36+
WORKDIR /usr/local/src
37+
RUN tar -xzf openssl-${OPENSSL_VERSION}.tar.gz \
38+
&& tar -xzf Python-${PYTHON_VERSION}.tgz \
39+
&& unzip boost_1_73_0.zip \
40+
&& rm openssl-${OPENSSL_VERSION}.tar.gz Python-${PYTHON_VERSION}.tgz boost_1_73_0.zip
41+
42+
# Open-SSL
43+
WORKDIR /usr/local/src/openssl-${OPENSSL_VERSION}
44+
RUN ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib \
45+
&& make \
46+
&& make install \
47+
&& echo "/usr/local/ssl/lib" > /etc/ld.so.conf.d/openssl-${OPENSSL_VERSION}.conf \
48+
&& ldconfig \
49+
&& export PATH="/usr/local/ssl/bin:${PATH}"
50+
51+
# Python
52+
WORKDIR /usr/local/src/Python-${PYTHON_VERSION}
53+
RUN ./configure --enable-optimizations --with-openssl=/usr/local/ssl \
54+
&& make altinstall \
55+
&& ln -sf /usr/local/bin/python3.10 /usr/bin/python3 \
56+
&& ln -sf /usr/local/bin/python3.10 /usr/local/bin/python3 \
57+
&& ln -sf /usr/local/bin/pip3.10 /usr/bin/pip3 \
58+
&& ln -sf /usr/local/bin/pip3.10 /usr/local/bin/pip3 \
59+
&& python3 -V \
60+
&& python3 -c "import ssl; print(ssl.OPENSSL_VERSION)" \
61+
&& pip3 install cmake==${CMAKE_VERSION} \
62+
&& cmake --version
63+
64+
# Set working directory
65+
WORKDIR /app
66+
67+
# Default command
68+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)