fd210315065f2c091e4906f9578c49cca69d5218
[nit.git] / .gitlab-ci.yml
1 image: nitlang/nit-ci
2
3 services:
4   - mongo
5   - neo4j:2.3
6   - postgres
7
8 variables:
9   NEO4J_AUTH: none
10
11 cache:
12   paths:
13     - .ccache
14     - .gradle/caches
15     - .gradle/wrapper
16   key: "$CI_JOB_NAME"
17
18 stages:
19   - build
20   - test
21   - more_test
22   - deploy
23
24 before_script:
25   - date
26   - export CCACHE_DIR=$PWD/.ccache
27   - export GRADLE_USER_HOME=$PWD/.gradle
28   - export PATH=$PWD/bin:$PATH
29   - git config --add github.oauthtoken "$GITHUB_OAUTHTOKEN" # needed for github api rate limit
30   - pwd
31   - ccache -s
32   - ccache -z
33   - ccache -M 500M
34   - du -sh .gradle || true
35   - type -a nitc nitdoc || true # is there some nit tools?
36   - "> status.txt"
37
38 after_script:
39   - export CCACHE_DIR=$PWD/.ccache
40   - ccache -s
41   - du -sh .gradle || true
42   - git status --ignored || true
43   - date
44   - tail status.txt
45
46 # BASIC JOBS ########################################################
47
48 sanity_checks:
49   stage: build
50   script:
51     - misc/jenkins/checkwhitespaces.sh | tee -a status.txt
52     - misc/jenkins/checksignedoffby.sh | tee -a status.txt
53     - misc/jenkins/checklicense.sh | tee -a status.txt
54
55 build_tools: &build_tools
56   stage: build
57   script:
58     - make 2>> status.txt
59     - nitc --version
60     - misc/jenkins/check_manpages.sh
61   artifacts:
62     paths:
63       - bin/*
64       - c_src/nitc
65       - src/version.nit
66       - src/nitc_0
67     when: always
68
69 test_some: &test_some
70   stage: test
71   dependencies:
72     - build_tools
73   script:
74     - cd tests
75     - ./search_tests_git.sh origin/master HEAD > list
76     - ./testall.sh `cat list` | tee log.txt
77     - grep -v '=>' log.txt > ../status.txt || true
78   artifacts:
79     paths:
80       - tests/errlist
81       - tests/*.xml*
82     when: always
83     reports:
84       junit: tests/*.xml
85
86 nitunit_some:
87   stage: test
88   dependencies:
89     - build_tools
90   script:
91     - git diff --name-only origin/master..HEAD -- "*.nit" "*.res" "README.*" | grep -v "^tests/\|contrib/" > list0.txt || true
92     - xargs nitls -pP < list0.txt > list.txt
93     - test -s list.txt || exit 0
94     - xargs nitunit < list.txt
95     - junit2html nitunit.xml
96   artifacts:
97     paths:
98       - nitunit.xml*
99     when: always
100     reports:
101       junit:
102         - nitunit.xml
103
104 nitpick_full:
105   stage: test
106   dependencies:
107     - build_tools
108   script:
109     - nitls lib src examples contrib
110     - nitls -Pp lib src examples | grep -v -f tests/gitlab_ci.skip > list.txt || true # filter what is skipped by tests.sh
111     - xargs nitpick < list.txt
112
113 basic_android:
114   stage: test
115   dependencies:
116     - build_tools
117   script:
118     - make -C contrib/asteronits android
119   artifacts:
120     paths:
121       - contrib/asteronits/bin/*.apk
122
123 # TEST FULL #########################################################
124
125 test_full_nitcs: &test_full_nitcs
126   stage: more_test
127   dependencies:
128     - build_tools
129   script:
130     - share/android-bdwgc/setup.sh
131     - cd tests
132     - ./testfull.sh | tee log.txt
133     - grep -v '=>' log.txt > ../status.txt || true
134   artifacts:
135     paths:
136       - tests/errlist
137       - tests/*.xml*
138       - tests/out/*.res
139       - tests/out/*.log
140     when: always
141     reports:
142       junit: tests/*.xml
143
144 test_full_niti:
145   stage: more_test
146   dependencies:
147     - build_tools
148   script:
149     - cd tests
150     - ./testfull.sh --engine niti | tee log.txt
151     - grep -v '=>' log.txt > ../status.txt || true
152   artifacts:
153     paths:
154       - tests/errlist
155       - tests/*.xml*
156       - tests/out/*.res
157       - tests/out/*.log
158     when: always
159     reports:
160       junit: tests/*.xml
161
162 test_full_nitcg:
163   stage: more_test
164   dependencies:
165     - build_tools
166   script:
167     - cd tests
168     - ./testfull.sh --engine nitcg | tee log.txt
169     - grep -v '=>' log.txt > ../status.txt || true
170   artifacts:
171     paths:
172       - tests/errlist
173       - tests/*.xml*
174       - tests/out/*.res
175       - tests/out/*.log
176     when: always
177     reports:
178       junit: tests/*.xml
179
180 test_full_nitce:
181   stage: more_test
182   dependencies:
183     - build_tools
184   script:
185     - cd tests
186     - ./testfull.sh --engine nitce | tee log.txt
187     - grep -v '=>' log.txt > ../status.txt || true
188   artifacts:
189     paths:
190       - tests/errlist
191       - tests/*.xml*
192       - tests/out/*.res
193       - tests/out/*.log
194     when: always
195     reports:
196       junit: tests/*.xml
197
198 test_full_nitcsg:
199   stage: more_test
200   dependencies:
201     - build_tools
202   script:
203     - cd tests
204     - ./testfull.sh --engine nitcsg | tee log.txt
205     - grep -v '=>' log.txt > ../status.txt || true
206   artifacts:
207     paths:
208       - tests/errlist
209       - tests/*.xml*
210       - tests/out/*.res
211       - tests/out/*.log
212     when: always
213     reports:
214       junit: tests/*.xml
215
216 # LIB, CONTRIB AND OOT ##############################################
217
218 nitunit_lib:
219   stage: more_test
220   dependencies:
221     - build_tools
222   script:
223     - nitls -Pp lib | grep -v -f tests/gitlab_ci.skip > list.txt || true # filter what is skipped by tests.sh
224     - xargs nitunit -v < list.txt| tee log.txt
225     - grep -e KO log.txt > status.txt || true
226     - tail -3 log.txt >> status.txt
227     - junit2html nitunit.xml
228   artifacts:
229     paths:
230       - nitunit.xml*
231     when: always
232     reports:
233       junit:
234         - nitunit.xml
235
236 nitunit_src:
237   stage: more_test
238   dependencies:
239     - build_tools
240   script:
241     - nitls -Pp src examples | grep -v -f tests/gitlab_ci.skip > list.txt || true # filter what is skipped by tests.sh
242     - xargs nitunit -v < list.txt| tee log.txt
243     - grep -e KO log.txt > status.txt || true
244     - tail -3 log.txt >> status.txt
245     - junit2html nitunit.xml
246   artifacts:
247     paths:
248       - nitunit.xml*
249     when: always
250     reports:
251       junit:
252         - nitunit.xml
253
254 test_contribs:
255   stage: more_test
256   dependencies:
257     - build_tools
258   script:
259     - misc/jenkins/check_contrib.sh all check
260     - grep 'error message' *.xml > status.txt || true
261     - test ! -s status.txt # no lines, no errors
262
263 test_contribs_android:
264   stage: more_test
265   dependencies:
266     - build_tools
267   script:
268     - misc/jenkins/check_contrib.sh android
269     - grep 'error message' *.xml > status.txt || true
270     - mkdir -p apk/debug
271     - find . -name '*.apk' -exec mv {} apk/debug/ ";"
272     - test ! -s status.txt # no lines, no errors
273     - misc/jenkins/check_contrib.sh android-release
274     - grep 'error message' *.xml > status.txt || true
275     - mkdir -p apk/release
276     - find . -name '*.apk' -exec mv {} apk/release ";"
277     - test ! -s status.txt # no lines, no errors
278   artifacts:
279     paths:
280       - "apk"
281     when: always
282
283 build_oot:
284   stage: more_test
285   dependencies:
286     - build_more_tools
287   script:
288     - cd contrib
289     - ./oot.sh all
290     - grep 'error message' *.xml > ../status.txt || true
291     # Errors are somewhat expected
292
293 # MISC ##############################################################
294
295 check_requirments:
296   stage: more_test
297   image: debian:buster
298   before_script:
299     - date # cancel the default `before_script`, an empty list does nothing
300   script: # from the README
301     - apt-get update && apt-get install --yes --no-install-recommends build-essential ccache libgc-dev libunwind-dev pkg-config
302     - make
303     - bin/nitc examples/hello_world.nit
304     - ./hello_world
305     - . misc/nit_env.sh install
306     - nitc examples/hello_world.nit
307     - ./hello_world
308     - apt-get update && apt-get install --yes --no-install-recommends graphviz libcurl4-openssl-dev libevent-dev libmongoc-dev
309     - make more
310
311 bootstrap_full:
312   stage: more_test
313   dependencies:
314     - build_tools
315   script:
316     - cd src
317     - ./full_bootstrap
318     - ./ncall.sh
319
320 bench_fast:
321   stage: more_test
322   dependencies:
323     - build_tools
324   script:
325     - cd benchmarks
326     - ./bench_engines.sh --fast --fast --html options
327     - grep -B1 'error message' *.xml | grep testcase > ../status.txt || true
328   artifacts:
329     paths:
330       - benchmarks/*.html
331       - benchmarks/*.png
332       - benchmarks/*.dat
333       - benchmarks/*.gnu
334     when: always
335
336
337 # MORE TOOLS ########################################################
338
339 build_more_tools:
340   stage: test
341   dependencies:
342     - build_tools
343   script:
344     - make more
345     - make -C "contrib/nitcc"
346   artifacts:
347     paths:
348       - bin/*
349       - c_src/nitc
350       - src/version.nit
351       - src/nitc_0
352
353 valgrind:
354   stage: more_test
355   dependencies:
356     - build_more_tools
357   script:
358     - mkdir -p valgrind.out
359     - nitc src/nitc.nit # To warm-up the cache
360     - src/valgrind.sh --callgrind-out-file=valgrind.out/nitc.nitc.out nitc src/nitc.nit -vv
361     - callgrind_annotate valgrind.out/nitc.nitc.out > valgrind.out/nitc.nitc.txt
362     - src/valgrind.sh --callgrind-out-file=valgrind.out/niti.niti.out nit -- src/nit.nit tests/base_simple3.nit -vv
363     - callgrind_annotate valgrind.out/niti.niti.out > valgrind.out/niti.niti.txt
364   artifacts:
365     paths:
366       - valgrind.out
367
368 build_doc:
369   stage: more_test
370   dependencies:
371     - build_more_tools
372   script:
373     - nitls -r -t .
374     - nitdoc -d nitdoc.out --keep-going lib src
375   artifacts:
376     paths:
377       - nitdoc.out
378
379 build_manual:
380   stage: more_test
381   script:
382     - apt-get update && apt-get install --yes --no-install-recommends pandoc texlive texlive-latex-extra lmodern
383     - make -C doc/manual
384   artifacts:
385     paths:
386       - doc/manual/*.pdf
387       - doc/manual/*.epub
388
389 nitmetrics:
390   stage: more_test
391   dependencies:
392     - build_more_tools
393   script:
394     - mkdir -p nitmetrics.out
395     - nitmetrics --all --log --log-dir nitmetrics.out --dir nitmetrics.out --keep-going lib src | tee nitmetrics.out/metrics.txt
396   artifacts:
397     paths:
398       - nitmetrics.out
399
400 build_catalog:
401   stage: more_test
402   dependencies:
403     - build_more_tools
404   script:
405     - misc/jenkins/check_contrib.sh pre-build
406     - cd contrib
407     - ./oot.sh update
408     - ./oot.sh pre-build
409     - cd ..
410     - nitcatalog -d catalog.out lib/ examples/ contrib/ contrib/oot/
411   artifacts:
412     paths:
413       - catalog.out
414
415 build_tools_macos:
416   <<: *build_tools
417   tags:
418     - macos
419
420 test_some_macos:
421   <<: *test_some
422   tags:
423     - macos
424   dependencies:
425     - build_tools_macos
426
427 test_full_nitcs_macos:
428   <<: *test_full_nitcs
429   tags:
430     - macos
431   dependencies:
432     - build_tools_macos
433
434 bench_old:
435   stage: more_test
436   tags:
437     - perf
438   dependencies:
439     - build_tools
440   script:
441     - benchmarks/bench_old.sh
442   allow_failure: true # time is unreliable. manual check required
443   services: []
444
445 build_tools_windows:
446   stage: build
447   before_script:
448     - date
449   after_script:
450     - date
451   tags:
452     - windows
453   script:
454     - $project_dir = "$CI_PROJECT_DIR" -replace "\\", "\\\"
455     - $converted_project_dir = $(c:\msys64\usr\bin\bash -l -c "cygpath -u $project_dir")
456     - c:\msys64\usr\bin\env MSYSTEM=MINGW64 c:\msys64\usr\bin\bash -l -c "cd $converted_project_dir; make"