@@ -18,88 +18,121 @@ jobs:
1818 - uses : actions/checkout@v4
1919 with :
2020 fetch-depth : 0
21- - name : Install prereqs
21+
22+ - name : Install system prerequisites
2223 run : |
2324 sudo apt-get update
24- sudo apt-get install -y libgraphviz-dev libboost-all-dev nlohmann-json3-dev pybind11-dev
25+ sudo apt-get install -y \
26+ libgraphviz-dev \
27+ libboost-all-dev \
28+ nlohmann-json3-dev \
29+ pybind11-dev \
30+ lcov \
31+ gcovr \
32+ python3-breathe \
33+ python3-sphinx \
34+ python3-sphinx-rtd-theme \
35+ python3-sphinx-copybutton \
36+ python3-sphinx-tabs \
37+ doxygen
38+
39+ - name : Cache SimGrid
40+ uses : actions/cache@v4
41+ id : cache-simgrid
42+ with :
43+ path : /opt/simgrid
44+ key : ${{ runner.os }}-simgrid-python-v2
2545
2646 - name : Install SimGrid
47+ if : steps.cache-simgrid.outputs.cache-hit != 'true'
2748 run : |
28- git clone https://framagit.org/simgrid/simgrid.git
49+ git clone --depth 1 https://framagit.org/simgrid/simgrid.git
2950 cd simgrid
30- mkdir build
31- cd build
32- cmake -Denable_smpi=OFF -Denable_model-checking=OFF ..
33- make -j4
34- sudo make install
51+ cmake -B build -Denable_smpi=OFF -Denable_model-checking=OFF -Denable_python=ON -DCMAKE_INSTALL_PREFIX=/opt/simgrid
52+ cmake --build build -j$(nproc)
53+ sudo cmake --install build
54+
55+ - name : Cache FSMod
56+ uses : actions/cache@v4
57+ id : cache-fsmod
58+ with :
59+ path : /opt/fsmod
60+ key : ${{ runner.os }}-fsmod-python-v2
3561
3662 - name : Install FSMod
63+ if : steps.cache-fsmod.outputs.cache-hit != 'true'
3764 run : |
38- git clone https://github.com/simgrid/file-system-module.git
65+ git clone --depth 1 https://github.com/simgrid/file-system-module.git
3966 cd file-system-module
40- mkdir build
41- cd build
42- cmake .. -Denable_lib_in_jar=OFF -Denable_sthread=OFF
43- make -j4
44- sudo make install
67+ cmake -B build -Denable_lib_in_jar=OFF -Denable_sthread=OFF -Denable_python=ON -DCMAKE_INSTALL_PREFIX=/opt/fsmod -DCMAKE_PREFIX_PATH=/opt/simgrid
68+ cmake --build build -j$(nproc)
69+ sudo cmake --install build
4570
46- - name : Install Google Tests
71+ - name : Cache Google Test
72+ uses : actions/cache@v4
73+ id : cache-gtest
74+ with :
75+ path : /opt/gtest
76+ key : ${{ runner.os }}-gtest-v1
77+
78+ - name : Install Google Test
79+ if : steps.cache-gtest.outputs.cache-hit != 'true'
4780 run : |
48- wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
81+ wget -q https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
4982 tar xf release-1.11.0.tar.gz
5083 cd googletest-release-1.11.0
51- cmake .
52- make -j4
53- sudo make install
84+ cmake -B build -DCMAKE_INSTALL_PREFIX=/opt/gtest
85+ cmake --build build -j$(nproc)
86+ sudo cmake -- install build
5487
55- - name : Install lcov and gcovr
88+ - name : Build and test with coverage
5689 run : |
57- sudo apt-get -y install lcov gcovr
90+ # Dynamically find SimGrid Python path
91+ SIMGRID_PYTHON_PATH=$(find /opt/simgrid/lib -type d -path "*/python*/site-packages" 2>/dev/null | head -1)
92+ if [ -z "$SIMGRID_PYTHON_PATH" ]; then
93+ SIMGRID_PYTHON_PATH=$(find /opt/simgrid/lib -type d -path "*/python*/dist-packages" 2>/dev/null | head -1)
94+ fi
95+ echo "Using SimGrid Python path: $SIMGRID_PYTHON_PATH"
5896
59- - name : Run tests, compute coverage
60- env :
61- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
62- run : |
63- git clone https://github.com/simgrid/DTLMod.git
64- cd DTLMod
65- mkdir build
66- cd build
67- cmake ..
68- make -j4
69- sudo make install
70- make -j4 unit_tests
71- ./unit_tests
72- export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
73- export PYTHONPATH="/usr/local/lib/python3.12/dist-packages/"
74- cd test/python
75- python ./unit_tests_python.py
76- cd ../..
77- lcov --keep-going --directory . --capture --output-file coverage.info
78- lcov --remove coverage.info '*/test/*' '*/include/*'
79- bash <(curl -s https://codecov.io/bash) -f coverage.info -t ${CODECOV_TOKEN}
97+ # Dynamically find FSMod Python path
98+ FSMOD_PYTHON_PATH=$(find /opt/fsmod/lib -type d -path "*/python*/site-packages" 2>/dev/null | head -1)
99+ if [ -z "$FSMOD_PYTHON_PATH" ]; then
100+ FSMOD_PYTHON_PATH=$(find /opt/fsmod/lib -type d -path "*/python*/dist-packages" 2>/dev/null | head -1)
101+ fi
102+ echo "Using FSMod Python path: $FSMOD_PYTHON_PATH"
80103
104+ export LD_LIBRARY_PATH=/opt/simgrid/lib:/opt/fsmod/lib:/usr/local/lib
105+ export PYTHONPATH="$SIMGRID_PYTHON_PATH:$FSMOD_PYTHON_PATH:/usr/local/lib/python3.12/dist-packages"
106+ export CMAKE_PREFIX_PATH=/opt/simgrid:/opt/fsmod:/opt/gtest
81107
82- - name : Build with CMake
83- run : |
84- mkdir build
85- cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
86- cmake --build build/ --config Release -j4
87- - name : Run tests to generate coverage statistics
88- run : |
108+ cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug
109+ cmake --build build -j$(nproc)
110+ sudo cmake --install build
111+ cmake --build build --target unit_tests -j$(nproc)
89112 cd build
90- make -j4 unit_tests
91113 ./unit_tests
92- export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
93- export PYTHONPATH="/usr/local/lib/python3.12/dist-packages/"
94114 cd test/python
95- python ./unit_tests_python.py
115+ python3 ./unit_tests_python.py
96116 cd ../..
97- - name : Collect coverage into one XML report
117+
118+ - name : Generate coverage report
98119 run : |
120+ cd build
121+ lcov --keep-going --directory . --capture --output-file coverage.info
122+ lcov --remove coverage.info '*/test/*' '*/include/*' -o coverage.info
123+ cd ..
99124 gcovr -e test -e examples --sonarqube -u -o coverage.xml --exclude-throw-branches \
100125 --gcov-ignore-parse-errors --exclude-unreachable-branches
101126
102- - name : Sonar Scan
127+ - name : Upload coverage to Codecov
128+ if : env.CODECOV_TOKEN != ''
129+ env :
130+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
131+ run : |
132+ bash <(curl -s https://codecov.io/bash) -f build/coverage.info -t ${CODECOV_TOKEN}
133+
134+ - name : SonarQube Scan
135+ if : env.SONAR_TOKEN != ''
103136 uses : SonarSource/sonarqube-scan-action@v7
104137 env :
105138 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
@@ -109,33 +142,24 @@ jobs:
109142 -Dsonar.organization=simgrid
110143 -Dsonar.cfamily.compile-commands=build/compile_commands.json
111144 -Dsonar.coverageReportPaths=coverage.xml
112-
113- - name : Install Doxygen and Sphinx
114- run : |
115- sudo apt-get install -y python3-breathe python3-sphinx python3-sphinx-rtd-theme python3-sphinx-copybutton python3-sphinx-tabs
116- sudo apt-get -y install doxygen
117145
118- - name : Build and Deploy Documentation
146+ - name : Build and deploy documentation
147+ if : github.ref == 'refs/heads/main' && env.TOKEN_GITHUB != ''
119148 env :
120149 TOKEN_GITHUB : ${{ secrets.TOKEN_GITHUB }}
121150 run : |
122- cd DTLMod/build
123- cmake ..
124- echo "Building documentation..."
125- cd ../doc
151+ cd doc
126152 LC_ALL=C.UTF-8 ./Build.sh
127- mkdir $HOME/gh-pages-to-deploy
153+ mkdir -p $HOME/gh-pages-to-deploy
128154 cp -r build/html/* $HOME/gh-pages-to-deploy/
129155 cd ..
130- echo "Updating gh-pages branch..."
131156 git config --global user.email "[email protected] " 132157 git config --global user.name "GitHub Actions"
133- echo "git clone -q -b gh-pages https://${TOKEN_GITHUB}@github.com/simgrid/DTLMod.git gh-pages"
134- git clone -b gh-pages https://${TOKEN_GITHUB}@github.com/simgrid/DTLMod.git gh-pages > /dev/null
158+ git clone -b gh-pages https://${TOKEN_GITHUB}@github.com/simgrid/DTLMod.git gh-pages
135159 cd gh-pages
136160 cp -Rf $HOME/gh-pages-to-deploy/* .
137161 touch .nojekyll
138162 git add -f .
139163 git diff-index --quiet HEAD || git commit -m "GitHub build $GITHUB_RUN_NUMBER"
140- git push -fq origin gh-pages > /dev/null
164+ git push -fq origin gh-pages
141165 echo "Done updating gh-pages!"
0 commit comments