Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/feature/vcpkg-linux…
Browse files Browse the repository at this point in the history
…' into feature/expose-api_vcpkg

# Conflicts:
#	.github/workflows/centos7.yml
#	.github/workflows/oracle8.yml
#	.github/workflows/ubuntu.yml
#	.github/workflows/windows-vcpkg.yml
#	src/packaging/Config.cmake.in
  • Loading branch information
JasonMarechal25 committed May 27, 2024
2 parents da2200a + 5bc828e commit 42df761
Show file tree
Hide file tree
Showing 16 changed files with 526 additions and 431 deletions.
61 changes: 45 additions & 16 deletions .github/workflows/centos7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,28 @@ jobs:
yum install -y centos-release-scl
yum install -y devtoolset-10-gcc*
- uses: ./.github/workflows/install-cmake-328
- 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: |
Expand Down Expand Up @@ -80,20 +101,22 @@ jobs:
dnf -y config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
dnf -y install gh
- name: Configure
run: |
source /opt/rh/devtoolset-10/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 \
source /opt/rh/devtoolset-10/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 \
-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: |
Expand Down Expand Up @@ -123,12 +146,12 @@ jobs:
cpack -G TGZ
- name: Installer TGZ push
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: _build/*.tar.gz

- name: Installer RPM push
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: _build/*.rpm

Expand All @@ -140,4 +163,10 @@ jobs:
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') }}
52 changes: 40 additions & 12 deletions .github/workflows/oracle8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ env:
IS_PUSH: ${{ github.event_name == 'push' }}
REF: ${{ inputs.target_branch =='' && github.ref_name || inputs.target_branch}}


jobs:

build:
Expand All @@ -50,7 +49,28 @@ 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
# 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-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: |
Expand All @@ -65,9 +85,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/antares-deps src/tests/resources/Antares_Simulator_Tests

- name: Install dependencies
run: |
Expand All @@ -82,13 +100,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: |
Expand Down Expand Up @@ -138,3 +158,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@v3
with:
path: ${{ env.VCPKG_CACHE_DIR }}
key: vcpkg-cache-oracle8-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}
24 changes: 24 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,26 @@ jobs:
env:
SONAR_SERVER_URL: "https://sonarcloud.io"
ORTOOLS_DIR: ${{ github.workspace }}/or-tools
# Caching strategy of VCPKG dependencies
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/vcpkg_cache,readwrite"

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Install VCPKG
run: git submodule update --init vcpkg && ./vcpkg/bootstrap-vcpkg.sh -disableMetrics

- 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-ubuntu-${{ 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-ubuntu-

- name: Config OR-Tools URL
run: |
echo "ORTOOLS_URL=https://github.com/rte-france/or-tools/releases/download/$(cat ortools_tag)/ortools_cxx_ubuntu-20.04_static_sirius.zip" >> $GITHUB_ENV
Expand Down Expand Up @@ -81,6 +95,8 @@ jobs:
-DCMAKE_C_COMPILER=/usr/bin/gcc-10 \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
-DDEPS_INSTALL_DIR=./rte-antares-deps-Debug \
-DCODE_COVERAGE=ON \
-DCMAKE_BUILD_TYPE=Debug \
Expand Down Expand Up @@ -109,3 +125,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}"

- 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-ubuntu-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}
98 changes: 39 additions & 59 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ env:
RUN_SIMPLE_TESTS: ${{ github.event_name == 'push' || inputs.run-tests == 'true' }}
RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }}
REF: ${{ inputs.target_branch =='' && github.ref || inputs.target_branch}}
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
vcpkgPackages: yaml-cpp antlr4 boost-test
triplet: x64-linux
WX_CONFIG: /usr/bin/wx-config

jobs:

Expand All @@ -40,6 +36,8 @@ jobs:
env:
ORTOOLS_DIR: ${{ github.workspace }}/or-tools
os: ubuntu-20.04
# Caching strategy of VCPKG dependencies
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/vcpkg_cache,readwrite"

runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, '[skip ci]')"
Expand All @@ -49,51 +47,28 @@ jobs:
with:
ref: ${{ env.REF }}

- name: Install VCPKG
run: git submodule update --init vcpkg && ./vcpkg/bootstrap-vcpkg.sh -disableMetrics

- 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-ubuntu-${{ 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-ubuntu-

- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ env.os }}


- name : Init VCPKG submodule
run: |
git submodule update --init vcpkg
# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v4
with:
# The first path is the location of vcpkg (it contains the vcpkg executable and data files).
# The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages.
path: |
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'vcpkg_manifest/vcpkg.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ env.triplet }}
- name: Install libraries
run: |
sudo apt-get update
sudo apt-get install uuid-dev libwxgtk3.0-gtk3-dev
sudo apt-get install g++-10 gcc-10
- name: export wxWidgets script
shell: bash
run: |
export WX_CONFIG=${{env.WX_CONFIG}}
- name : Install deps with VCPKG
run: |
cd vcpkg
./bootstrap-vcpkg.sh
vcpkg install ${{env.vcpkgPackages}} --triplet ${{env.triplet}}
rm -rf buildtrees packages downloads
shell: bash
sudo apt-get update
sudo apt-get install uuid-dev libwxgtk3.0-gtk3-dev
sudo apt-get install g++-10 gcc-10
- name: Read antares-deps version
id: antares-deps-version
Expand Down Expand Up @@ -130,31 +105,28 @@ jobs:
run: |
git submodule update --init src/antares-deps
git submodule update --init --remote --recursive src/tests/resources/Antares_Simulator_Tests

- name: Configure
run: |
cmake -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DVCPKG_ROOT="${{env.VCPKG_ROOT}}" \
-DVCPKG_TARGET_TRIPLET=${{ env.triplet }} \
-DCMAKE_C_COMPILER=/usr/bin/gcc-10 \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
-DDEPS_INSTALL_DIR=${{github.workspace}}/rte-antares-deps-Release \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DBUILD_not_system=OFF \
-DBUILD_TOOLS=ON \
-DCMAKE_PREFIX_PATH=${{ env.ORTOOLS_DIR }}/install \
-DPython3_EXECUTABLE="${{ env.Python3_ROOT_DIR }}/bin/python"
cmake -B _build -S src \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=/usr/bin/gcc-10 \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux-release \
-DDEPS_INSTALL_DIR=${{github.workspace}}/rte-antares-deps-Release \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DBUILD_not_system=OFF \
-DBUILD_TOOLS=ON \
-DCMAKE_PREFIX_PATH=${{ env.ORTOOLS_DIR }}/install \
-DPython3_EXECUTABLE="${{ env.Python3_ROOT_DIR }}/bin/python"
- name: Build
run: |
cmake --build _build -j$(nproc)
# simtest
- name: Read simtest version
id: simtest-version
Expand Down Expand Up @@ -355,3 +327,11 @@ jobs:
tag: ${{ github.event.inputs.release_tag }}
run: |
gh release upload "$tag" _build/*.tar.gz _build/*.deb
- 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-ubuntu-${{ hashFiles('src/vcpkg.json', '.git/modules/vcpkg/HEAD') }}
Loading

0 comments on commit 42df761

Please sign in to comment.