gitlab-ci: Add linters
[ghc.git] / .gitlab-ci.yml
1 variables:
2   GIT_SSL_NO_VERIFY: "1"
3
4 before_script:
5   - python3 .gitlab/fix-submodules.py
6   - git submodule sync --recursive
7   - git submodule update --init --recursive
8   - git checkout .gitmodules
9
10 stages:
11   - lint
12   - build
13
14 ############################################################
15 # Linting
16 ############################################################
17
18 ghc-linters:
19   stage: lint
20   image: ghcci/linters:0.1
21   script:
22     - |
23       if [ -n "$CI_MERGE_REQUEST_ID" ]; then
24         base="$(git merge-base $CI_MERGE_REQUEST_BRANCH_NAME HEAD)"
25         validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
26         submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
27         validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
28         .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
29         .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
30       fi
31
32 ############################################################
33 # Validation via Pipelines (hadrian)
34 ############################################################
35
36 .validate-hadrian:
37   stage: build
38   allow_failure: true
39   script:
40     - bash .circleci/prepare-system.sh
41     - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
42     - ./boot
43     - ./configure $CONFIGURE_ARGS
44     - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh`
45   cache:
46     key: hadrian
47     paths:
48       - cabal-cache
49
50 validate-x86_64-linux-deb8-hadrian:
51   extends: .validate-hadrian
52   image: ghcci/x86_64-linux-deb8:0.1
53   before_script:
54     # workaround for docker permissions
55     - sudo chown ghc:ghc -R .
56   tags:
57     - x86_64-linux
58
59 ############################################################
60 # Validation via Pipelines (make)
61 ############################################################
62
63 .validate:
64   stage: build
65   script:
66     - make clean || true
67     - ./boot
68     - ./configure $CONFIGURE_ARGS
69     - |
70       THREADS=`mk/detect-cpu-count.sh`
71       make V=0 -j$THREADS
72     - |
73       make binary-dist TAR_COMP_OPTS="-1"
74       mv ghc-*.tar.xz ghc.tar.xz
75     - |
76       THREADS=`mk/detect-cpu-count.sh`
77       make test THREADS=$THREADS JUNIT_FILE=../../junit.xml
78   artifacts:
79     reports:
80       junit: junit.xml
81     paths:
82       - ghc.tar.xz
83       - junit.xml
84
85 validate-x86_64-darwin:
86   extends: .validate
87   allow_failure: true
88   tags:
89     - x86_64-darwin
90   variables:
91     GHC_VERSION: 8.6.2
92     MACOSX_DEPLOYMENT_TARGET: "10.7"
93     # Only Sierra and onwards supports clock_gettime. See #12858
94     ac_cv_func_clock_gettime: "no"
95   before_script:
96     - python .gitlab/fix-submodules.py
97     - git submodule sync --recursive
98     - git submodule update --init --recursive
99     - git checkout .gitmodules
100
101     - bash .gitlab/darwin-init.sh
102     - PATH="`pwd`/toolchain/bin:$PATH"
103       # Disable sphinx PDF output as MacTeX apparently doesn't provide xelatex
104     - echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
105   after_script:
106     - cp -Rf $HOME/.cabal cabal-cache
107   artifacts:
108     when: always
109   cache:
110     key: darwin
111     paths:
112       - cabal-cache
113       - toolchain
114
115
116 .validate-linux:
117   extends: .validate
118   tags:
119     - x86_64-linux
120   before_script:
121     - python3 .gitlab/fix-submodules.py
122     - git submodule sync --recursive
123     - git submodule update --init --recursive
124     - git checkout .gitmodules
125
126     - bash .circleci/prepare-system.sh
127     # workaround for docker permissions
128     - sudo chown ghc:ghc -R .
129   after_script:
130     - cp -Rf $HOME/.cabal cabal-cache
131   cache:
132     key: linux
133     paths:
134       - cabal-cache
135       - toolchain
136
137 validate-x86_64-linux-deb9:
138   extends: .validate-linux
139   image: ghcci/x86_64-linux-deb9:0.2
140   artifacts:
141     when: always
142   cache:
143     key: linux-x86_64-deb9
144
145 validate-x86_64-linux-deb9-llvm:
146   extends: .validate-linux
147   allow_failure: true
148   image: ghcci/x86_64-linux-deb9:0.2
149   variables:
150     BUILD_FLAVOUR: perf-llvm
151   cache:
152     key: linux-x86_64-deb9
153
154 validate-x86_64-linux-deb8:
155   extends: .validate-linux
156   image: ghcci/x86_64-linux-deb8:0.1
157   cache:
158     key: linux-x86_64-deb8
159   artifacts:
160     when: always
161
162 validate-x86_64-linux-fedora27:
163   extends: .validate-linux
164   image: ghcci/x86_64-linux-fedora27:0.1
165   cache:
166     key: linux-x86_64-fedora27
167   artifacts:
168     when: always
169
170 validate-x86_64-linux-deb9-integer-simple:
171   extends: .validate-linux
172   allow_failure: true
173   variables:
174     INTEGER_LIBRARY: integer-simple
175   image: ghcci/x86_64-linux-deb9:0.2
176   cache:
177     key: linux-x86_64-deb9
178
179 validate-x86_64-linux-deb9-unreg:
180   extends: .validate-linux
181   variables:
182     CONFIGURE_ARGS: --enable-unregisterised
183   image: ghcci/x86_64-linux-deb9:0.2
184   cache:
185     key: linux-x86_64-deb9
186
187 ############################################################
188 # Validation via Pipelines (make, Windows)
189 ############################################################
190
191 .validate-x86_64-windows:
192   stage: build
193   variables:
194     GHC_VERSION: "8.6.2"
195   script:
196     - bash -e .gitlab/win32-init.sh
197     - |
198       set MSYSTEM=MINGW64
199       python boot
200       bash -c './configure --with-ghc=`pwd`/toolchain/bin/ghc --enable-tarballs-autodownload HappyCmd=`pwd`/toolchain/bin/happy AlexCmd=`pwd`/toolchain/bin/alex'
201       mkdir -p _build
202       cp -R inplace/mingw _build/mingw
203     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick"
204     - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh binary-dist"
205     - mv ghc-*.tar.xz ghc.tar.xz
206     - bash -c 'make V=0 -j`mk/detect-cpu-count.sh` HADDOCK_DOCS=NO test THREADS=$THREADS JUNIT_FILE=../../junit.xml'
207     - cp -Rf $APPDATA/cabal cabal-cache
208   cache:
209     key: windows
210     paths:
211       - cabal-cache
212       - ghc-8.6.2
213       - ghc-tarballs
214   tags:
215     - x86_64-windows
216
217
218 ############################################################
219 # Validation via CircleCI
220 ############################################################
221
222 .circleci:
223   stage: build
224   image: ghcci/x86_64-linux-deb8:0.1
225   artifacts:
226     when: always
227     reports:
228       junit: junit.xml
229     paths:
230       - ghc.tar.xz
231       - junit.xml
232   tags:
233     - circleci
234
235 # All validation jobs keep the bindists and test results are artifacts,
236 # when we get far enough to generate them.
237 #
238 # This requires updating the maximum artifacts size limit in Gitlab to
239 # something like 200MB.
240
241 circleci-validate-x86_64-linux-deb8:
242   extends: .circleci
243   script: ".gitlab/circle-ci-job.sh validate-x86_64-linux-deb8"
244
245 circleci-validate-i386-linux-deb8:
246   extends: .circleci
247   script: ".gitlab/circle-ci-job.sh validate-i386-linux-deb8"
248
249 # circleci-validate-x86_64-freebsd:
250 #   extends: .circleci
251 #   script: ".gitlab/circle-ci-job.sh validate-x86_64-freebsd"
252
253 circleci-validate-x86_64-darwin:
254   extends: .circleci
255   script: ".gitlab/circle-ci-job.sh validate-x86_64-darwin"