-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
317 lines (297 loc) · 9.92 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
{ kapack ? import
(fetchTarball "https://github.com/oar-team/nur-kapack/archive/master.tar.gz")
{}
, doUnitTests ? true
, doCoverage ? true
, coverageCobertura ? false
, coverageCoveralls ? false
, coverageGcovTxt ? false
, coverageHtml ? false
, coverageSonarqube ? false
, werror ? false
, doValgrindAnalysis ? false
, debug ? true
, useClang ? false
, simgrid ? kapack.simgrid-light.override { inherit debug; }
, batsched ? kapack.batsched.overrideAttrs (old: {
src = kapack.pkgs.fetchFromGitLab {
domain = "framagit.org";
owner = "batsim";
repo = "batsched";
rev = "17072778995100fc90214ea4910bf5b171adfd0d";
sha256 = "12r8b14rwa26wx34l1492vdvyn2s7mch3ixlz46s6imi1ximywa8";
};
})
, batexpe ? kapack.batexpe
, pybatsim ? kapack.pybatsim.overrideAttrs (old: {
src = kapack.pkgs.fetchFromGitLab {
domain = "gitlab.inria.fr";
owner = "batsim";
repo = "pybatsim";
rev = "880dd60c537d7d7a8246daaf5b2d1f7bfea3cbf4";
sha256 = "1xa0r1h8xv1x51v0zddw3m52n250wph8jsm1ga67v18k7582kav4";
};
})
# set this to avoid running tests over and over
# (e.g., to debug coverage reports or to run tests and coverage report separately)
, testVersion ? toString builtins.currentTime
}:
let
pkgs = kapack.pkgs;
pythonPackages = pkgs.python3Packages;
buildPythonPackage = pythonPackages.buildPythonPackage;
#custom-stdenv-base = if useClang then pkgs.llvmPackages_11.stdenv else pkgs.gcc11Stdenv;
custom-stdenv-base = if useClang then pkgs.clangStdenv else pkgs.gccStdenv;
custom-stdenv = if debug then (pkgs.stdenvAdapters.keepDebugInfo custom-stdenv-base) else custom-stdenv-base;
jobs = rec {
inherit pkgs;
inherit kapack;
# Batsim executable binary file.
batsim = (kapack.batsim.override { inherit debug simgrid; stdenv = custom-stdenv; }).overrideAttrs (attr: rec {
buildInputs = attr.buildInputs
++ pkgs.lib.optional doUnitTests [pkgs.gtest.dev];
src = pkgs.lib.sourceByRegex ./. [
"^src"
"^src/.*\.?pp"
"^src/unittest"
"^src/unittest/.*\.?pp"
"^meson\.build"
"^meson_options\.txt"
];
patches = [];
mesonBuildType = if debug then "debug" else "release";
mesonFlags = [ "--warnlevel=3" ]
++ pkgs.lib.optional werror [ "--werror" ]
++ pkgs.lib.optional doUnitTests [ "-Ddo_unit_tests=true" ]
++ pkgs.lib.optional doCoverage [ "-Db_coverage=true" ];
ninjaFlags = [ "-v" ];
# Unit tests
doCheck = doUnitTests;
checkPhase = ''
meson test --print-errorlogs
'';
# Keep files generated by GCOV, so depending jobs can use them.
postInstall = pkgs.lib.optionalString doCoverage ''
mkdir -p $out/gcno
cp batsim.p/*.gcno $out/gcno/
cp libbatlib.a.p/*.gcno $out/gcno/
'' + pkgs.lib.optionalString (doCoverage && doUnitTests) ''
mkdir -p $out/gcda
cp libbatlib.a.p/*.gcda $out/gcda/
'';
});
# Another Batsim. This one is built from cmake.
batsim_cmake = batsim.overrideAttrs (attr: rec {
buildInputs = attr.buildInputs ++ [pkgs.cmake];
src = pkgs.lib.sourceByRegex ./. [
"^src"
"^src/.*\.?pp"
"^CMakeLists.txt"
];
configurePhase = ''
mkdir build && cd build
cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=$out
'';
buildPhase = "ninja";
installPhase = "ninja install";
});
# Convenient development shell for qtcreator+cmake users.
qtcreator_shell = pkgs.mkShell rec {
name = "batsim-dev-shell-qtcreator-cmake";
buildInputs = batsim.buildInputs ++
[pkgs.cmake pkgs.qtcreator];
};
# Shell used by CI to push coverage results on codecov's infrastructure.
codecov_push_shell = pkgs.mkShell rec {
name = "codecov-push-shell";
buildInputs = [
pkgs.curl
pkgs.git
pkgs.python3Packages.codecov
];
};
# Batsim integration tests.
integration_tests = pkgs.stdenv.mkDerivation rec {
pname = "batsim-integration-tests";
version = testVersion;
src = pkgs.lib.sourceByRegex ./. [
"^test"
"^test/.*\.py"
"^platforms"
"^platforms/.*\.xml"
"^workloads"
"^workloads/.*\.json"
"^workloads/.*\.dax"
"^workloads/smpi"
"^workloads/smpi/.*"
"^workloads/smpi/.*/.*\.txt"
"^workloads/usage-trace"
"^workloads/usage-trace/.*"
"^workloads/usage-trace/.*/.*\.txt"
"^events"
"^events/.*\.txt"
];
buildInputs = with pkgs.python3Packages; [
batsim batsched batexpe pkgs.redis
pybatsim pytest pytest-html pandas] ++
pkgs.lib.optional doValgrindAnalysis [ pkgs.valgrind ];
pytestArgs = "-ra test/ --html=./report/pytest_report.html" +
pkgs.lib.optionalString doValgrindAnalysis " --with-valgrind";
preBuild = pkgs.lib.optionalString doCoverage ''
mkdir -p gcda
export GCOV_PREFIX=$(realpath gcda)
export GCOV_PREFIX_STRIP=5
'' + pkgs.lib.optionalString (doCoverage && doUnitTests) ''
cp --no-preserve=all ${batsim}/gcda/*.gcda gcda/
'';
buildPhase = ''
runHook preBuild
set +e
pytest ${pytestArgs}
echo $? > ./pytest_returncode
set -e
'';
checkPhase = ''
pytest_return_code=$(cat ./pytest_returncode)
echo "pytest return code: $pytest_return_code"
if [ $pytest_return_code -ne 0 ] ; then
exit 1
fi
'';
doCheck = false;
installPhase = ''
mkdir -p $out
mv ./report/* ./pytest_returncode $out/
'' + pkgs.lib.optionalString doCoverage ''
mv ./gcda $out/
'';
};
# Generate coverage reports, from gcov traces in batsim and batsim_integration_tests.
coverage-report = pkgs.stdenv.mkDerivation rec {
pname = "batsim-coverage-report";
version = integration_tests.version;
buildInputs = batsim.buildInputs ++ [ kapack.gcovr ]
++ [ batsim integration_tests ];
src = batsim.src;
buildPhase = ''
mkdir cov-merged
cd cov-merged
cp ${batsim}/gcno/* ${integration_tests}/gcda/* ./
gcov -p *.gcno
mkdir report
'' + pkgs.lib.optionalString coverageHtml ''
mkdir -p report/html
'' + pkgs.lib.optionalString coverageGcovTxt ''
mkdir -p report/gcov-txt
cp \^\#src\#*.gcov report/gcov-txt/
'' + ''
gcovr -g -k -r .. --filter '\.\./src/' \
--txt report/file-summary.txt \
--csv report/file-summary.csv \
--json-summary report/file-summary.json \
'' + pkgs.lib.optionalString coverageCobertura ''
--xml report/cobertura.xml \
'' + pkgs.lib.optionalString coverageCoveralls ''
--coveralls report/coveralls.json \
'' + pkgs.lib.optionalString coverageHtml ''
--html-details report/html/index.html \
'' + pkgs.lib.optionalString coverageSonarqube ''
--sonarqube report/sonarqube.xml \
'' + ''
--print-summary
'';
installPhase = ''
mkdir -p $out
cp -r report/* $out/
'';
};
# Batsim doxygen documentation.
doxydoc = pkgs.stdenv.mkDerivation rec {
name = "batsim-doxygen-documentation";
src = pkgs.lib.sourceByRegex ./. [
"^src"
"^src/.*\.?pp"
"^doc"
"^doc/Doxyfile"
"^doc/doxygen_mainpage.md"
];
buildInputs = [pkgs.doxygen];
buildPhase = "(cd doc && doxygen)";
installPhase = ''
mkdir -p $out
mv doc/doxygen_doc/html/* $out/
'';
checkPhase = ''
nb_warnings=$(cat doc/doxygen_warnings.log | wc -l)
if [[ $nb_warnings -gt 0 ]] ; then
echo "FAILURE: There are doxygen warnings!"
cat doc/doxygen_warnings.log
exit 1
fi
'';
doCheck = true;
};
# Batsim sphinx documentation.
sphinx_doc = pkgs.stdenv.mkDerivation rec {
name = "batsim-sphinx-documentation";
src = pkgs.lib.sourceByRegex ./. [
"^\.gitlab-ci\.yml"
"^\.github"
"^\.github/workflows"
"^\.github/workflows/build-docker-containers.yml"
"^default.nix"
"^doc"
"^doc/batsim_rjms_overview.png"
"^docs"
"^docs/conf.py"
"^docs/Makefile"
"^docs/.*\.bash"
"^docs/.*\.rst"
"^docs/img"
"^docs/img/.*\.png"
"^docs/img/ci"
"^docs/img/ci/.*\.svg"
"^docs/img/logo"
"^docs/img/logo/logo.png"
"^docs/img/ptask"
"^docs/img/ptask/CommMatrix.svg"
"^docs/img/proto"
"^docs/img/proto/.*\.png"
"^docs/tuto-app-model"
"^docs/tuto-app-model/.*\.rst"
"^docs/tuto-app-model/.*\.svg"
"^docs/tuto-first-simulation"
"^docs/tuto-first-simulation/.*\.bash"
"^docs/tuto-first-simulation/.*\.rst"
"^docs/tuto-first-simulation/.*\.out"
"^docs/tuto-first-simulation/.*\.yaml"
"^docs/tuto-first-simulation/.*\.nix"
"^docs/tuto-reproducible-experiment"
"^docs/tuto-reproducible-experiment/.*\.nix"
"^docs/tuto-reproducible-experiment/.*\.rst"
"^docs/tuto-reproducible-experiment/.*\.bash"
"^docs/tuto-reproducible-experiment/.*\.R"
"^docs/tuto-reproducible-experiment/.*\.Rmd"
"^docs/tuto-result-analysis"
"^docs/tuto-result-analysis/.*\.rst"
"^docs/tuto-result-analysis/.*\.R"
"^docs/tuto-sched-implem"
"^docs/tuto-sched-implem/.*\.rst"
"^env"
"^env/docker"
"^env/docker/Dockerfile"
"^events"
"^events/test_events_4hosts\.txt"
"^workloads"
"^workloads/test_various_profile_types\.json"
];
buildInputs = with pythonPackages; [ sphinx sphinx_rtd_theme ];
buildPhase = "cd docs && make html";
installPhase = ''
mkdir -p $out
cp -r _build/html $out/
'';
};
};
in
jobs