Skip to content

Centos7 CI (push and/or release) #3824

Centos7 CI (push and/or release)

Centos7 CI (push and/or release) #3824

Workflow file for this run

name: Centos7 CI (push and/or release)
on:
release:
types: [created]
push:
branches:
- develop
- dependabot/*
schedule:
- cron: '21 2 * * *'
workflow_call:
inputs:
run-tests:
required: true
type: string
target_branch:
required: true
type: string
env:
GITHUB_TOKEN: ${{ github.token }}
IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }}
IS_PUSH: ${{ github.event_name == 'push' }}
REF: ${{ inputs.target_branch =='' && github.ref_name || inputs.target_branch}}
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
jobs:
build:
name: Build
env:
ORTOOLSDIR: ${{ github.workspace }}/or-tools
runs-on: ubuntu-latest
container: 'antaresrte/rte-antares:centos7-simulator-no-deps'
steps:
- name: Checkout
run: |
git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git -b ${{ env.REF }} .
- name: Install gcc 10
run: |
# update mirrors, official centos7 is deprecated
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
# not a typo, centos-release-scl is needed to install devtoolset-10 but introduce deprecated mirror
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 centos-release-scl
yum install -y devtoolset-11-gcc*
- name: Install cmake 3.28
run: pip3 install cmake==3.28.4
- name: Install VCPKG
# Note: we need to use environment variables instead of workflow variables
# because github messes up path variables when running in container,
# see https://github.com/actions/runner/issues/2058
run: |
git submodule update --init vcpkg && ./vcpkg/bootstrap-vcpkg.sh -disableMetrics
echo "VCPKG_ROOT=$GITHUB_WORKSPACE/vcpkg" >> $GITHUB_ENV
echo "VCPKG_CACHE_DIR=$GITHUB_WORKSPACE/vcpkg_cache" >> $GITHUB_ENV
echo "VCPKG_BINARY_SOURCES=clear;files,$GITHUB_WORKSPACE/vcpkg_cache,readwrite" >> $GITHUB_ENV
- name: Restore vcpkg binary dir from cache
id: cache-vcpkg-binary
# Note: we are stuck with v3, because v4 is not compatible with oracle8 image
uses: actions/cache/restore@v3
with:
path: ${{ env.VCPKG_CACHE_DIR }}
key: vcpkg-cache-centos7-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}
# Allows to restore a cache when deps have only partially changed (like adding a dependency)
restore-keys: vcpkg-cache-centos7-
- name: Init submodule
run: |
git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests
- name: Config OR-Tools URL
run: |
echo "URL_ORTOOLS=https://github.com/rte-france/or-tools-rte/releases/download/$(cat ortools_tag)/ortools_cxx_centos7_static_sirius.zip" >> $GITHUB_ENV
- name: Download OR-Tools
id: ortools
run: |
mkdir -p ${{ env.ORTOOLSDIR }} && cd ${{ env.ORTOOLSDIR }}
wget -q -O ortools.zip ${{ env.URL_ORTOOLS }}
unzip -q ortools.zip
rm ortools.zip
- name: Install gh if needed
if: ${{ env.IS_RELEASE == 'true' }}
run: |
wget https://github.com/cli/cli/releases/download/v2.52.0/gh_2.52.0_linux_amd64.rpm
rpm -i gh_2.52.0_linux_amd64.rpm
gh --version
- name: Configure
run: |
source /opt/rh/devtoolset-11/enable
source /opt/rh/rh-git227/enable
cmake -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DBUILD_TOOLS=ON \
-DBUILD_UI=OFF \
-DCMAKE_PREFIX_PATH=${{ env.ORTOOLSDIR }}/install \
- name: Build
run: |
source /opt/rh/devtoolset-11/enable
source /opt/rh/rh-git227/enable
cmake --build _build --config Release -j$(nproc)
ccache -s
- name: Installer .rpm creation
run: |
cd _build
cpack -G RPM
- name: Solver archive creation
run: |
cd _build
cmake --install . --prefix install
pushd .
cd install/bin
tar czf ../../antares-solver_centos7.tar.gz antares-solver libsirius_solver.so
popd
rm -rf install
- name: .tar.gz creation
run: |
cd _build
cpack -G TGZ
- name: Publish assets
if: ${{ env.IS_RELEASE == 'true' }}
env:
GITHUB_TOKEN: ${{ github.token }}
tag: ${{ github.event.inputs.release_tag }}
run: |
gh release upload "$tag" _build/*.tar.gz _build/*.rpm
- name: Cache vcpkg binary dir
if: always()
id: save-cache-vcpkg-binary
uses: actions/cache/save@v3
with:
path: ${{ env.VCPKG_CACHE_DIR }}
key: vcpkg-cache-centos7-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}