@@ -18,88 +18,108 @@ jobs:
1818 - uses : actions/checkout@v4
1919 with :
2020 fetch-depth : 0
21- - name : Install prereqs
21+
22+ - name : Cache dependencies
23+ uses : actions/cache@v4
24+ id : cache-deps
25+ with :
26+ path : |
27+ ~/simgrid-install
28+ ~/fsmod-install
29+ ~/gtest-install
30+ key : ${{ runner.os }}-deps-${{ hashFiles('.github/workflows/build.yml') }}
31+
32+ - name : Install system prerequisites
2233 run : |
2334 sudo apt-get update
24- sudo apt-get install -y libgraphviz-dev libboost-all-dev nlohmann-json3-dev pybind11-dev
35+ sudo apt-get install -y \
36+ libgraphviz-dev \
37+ libboost-all-dev \
38+ nlohmann-json3-dev \
39+ pybind11-dev \
40+ lcov \
41+ gcovr \
42+ python3-breathe \
43+ python3-sphinx \
44+ python3-sphinx-rtd-theme \
45+ python3-sphinx-copybutton \
46+ python3-sphinx-tabs \
47+ doxygen
2548
2649 - name : Install SimGrid
50+ if : steps.cache-deps.outputs.cache-hit != 'true'
2751 run : |
28- git clone https://framagit.org/simgrid/simgrid.git
52+ git clone --depth 1 https://framagit.org/simgrid/simgrid.git
2953 cd simgrid
30- mkdir build
31- cd build
32- cmake -Denable_smpi=OFF -Denable_model-checking=OFF ..
33- make -j4
34- sudo make install
54+ cmake -B build -Denable_smpi=OFF -Denable_model-checking=OFF
55+ cmake --build build -j$(nproc)
56+ DESTDIR=~/simgrid-install cmake --install build
3557
3658 - name : Install FSMod
59+ if : steps.cache-deps.outputs.cache-hit != 'true'
3760 run : |
38- git clone https://github.com/simgrid/file-system-module.git
61+ git clone --depth 1 https://github.com/simgrid/file-system-module.git
3962 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
63+ cmake -B build -Denable_lib_in_jar=OFF -Denable_sthread=OFF
64+ cmake --build build -j$(nproc)
65+ DESTDIR=~/fsmod-install cmake --install build
4566
46- - name : Install Google Tests
67+ - name : Install Google Test
68+ if : steps.cache-deps.outputs.cache-hit != 'true'
4769 run : |
48- wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
70+ wget -q https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
4971 tar xf release-1.11.0.tar.gz
5072 cd googletest-release-1.11.0
51- cmake .
52- make -j4
53- sudo make install
73+ cmake -B build
74+ cmake --build build -j$(nproc)
75+ DESTDIR=~/gtest-install cmake -- install build
5476
55- - name : Install lcov and gcovr
77+ - name : Restore cached dependencies
78+ if : steps.cache-deps.outputs.cache-hit == 'true'
5679 run : |
57- sudo apt-get -y install lcov gcovr
80+ sudo cp -r ~/simgrid-install/* /
81+ sudo cp -r ~/fsmod-install/* /
82+ sudo cp -r ~/gtest-install/* /
5883
59- - name : Run tests, compute coverage
84+ - name : Install dependencies from cache
85+ if : steps.cache-deps.outputs.cache-hit != 'true'
86+ run : |
87+ sudo cp -r ~/simgrid-install/* /
88+ sudo cp -r ~/fsmod-install/* /
89+ sudo cp -r ~/gtest-install/* /
90+
91+ - name : Build and test with coverage
6092 env :
61- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
93+ LD_LIBRARY_PATH : /usr/local/lib
94+ PYTHONPATH : /usr/local/lib/python3.12/dist-packages/
6295 run : |
63- git clone https://github.com/simgrid/DTLMod.git
64- cd DTLMod
65- mkdir build
96+ cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug
97+ cmake --build build -j$(nproc)
98+ sudo cmake --install build
99+ cmake --build build --target unit_tests -j$(nproc)
66100 cd build
67- cmake ..
68- make -j4
69- sudo make install
70- make -j4 unit_tests
71101 ./unit_tests
72- export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
73- export PYTHONPATH="/usr/local/lib/python3.12/dist-packages/"
74102 cd test/python
75- python ./unit_tests_python.py
103+ python3 ./unit_tests_python.py
76104 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}
80105
81-
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
106+ - name : Generate coverage report
88107 run : |
89108 cd build
90- make -j4 unit_tests
91- ./unit_tests
92- export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
93- export PYTHONPATH="/usr/local/lib/python3.12/dist-packages/"
94- cd test/python
95- python ./unit_tests_python.py
96- cd ../..
97- - name : Collect coverage into one XML report
98- run : |
109+ lcov --keep-going --directory . --capture --output-file coverage.info
110+ lcov --remove coverage.info '*/test/*' '*/include/*' -o coverage.info
99111 gcovr -e test -e examples --sonarqube -u -o coverage.xml --exclude-throw-branches \
100112 --gcov-ignore-parse-errors --exclude-unreachable-branches
101113
102- - name : Sonar Scan
114+ - name : Upload coverage to Codecov
115+ if : env.CODECOV_TOKEN != ''
116+ env :
117+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
118+ run : |
119+ bash <(curl -s https://codecov.io/bash) -f build/coverage.info -t ${CODECOV_TOKEN}
120+
121+ - name : SonarQube Scan
122+ if : env.SONAR_TOKEN != ''
103123 uses : SonarSource/sonarqube-scan-action@v7
104124 env :
105125 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
@@ -108,34 +128,25 @@ jobs:
108128 -Dsonar.projectKey=simgrid_dtlmod
109129 -Dsonar.organization=simgrid
110130 -Dsonar.cfamily.compile-commands=build/compile_commands.json
111- -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
131+ -Dsonar.coverageReportPaths=build/coverage.xml
117132
118- - name : Build and Deploy Documentation
133+ - name : Build and deploy documentation
134+ if : github.ref == 'refs/heads/main' && env.TOKEN_GITHUB != ''
119135 env :
120136 TOKEN_GITHUB : ${{ secrets.TOKEN_GITHUB }}
121137 run : |
122- cd DTLMod/build
123- cmake ..
124- echo "Building documentation..."
125- cd ../doc
138+ cd doc
126139 LC_ALL=C.UTF-8 ./Build.sh
127- mkdir $HOME/gh-pages-to-deploy
140+ mkdir -p $HOME/gh-pages-to-deploy
128141 cp -r build/html/* $HOME/gh-pages-to-deploy/
129142 cd ..
130- echo "Updating gh-pages branch..."
131143 git config --global user.email "[email protected] " 132144 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
145+ git clone -b gh-pages https://${TOKEN_GITHUB}@github.com/simgrid/DTLMod.git gh-pages
135146 cd gh-pages
136147 cp -Rf $HOME/gh-pages-to-deploy/* .
137148 touch .nojekyll
138149 git add -f .
139150 git diff-index --quiet HEAD || git commit -m "GitHub build $GITHUB_RUN_NUMBER"
140- git push -fq origin gh-pages > /dev/null
151+ git push -fq origin gh-pages
141152 echo "Done updating gh-pages!"
0 commit comments