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