From 0e03f82adc028f4f87dae707ed996f73c40c9737 Mon Sep 17 00:00:00 2001 From: Jason Marechal Date: Thu, 6 Jun 2024 14:35:30 +0200 Subject: [PATCH] Fuse build and release --- .github/workflows/build_centos7.yml | 141 +++++++++++++++++++++- .github/workflows/build_ubuntu.yml | 5 +- .github/workflows/build_windows.yml | 175 +++++++++++++++++++++------- 3 files changed, 272 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build_centos7.yml b/.github/workflows/build_centos7.yml index 3f3bd7b11..97a6df42c 100644 --- a/.github/workflows/build_centos7.yml +++ b/.github/workflows/build_centos7.yml @@ -89,6 +89,10 @@ jobs: XPRS_LIB_Path_CONTAINER: ${GITHUB_WORKSPACE}/xpress/lib VCPKG_ROOT: ${{ github.workspace }}/vcpkg + outputs: + TGZ_NAME: ${{ steps.export_output.outputs.TGZ_NAME }} + SINGLE_FILE_NAME: ${{ steps.export_output.outputs.SINGLE_FILE_NAME }} + steps: - run: | source /opt/rh/devtoolset-10/enable @@ -163,17 +167,26 @@ jobs: pip3 install -r requirements-tests.txt pip3 install -r requirements-ui.txt + - run: | + mkdir -p ${{ github.workspace }}/vcpkg_cache + - name: vcpkg install run: | pushd vcpkg git fetch --unshallow - ./bootstrap-vcpkg.sh - popd - vcpkg/vcpkg install + ./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: Configure run: | - [[ ${{ matrix.xprs.value }} == "XPRESS-ON" ]] && XPRESS_VALUE="ON" || XPRESS_VALUE="OFF" source /opt/rh/devtoolset-10/enable cmake -B _build -S . \ -DDEPS_INSTALL_DIR=rte-antares-deps-Release \ @@ -181,7 +194,6 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=_install \ -DBUILD_UI=ON \ - -DXPRESS=${{ env.XPRESS_VALUE }} \ -DALLOW_RUN_AS_ROOT=ON \ -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake @@ -189,6 +201,14 @@ jobs: run: | cmake --build _build --config Release -j$(nproc) + - 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') }} + - name: Running unit tests timeout-minutes: 120 shell: bash @@ -198,3 +218,114 @@ jobs: export XPRESS=${{ env.XPRESS_CONTAINER }} cd _build ctest -C Release --output-on-failure -L "unit|benders|lpnamer|medium" + + ####################### + - name: Install + run: | + cd _build + cmake --install . + + - name: set name variables + id: single_file_name + shell: bash + run: | + VERSION=${{steps.antares-xpansion-version.outputs.result}} + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - id: create-single-file + name: Single file .tar.gz creation + uses: ./.github/workflows/single-file-creation-tgz + with: + antares-xpansion-version: ${{env.VERSION}} + + - name: Installer .tar.gz creation + run: | + cd _build + export FILE_NAME="antaresXpansion-${{env.VERSION}}-CentOS-7.9.2009" + cpack -G TGZ -D CPACK_PACKAGE_FILE_NAME=$FILE_NAME + #Need to differentiate between xpress/no_xpress files + #Cpack command line doesn't seem to care about -P or -R options + echo "TGZ_NAME=$FILE_NAME.tar.gz" >> $GITHUB_ENV + + - name: Upload .tar.gz + uses: actions/upload-artifact@v4 + with: + name: ${{env.TGZ_NAME}} + path: _build/${{env.TGZ_NAME}} + + - name: Upload single file + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.create-single-file.outputs.archive-name }} + path: ${{ steps.create-single-file.outputs.archive-path }} + + - name: export asset name in output + id: export_output + run: | + echo "TGZ_NAME=${{env.TGZ_NAME}}" >> $GITHUB_OUTPUT + echo "SINGLE_FILE_NAME=${{ steps.create-single-file.outputs.archive-name }}" >> $GITHUB_OUTPUT + + ####################### + userguide: + if: github.event_name == 'release' && github.event.action == 'created' + runs-on: ubuntu-latest + outputs: + pdf-name: ${{ steps.create-user-guide.outputs.pdf-name }} + + steps: + - uses: actions/checkout@v4 + + - name: Read antares-xpansion version + id: antares-xpansion-version + uses: ./.github/actions/read-json-value + with: + path: 'antares-version.json' + key: 'antares_xpansion_version' + + - id: create-user-guide + name: user guide pdf creation + uses: ./.github/workflows/generate-userguide-pdf + with: + antares-xpansion-version: ${{steps.antares-xpansion-version.outputs.result}} + + - name: user guide upload + id: userguide_upload + uses: actions/upload-artifact@v4 + with: + name: user-guide + path: ${{ steps.create-user-guide.outputs.pdf-path }} + + release: + runs-on: ubuntu-latest + needs: [ build, userguide ] + if: github.event_name == 'release' && github.event.action == 'created' + steps: + - name: Download userguide + uses: actions/download-artifact@v4 + with: + name: user-guide + path: docs/ + + - name: Download build assets + uses: actions/download-artifact@v4 + with: + name: ${{needs.build.outputs.TGZ_NAME}} + path: _build/ + + - name: Download build assets single file + uses: actions/download-artifact@v4 + with: + name: ${{needs.build.outputs.SINGLE_FILE_NAME}} + path: . + + - name: Get release + id: get_release + uses: bruceadams/get-release@main + + - name: Upload Release Asset + env: + GH_REPO: ${{ github.repository }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload --repo ${{env.GH_REPO}} ${{ steps.get_release.outputs.tag_name }} _build/${{needs.build.outputs.TGZ_NAME}} + gh release upload --repo ${{env.GH_REPO}} ${{ steps.get_release.outputs.tag_name }} ${{needs.build.outputs.SINGLE_FILE_NAME}} \ No newline at end of file diff --git a/.github/workflows/build_ubuntu.yml b/.github/workflows/build_ubuntu.yml index fa50f075b..bc7ada3f7 100644 --- a/.github/workflows/build_ubuntu.yml +++ b/.github/workflows/build_ubuntu.yml @@ -123,7 +123,7 @@ jobs: run: | pushd vcpkg git fetch --unshallow - ./bootstrap-vcpkg.sh -disableMetrics + ./bootstrap-vcpkg.sh --disableMetrics - name: Restore vcpkg binary dir from cache id: cache-vcpkg-binary @@ -137,7 +137,6 @@ jobs: - name: Configure shell: bash run: | - [[ ${{ matrix.xprs.value }} == "XPRESS-ON" ]] && XPRESS_VALUE="ON" || XPRESS_VALUE="OFF" cmake -B _build -S . \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER=/usr/bin/gcc-10 \ @@ -148,7 +147,6 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=_install \ -DBUILD_UI=ON \ - -DXPRESS=${{ env.XPRESS_VALUE }} \ -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build @@ -171,6 +169,7 @@ jobs: ####################### - name: Install + if: github.event_name == 'release' && github.event.action == 'created' run: | cd _build cmake --install . diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index a41422727..61d45d190 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -15,7 +15,7 @@ env: GITHUB_TOKEN: ${{ github.token }} jobs: - windows: + build: runs-on: ${{ matrix.os }} if: "!contains(github.event.head_commit.message, '[skip ci]')" strategy: @@ -33,6 +33,10 @@ jobs: # Indicates the location of the vcpkg as a Git submodule of the project repository. VCPKG_ROOT: ${{ github.workspace }}/vcpkg + outputs: + zip_name: ${{ steps.zip_name.outputs.zip_name }} + singlefile_name: ${{steps.zip_name.outputs.singlefile_name}} + steps: - uses: actions/checkout@v4 with: @@ -47,12 +51,6 @@ jobs: ref: ${{matrix.xprs.ref}} token: ${{ secrets.AS_TOKEN }} - - name: Get release - if: github.event_name == 'release' && github.event.action == 'created' - id: get_release - uses: - bruceadams/get-release@v1.3.2 - - name: Set up Python uses: actions/setup-python@v5 with: @@ -60,23 +58,6 @@ jobs: cache: 'pip' cache-dependency-path: requirements*.txt - # 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.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }} - - name: Install dependencies run: | python -m pip install --upgrade pip @@ -103,16 +84,22 @@ jobs: path: 'antares-version.json' key: 'antares_deps_version' - - name: Install deps with VCPKG + - name: vcpkg install + shell: bash run: | - cd vcpkg + mkdir -p ${{ github.workspace }}/vcpkg_cache + pushd vcpkg git fetch --unshallow - ./bootstrap-vcpkg.sh - vcpkg install --triplet ${{matrix.triplet}} - rm -rf buildtrees - rm -rf packages - rm -rf downloads - shell: bash + ./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: Compile tbb uses: ./.github/workflows/compile-tbb @@ -126,20 +113,21 @@ jobs: antares-version: ${{steps.antares-version.outputs.result}} os: ${{matrix.os}} - - name: Expand xpress value in env - #I can't seem to expand the variable in the cmake command line so export it in env - shell: bash - run: | - [[ ${{ matrix.xprs.value }} == "XPRESS-ON" ]] && XPRESS_VALUE="ON" || XPRESS_VALUE="OFF" - echo "XPRESS_VALUE=$XPRESS_VALUE" >> $GITHUB_ENV - - name: Configure run: | $pwd=Get-Location - cmake -B _build -S . -DDEPS_INSTALL_DIR=rte-antares-deps-Release -DCMAKE_PREFIX_PATH="$pwd\rte-antares-${{steps.antares-version.outputs.result}}-installer-64bits" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} -DCMAKE_INSTALL_PREFIX=_install -DBUILD_UI=ON -DXPRESS=${{ env.XPRESS_VALUE }} + cmake -B _build -S . -DDEPS_INSTALL_DIR=rte-antares-deps-Release -DCMAKE_PREFIX_PATH="$pwd\rte-antares-${{steps.antares-version.outputs.result}}-installer-64bits" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} -DCMAKE_INSTALL_PREFIX=_install -DBUILD_UI=ON - name: Build run: | cmake --build _build --config Release -j4 + + - 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') }} - name: Running unit tests timeout-minutes: 120 @@ -149,4 +137,109 @@ jobs: set PATH=%PATH%;${{ env.XPRESS }} set XPRESSDIR=${{ env.XPRESSDIR }} cd _build - ctest -C Release --output-on-failure -L "medium|unit|benders|lpnamer" \ No newline at end of file + ctest -C Release --output-on-failure -L "medium|unit|benders|lpnamer" + ############## + - name: Create installer .zip + shell: bash + run: | + cd _build + cpack -G ZIP + export ZIP_NAME=$(ls *.zip) + echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV + + - name: set name variables + id: single_file_name + shell: bash + run: | + [[ ${{ matrix.xprs }} == "XPRESS-ON" ]] && XPRESS_VALUE="ON" || XPRESS_VALUE="OFF" + XPRS=${{ env.XPRESS_VALUE }} + [ $XPRS == "ON" ] && WITH_XPRS="-xpress" || WITH_XPRS="" + VERSION=${{steps.antares-xpansion-version.outputs.result}}${WITH_XPRS} + echo "VERSION_WITH_XPRESS=$VERSION" + echo "VERSION_WITH_XPRESS=$VERSION" >> $GITHUB_ENV + + - name: Upload installer + uses: actions/upload-artifact@v4 + with: + name: ${{env.ZIP_NAME}} + path: _build/${{env.ZIP_NAME}} + + - name: Create single file .zip + id: create-single-file + uses: ./.github/workflows/single-file-creation-zip + with: + antares-xpansion-version: ${{env.VERSION_WITH_XPRESS}} + + - name: Upload single file + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.create-single-file.outputs.archive-name }} + path: ${{ steps.create-single-file.outputs.archive-path }} + + - id: zip_name + shell: bash + run: | + echo "zip_name=${{env.ZIP_NAME}}" >> "$GITHUB_OUTPUT" + echo "singlefile_name=${{steps.create-single-file.outputs.archive-name}}" >> "$GITHUB_OUTPUT" + userguide: + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'created' + outputs: + pdf-name: ${{ steps.create-user-guide.outputs.pdf-name }} + + steps: + - uses: actions/checkout@v4 + + - name: Read antares-xpansion version + id: antares-xpansion-version + uses: ./.github/actions/read-json-value + with: + path: 'antares-version.json' + key: 'antares_xpansion_version' + + - id: create-user-guide + name: user guide pdf creation + uses: ./.github/workflows/generate-userguide-pdf + with: + antares-xpansion-version: ${{steps.antares-xpansion-version.outputs.result}} + + - name: user guide upload + id: userguide_upload + uses: actions/upload-artifact@v4 + with: + name: user-guide + path: ${{ steps.create-user-guide.outputs.pdf-path }} + + upload_asset_to_release: + if: github.event_name == 'release' && github.event.action == 'created' + runs-on: ubuntu-latest + needs: [build, userguide] + env: + ZIP_NAME: ${{needs.build.outputs.zip_name}} + SINGLEFILE_NAME: ${{needs.build.outputs.singlefile_name}} + steps: + - name: Get release + id: get_release + uses: bruceadams/get-release@main + + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: ${{env.ZIP_NAME}} + path: . + + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: ${{env.SINGLEFILE_NAME}} + path: . + + - name: Upload Release Asset + env: + GH_REPO: ${{ github.repository }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload --repo ${{env.GH_REPO}} ${{ steps.get_release.outputs.tag_name }} ${{env.ZIP_NAME}} + gh release upload --repo ${{env.GH_REPO}} ${{ steps.get_release.outputs.tag_name }} ${{env.SINGLEFILE_NAME}} + + ######################## \ No newline at end of file