diff --git a/.github/workflows/centos7-system-deps-build.yml b/.github/workflows/centos7-system-deps-build.yml deleted file mode 100644 index 1dd906c4d9..0000000000 --- a/.github/workflows/centos7-system-deps-build.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Centos7 CI (deps. compilation) - -on: - schedule: - - cron: '21 2 * * 1' - -jobs: - - build: - - runs-on: ubuntu-latest - container: 'centos:7' - - steps: - - - name: Set up Python - run: | - yum update -y - yum install -y python3 python3-pip - - - name: Install libraries - run: | - yum install -y epel-release - yum install -y git redhat-lsb-core gcc gcc-c++ make wget centos-release-scl scl-utils rpm-build - yum install -y devtoolset-9 - yum install -y rh-git227-git - yum install -y unzip libuuid-devel wxGTK3-devel boost-test boost-devel - - - name: Install cmake - run: | - wget https://github.com/Kitware/CMake/releases/download/v3.25.3/cmake-3.25.3-linux-x86_64.tar.gz - tar xvf cmake-3.25.3-linux-x86_64.tar.gz -C / - echo "/cmake-3.25.3-linux-x86_64/bin" >> $GITHUB_PATH - rm cmake-3.25.3-linux-x86_64.tar.gz - - - name: Checkout - run: | - git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git -b $GITHUB_REF_NAME . - - - name: Init submodule - run: | - git submodule update --init --recursive src/antares-deps - - - name: Install dependencies - run: | - pip3 install -r src/tests/examples/requirements.txt - - - name: Configure - run: | - source /opt/rh/devtoolset-9/enable - #git 2.x must be enabled for Coin compilation with CMake ExternalProject_Add - source /opt/rh/rh-git227/enable - cmake -B _build -S src -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON - - - name: Build - run: | - source /opt/rh/devtoolset-9/enable - source /opt/rh/rh-git227/enable - cmake --build _build --config release -j2 - - - name: Installer .rpm creation - run: | - cd _build - cpack -G RPM - - - name: Installer .tar.gz creation - run: | - cd _build - cpack -G TGZ - - - name: Installer archive upload - uses: actions/upload-artifact@v3 - with: - name: antares-centos7-archive - path: _build/*.tar.gz - - - name: Installer rpm upload - uses: actions/upload-artifact@v3 - with: - name: antares-centos7-rpm - path: _build/*.rpm - diff --git a/.github/workflows/centos7.yml b/.github/workflows/centos7.yml index 268f88a70d..61ac1ec3dd 100644 --- a/.github/workflows/centos7.yml +++ b/.github/workflows/centos7.yml @@ -2,10 +2,11 @@ name: Centos7 CI (push and/or release) on: release: - types: [created] + types: [ created ] push: branches: - develop + - dependabot/* schedule: - cron: '21 2 * * *' workflow_call: @@ -28,102 +29,107 @@ 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 11 - run: | - yum install -y centos-release-scl - yum install -y devtoolset-11-gcc* - - - uses: ./.github/workflows/install-cmake-328 - - - name: Init submodule - run: | - git submodule update --init --remote src/antares-deps src/tests/resources/Antares_Simulator_Tests - - - name: Download & extract precompiled deps at root - run: | - ANTARES_DEPS_VERSION=$(cut -d'"' -f4 antares-deps-version.json | grep -Ev '\{|\}') - cd / - wget https://github.com/AntaresSimulatorTeam/antares-deps/releases/download/v${ANTARES_DEPS_VERSION}/rte-antares-deps-centos7-Release.tar.gz - tar -xvf rte-antares-deps-centos7-Release.tar.gz - rm -rf rte-antares-deps-centos7-Release.tar.gz - - - 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 - cmake -B _build -S src \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DDEPS_INSTALL_DIR=/rte-antares-deps-Release \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_TESTING=ON \ - -DBUILD_not_system=OFF \ - -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 + + #sparse checkout -- only needed files + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + sparse-checkout: | + docker + src/vcpkg.json + ref: ${{ env.REF }} + + - name: set env variables -- DockerFiles + run: | + echo "DOCKERFILE=$(pwd)/docker/Dockerfile" >> $GITHUB_ENV + echo "DOCKERDIR=$(pwd)/docker" >> $GITHUB_ENV + + + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v45 + with: + files: | + docker/AntaresDeps + + - name: Docker file push + id: docker_push + + if: steps.changed-files.outputs.any_changed == 'true' + uses: elgohr/Publish-Docker-Github-Action@main + with: + name: antaresrte/antaressystemdeps + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + workdir: ${{ env.DOCKERDIR }} + dockerfile: ${{ env.DOCKERDIR }}/AntaresDeps + cache: false + tags: latest + + - name: create vcpkg cache dir + run: | + echo "VCPKG_CACHE_DIR=$GITHUB_WORKSPACE/vcpkg_cache" >> $GITHUB_ENV + mkdir -p ${{ github.workspace }}/vcpkg_cache + + + - name: Restore vcpkg binary dir from cache + id: cache-vcpkg-binary + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/vcpkg_cache + 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: Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: centos7-on-${{ runner.os }} + + + - name: Build the image and Antares + run: | + ls -latr .ccache/ && \ + docker build \ + -t antares:centos7 \ + --build-arg="BRANCH=${{ env.REF }}" \ + --build-arg="NPROC=$(nproc)" \ + --build-arg="VCPKG_CACHE_DIR=./vcpkg_cache" \ + --build-arg CCACHE_DIR=./.ccache \ + --build-arg CCACHE_KEY=centos7-on-${{ runner.os }} \ + -f ${{ env.DOCKERFILE }} . + + + - name: create a container without starting it && retrieve the .tgz + run: | + container_id=$(docker create antares:centos7) + docker cp $container_id:/workspace/Antares_Simulator/_build/archive archive + docker cp $container_id:/workspace/vcpkg_cache ${{ env.VCPKG_CACHE_DIR }} + docker cp $container_id:/workspace/.ccache/. .ccache + ls -la .ccache + docker rm $container_id + + + - name: Publish assets + if: ${{ env.IS_RELEASE == 'true' }} + env: + GITHUB_TOKEN: ${{ github.token }} + tag: ${{ github.event.inputs.release_tag }} + 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@v4 + with: + path: ${{ github.workspace }}/vcpkg_cache + key: vcpkg-cache-centos7-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }} diff --git a/.github/workflows/oracle8.yml b/.github/workflows/oracle8.yml index ac971bb998..e026b4246a 100644 --- a/.github/workflows/oracle8.yml +++ b/.github/workflows/oracle8.yml @@ -25,7 +25,6 @@ env: IS_PUSH: ${{ github.event_name == 'push' }} REF: ${{ inputs.target_branch =='' && github.ref_name || inputs.target_branch}} - jobs: build: @@ -50,7 +49,27 @@ jobs: - name: Checkout run: | - git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git -b ${{ env.REF }} . + git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git -b ${{ env.REF }} . + git config --global safe.directory '*' + + - 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 + uses: actions/cache/restore@v4 + with: + path: ${{ env.VCPKG_CACHE_DIR }} + key: vcpkg-cache-oracle8-${{ 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-oracle8- - name: Config OR-Tools URL run: | @@ -65,9 +84,7 @@ jobs: rm ortools.zip - name: Init submodule - run: | - git config --global safe.directory '*' - git submodule update --init --remote src/antares-deps src/tests/resources/Antares_Simulator_Tests + run: git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests - name: Install dependencies run: | @@ -82,13 +99,15 @@ jobs: - name: Configure run: | - source /opt/rh/gcc-toolset-11/enable - cmake -B _build -S src \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_TESTING=OFF \ - -DBUILD_TOOLS=ON \ - -DBUILD_UI=OFF \ - -DCMAKE_PREFIX_PATH=${{ env.ORTOOLS_DIR }}/install + source /opt/rh/gcc-toolset-11/enable + cmake -B _build -S src \ + -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.ORTOOLS_DIR }}/install - name: Build run: | @@ -112,7 +131,7 @@ jobs: cmake --install . --prefix install pushd . cd install/bin - tar czf ../../antares-solver_oracle8.tar.gz antares-*-solver libsirius_solver.so + tar czf ../../antares-solver_oracle8.tar.gz antares-solver libsirius_solver.so popd rm -rf install @@ -140,3 +159,11 @@ jobs: 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@v4 + with: + path: ${{ env.VCPKG_CACHE_DIR }} + key: vcpkg-cache-oracle8-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}