From a6fa16fa47f020ba78a8229c79534ecde5b5317c Mon Sep 17 00:00:00 2001 From: Abdoulbari Zakir Date: Mon, 2 Dec 2024 16:38:04 +0100 Subject: [PATCH] a --- .github/workflows/centos7.yml | 31 +++++++++++++++++++++++++++++++ docker/Dockerfile | 7 +++++++ 2 files changed, 38 insertions(+) diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index 932b3e804f..a6454ebe67 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -43,6 +43,7 @@ jobs: sparse-checkout: | docker/Dockerfile docker/AntaresDeps + src/vcpkg.json ref: ${{ env.REF }} - name: set env variables -- DockerFiles @@ -73,6 +74,22 @@ jobs: cache: false tags: latest + - name: create vcpkg cache dir + run: | + echo "VCPKG_CACHE_DIR=$GITHUB_WORKSPACE/vcpkg_cache" >> $GITHUB_ENV + mkdir -p ${{ env.VCPKG_CACHE_DIR }} + + + - 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: Build the image and Antares run: | docker build \ @@ -87,6 +104,11 @@ jobs: container_id=$(docker create antares:centos7) mkdir archive docker cp $container_id:/workspace/Antares_Simulator/_build/archive/ archive/ + ls ${{ env.VCPKG_CACHE_DIR }} + echo "-----------------" + docker cp $container_id:/workspace/vcpkg-cache ${{ env.VCPKG_CACHE_DIR }} + ls ${{ env.VCPKG_CACHE_DIR }} + echo "-----------------" ls archive docker rm $container_id @@ -99,3 +121,12 @@ jobs: run: | gh release upload "$tag" archive/*.tar.gz archive/*.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') }} + diff --git a/docker/Dockerfile b/docker/Dockerfile index 8d6e30389b..c3e64600f0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,6 +10,12 @@ RUN echo "source /opt/rh/devtoolset-11/enable" >> /etc/bashrc SHELL ["/bin/bash", "--login", "-c"] + +ENV VCPKG_BINARY_SOURCES="clear;files,/workspace/vcpkg_cache,readwrite" +RUN mkdir -p /workspace/vcpkg_cache +ARG VCPKG_CACHE_DIR +COPY ${VCPKG_CACHE_DIR} /workspace/vcpkg_cache/ + ARG BRANCH=develop RUN cd /workspace && \ git clone https://github.com/AntaresSimulatorTeam/Antares_Simulator.git --branch $BRANCH && \ @@ -20,6 +26,7 @@ RUN cd /workspace && \ + RUN ORTOOLS_TAG=$(cat /workspace/Antares_Simulator/ortools_tag) && \ echo "ORTOOLS_TAG=$ORTOOLS_TAG" && \ URL_ORTOOLS=https://github.com/rte-france/or-tools-rte/releases/download/$ORTOOLS_TAG/ortools_cxx_centos7_static_sirius.zip && \