Skip to content

Fix CentOS CI by using docker #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Dec 16, 2024
80 changes: 14 additions & 66 deletions .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,80 +75,28 @@ jobs:
cpp_centos7:
name: Build C++ CentOS7
runs-on: ubuntu-latest
container: 'centos:centos7'
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Update mirrors
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo

- name: Update Dependencies
run: |
yum update -y

- name: Install Dependencies 1
run: |
yum install -y epel-release

- name: Install Dependencies 2
run: |
yum install -y git redhat-lsb-core make wget centos-release-scl scl-utils

- name: Update mirrors again because why not
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo

- name: Install Dependencies 3
run: |
yum install -y devtoolset-9

- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.22.x'

- name: Checkout sources
uses: actions/checkout@v3

- name: Download Boost-release
uses: dsaltares/fetch-gh-release-asset@a40c8b4a0471f9ab81bdf73a010f74cc51476ad4 # v1.1.1
with:
repo: 'ARnDOSrte/Boost'
file: 'boost_1_73_0.zip'
target: 'boost_1_73_0.zip'
token: ${{ secrets.GITHUB_TOKEN }}

- name: Unzip Boost
run: unzip boost_1_73_0.zip

- name: Configure 3rd parties
run: |
source /opt/rh/devtoolset-9/enable
cmake -S $GITHUB_WORKSPACE/metrix-simulator/external -B $GITHUB_WORKSPACE/metrix-simulator/build/external
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Build 3rd parties
- name: Build the Docker image
run: |
cmake --build $GITHUB_WORKSPACE/metrix-simulator/build/external --parallel 2
docker build -t centos7withcmake:latest $GITHUB_WORKSPACE --file $GITHUB_WORKSPACE/.github/workflows/docker/Dockerfile

- name: Configure CMake
- name: Run build steps in Docker container
run: |
source /opt/rh/devtoolset-9/enable
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

- name: Build
run: cmake --build $GITHUB_WORKSPACE/metrix-simulator/build --target install --parallel 2

- name: Tests
run: cd $GITHUB_WORKSPACE/metrix-simulator/build && ctest -j2 --output-on-failure
docker run --name build_container -v $GITHUB_WORKSPACE:/workspace centos7withcmake:latest /bin/bash -c "
source /opt/rh/devtoolset-9/enable &&
cmake -S /workspace/metrix-simulator/external -B /workspace/metrix-simulator/build/external &&
cmake --build /workspace/metrix-simulator/build/external --parallel 2 &&
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 &&
cmake --build /workspace/metrix-simulator/build --target install --parallel 2 &&
cd /workspace/metrix-simulator/build && ctest -j2 --output-on-failure
"

- name: Upload Metrix Simulator archive
if: ${{ github.event_name == 'workflow_dispatch' && inputs.generate_artifacts }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3
with:
name: metrix-simulator-centos7
path: |
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
FROM centos:7 AS builder1

# Set versions
ENV OPENSSL_VERSION="1.1.1w"
ENV CMAKE_VERSION=3.28.4
ENV PYTHON_VERSION=3.10.8
ENV LDFLAGS="-L/usr/local/ssl/lib"
ENV CPPFLAGS="-I/usr/local/ssl/include"

# Downloads
ADD https://github.com/ARnDOSrte/Boost/releases/download/Test_tag_6/boost_1_73_0.zip /usr/local/src/
ADD https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-${OPENSSL_VERSION}.tar.gz /usr/local/src/
ADD https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz /usr/local/src/

# First set of dependencies
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo \
&& yum update -y \
&& yum install -y epel-release \
&& yum install -y git redhat-lsb-core make wget centos-release-scl scl-utils

# Second set of dependencies
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \
&& sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo \
&& sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo \
&& yum install -y devtoolset-9 \
&& yum groupinstall -y "Development Tools" \
&& yum install -y openssl openssl-devel bzip2-devel libffi-devel \
&& yum clean all

# Start on a clean image
FROM builder1 AS builder2

# Unarchive all
WORKDIR /usr/local/src
RUN tar -xzf openssl-${OPENSSL_VERSION}.tar.gz \
&& tar -xzf Python-${PYTHON_VERSION}.tgz \
&& unzip boost_1_73_0.zip \
&& rm openssl-${OPENSSL_VERSION}.tar.gz Python-${PYTHON_VERSION}.tgz boost_1_73_0.zip

# Open-SSL
#RUN wget --max-redirect=0 https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-${OPENSSL_VERSION}.tar.gz \
# && tar -xzf openssl-${OPENSSL_VERSION}.tar.gz
WORKDIR /usr/local/src/openssl-${OPENSSL_VERSION}
RUN ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib \
&& make \
&& make install \
&& echo "/usr/local/ssl/lib" > /etc/ld.so.conf.d/openssl-${OPENSSL_VERSION}.conf \
&& ldconfig \
&& export PATH="/usr/local/ssl/bin:${PATH}"

# Python
#WORKDIR /usr/local/src
#RUN wget --max-redirect=0 https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \
# && tar xzf Python-${PYTHON_VERSION}.tgz
WORKDIR /usr/local/src/Python-${PYTHON_VERSION}
RUN ./configure --enable-optimizations --with-openssl=/usr/local/ssl \
&& make altinstall \
&& ln -sf /usr/local/bin/python3.10 /usr/bin/python3 \
&& ln -sf /usr/local/bin/pip3.10 /usr/bin/pip3 \
&& python3 -V \
&& python3 -c "import ssl; print(ssl.OPENSSL_VERSION)" \
&& pip3 install cmake==${CMAKE_VERSION} \
&& cmake --version

# Set working directory
WORKDIR /app

# Boost
# RUN wget --max-redirect=0 -O boost_1_73_0.zip https://github.com/ARnDOSrte/Boost/releases/download/Test_tag_6/boost_1_73_0.zip \
RUN source /opt/rh/devtoolset-9/enable \
&& groupadd nonroot && useradd -m -g nonroot nonroot

# USER nonroot

# Default command
CMD ["/bin/bash"]
Loading