Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d8408e5654f837ccab89614c75109e69524bf79c
[simgrid.git] / .github / workflows / jarfile.yml
1 name: Jar build
2
3 on:
4   workflow_dispatch:
5   schedule:
6   # * is a special character in YAML so you have to quote this string
7       - cron:  '0 18 * * 0'
8 jobs:
9   build:
10     runs-on: ${{ matrix.config.os }}-latest
11     strategy:
12         matrix:
13           config:
14           - { name: "Windows MingW", os: windows, cc: "gcc", cxx: "g++", generator: "MinGW Makefiles", cmake_extra_options: '-Denable_lto=OFF -DCMAKE_PREFIX_PATH="C:/Program Files/Eigen3/"' }
15           - { name: "Ubuntu gcc", os: ubuntu, cc: "gcc", cxx: "g++", generator: "Unix Makefiles", cmake_extra_options: "-DLTO_EXTRA_FLAG=auto" }
16           - { name: "MacOS clang", os: macos, cc: "clang", cxx: "clang++", generator: "Unix Makefiles", cmake_extra_options: "-DLTO_EXTRA_FLAG=auto" }
17     steps:
18     - uses: actions/checkout@v2
19      # install dependencies
20     - name: Init options
21       run: |
22           echo "CC=${{ matrix.config.cc }}"   >> $GITHUB_ENV
23           echo "CXX=${{ matrix.config.cxx }}" >> GITHUB_ENV
24     - name: Install boost and eigen on ubuntu
25       if: matrix.config.os == 'ubuntu'
26       run: sudo apt-get update && sudo apt-get install -yq libboost-dev libeigen3-dev
27     - name: Install boost and eigen on macos
28       if: matrix.config.os == 'macos'
29       run: brew install boost eigen
30     - name: Install boost, eigen, and gcc on windows
31       if: matrix.config.os == 'windows'
32       run: |
33         iwr -useb get.scoop.sh -outfile 'install.ps1'
34         .\install.ps1 -RunAsAdmin
35         scoop install gcc --global
36         If ((Test-Path "C:\hostedtoolcache\windows\Boost") -eq $False){
37           # Use the boost-1.72.0-win32-msvc14.1-x86_64.tar.gz for Windows 2016
38           $url = "https://github.com/actions/boost-versions/releases/download/1.72.0-20200608.4/boost-1.72.0-win32-msvc14.2-x86_64.tar.gz"
39           (New-Object System.Net.WebClient).DownloadFile($url, "$env:TEMP\boost.tar.gz")
40           7z.exe x "$env:TEMP\boost.tar.gz" -o"$env:TEMP\boostArchive" -y | Out-Null
41           7z.exe x "$env:TEMP\boostArchive" -o"$env:TEMP\boost" -y | Out-Null
42           Push-Location -Path "$env:TEMP\boost"
43           Invoke-Expression .\setup.ps1
44         }
45         echo "BOOST_ROOT=C:\hostedtoolcache\windows\Boost\1.72.0\x86_64" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
46         echo "BOOST_INCLUDEDIR=C:\hostedtoolcache\windows\Boost\1.72.0\x86_64\boost\include" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
47         echo "BOOST_LIBRARYDIR=C:\hostedtoolcache\windows\Boost\1.72.0\x86_64\lib" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
48         $url = "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz"
49         (New-Object System.Net.WebClient).DownloadFile($url, "$env:TEMP\eigen.tar.gz")
50         Push-Location -Path "$env:TEMP"
51         cmake -E tar zxf "$env:TEMP\eigen.tar.gz"
52         mkdir "$env:TEMP\eigen-3.4.0\build"
53         cd "$env:TEMP\eigen-3.4.0\build"
54         cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="C:\Program Files\Eigen3" ..
55         cmake --build . --target install
56     - name: Build and test jar with Cmake
57       run: |
58           mkdir build
59           cd build
60           cmake -Denable_documentation=OFF -Denable_java=ON -Denable_msg=ON -Denable_lib_in_jar=ON -Dminimal-bindings=ON -Denable_compile_optimizations=ON -Denable_smpi=OFF ${{ matrix.config.cmake_extra_options }} -G "${{ matrix.config.generator }}" ..
61           make -j2 simgrid-java_jar java-all
62           ctest -R java --output-on-failure
63     - name: Upload jar
64       uses: actions/upload-artifact@v2
65       with:
66           name: jar-${{ matrix.config.os }}
67           path: build/simgrid.jar
68     - name: Create the failure Message
69       if: ${{ failure() }}
70       run: |
71         echo "{\"attachments\": [{\"color\": \"#FF0000\", \"text\":\"Failure when building JAR file on ${{ matrix.config.name }}! See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \"}]}" > mattermost.json
72     - uses: mattermost/action-mattermost-notify@master
73       if: ${{ failure() }}
74       env:
75         MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
76         MATTERMOST_CHANNEL: ${{ secrets.MATTERMOST_CHANNEL}}
77   create_jar:
78     needs: build
79     runs-on: ubuntu-latest
80     steps:
81       - uses: actions/checkout@v2
82       - name: Download all jars from ubuntu
83         uses: actions/download-artifact@v2
84       - name: Build final jar
85         run: |
86            patch=$(grep -r set\(SIMGRID_VERSION_PATCH ./CMakeLists.txt | sed 's/.*"\([[:digit:]]\+\)".*/\1/g')
87            major=$(grep -r set\(SIMGRID_VERSION_MAJOR ./CMakeLists.txt | sed 's/.*"\([[:digit:]]\+\)".*/\1/g')
88            minor=$(grep -r set\(SIMGRID_VERSION_MINOR ./CMakeLists.txt | sed 's/.*"\([[:digit:]]\+\)".*/\1/g')
89            if [ $patch -ne 0 ]; then
90              version="$major.$minor.$patch"
91            else
92              version="$major.$minor"
93            fi
94            mkdir content
95            cd content
96            for j in  ubuntu macos windows ; do unzip -n ../jar-$j/simgrid.jar ; done
97            strip NATIVE/*/*/*.so
98            x86_64-linux-gnu-strip NATIVE/*/*/lib*dll
99            zip -r ../simgrid-${version}.jar *
100       - name: Upload jar
101         uses: actions/upload-artifact@v2
102         with:
103           name: jar-final
104           path: simgrid-*.jar
105       - name: cleanup artifacts
106         uses: geekyeggo/delete-artifact@v1
107         with:
108           name: |
109             jar-ubuntu
110             jar-windows
111             jar-macos
112       - name: Create the failure Message
113         if: ${{ failure() }}
114         run: |
115           echo "{\"attachments\": [{\"color\": \"#FF0000\", \"text\":\"Failure when assembling JAR file ! See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \"}]}" > mattermost.json
116       - name: Create the success Message
117         if: ${{ success() }}
118         run: |
119           echo "{\"attachments\": [{\"color\": \"#00FF00\", \"text\":\"JAR file built successfully ! You can get it on: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \"}]}" > mattermost.json
120       - uses: mattermost/action-mattermost-notify@master
121         env:
122           MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
123           MATTERMOST_CHANNEL: ${{ secrets.MATTERMOST_CHANNEL}}