diff --git a/.coafile b/.coafile index a8b6722785..a5388e94a2 100644 --- a/.coafile +++ b/.coafile @@ -1,10 +1,11 @@ [Source] bears = CPPCheckBear, LicenseYearBear +language = c++ files = source/**.(cpp|h) -ignore = source/third_party/** +ignore = source/third_party [JS] bears = ESLintBear, JSHintBear -eslint_config = build/jenkins/lint-config/eslintrc.json -jshint_config = build/jenkins/lint-config/jshintrc.json +eslint_config = build/coala/lint-config/eslintrc.json +jshint_config = build/coala/lint-config/jshintrc.json files = binaries/data/**.js diff --git a/build/coala/LicenseYearBear.py b/build/coala/LicenseYearBear.py index fd778b2e53..da8d471efa 100644 --- a/build/coala/LicenseYearBear.py +++ b/build/coala/LicenseYearBear.py @@ -29,7 +29,7 @@ class LicenseYearBear(LocalBear): if not was_modified: try: return client.info()['commit_date'].year - except SvnException: + except (AttributeError, SvnException): return None else: return date.today().year diff --git a/build/jenkins/lint-config/eslintrc.json b/build/coala/lint-config/eslintrc.json similarity index 100% rename from build/jenkins/lint-config/eslintrc.json rename to build/coala/lint-config/eslintrc.json diff --git a/build/jenkins/lint-config/jshintrc.json b/build/coala/lint-config/jshintrc.json similarity index 100% rename from build/jenkins/lint-config/jshintrc.json rename to build/coala/lint-config/jshintrc.json diff --git a/build/jenkins/dockerfiles/coala.Dockerfile b/build/jenkins/dockerfiles/coala.Dockerfile index 8076d87471..419dc48432 100644 --- a/build/jenkins/dockerfiles/coala.Dockerfile +++ b/build/jenkins/dockerfiles/coala.Dockerfile @@ -1,10 +1,22 @@ -FROM python:3.7-alpine +FROM python:3.8 -RUN adduser -u 1006 -D builder +RUN useradd --uid 1006 builder -RUN apk add subversion cppcheck npm +RUN apt-get -yy update && apt-get -yy install \ + cppcheck \ + git \ + npm \ + subversion -RUN pip3 install coala-bears svn +RUN npm install -g npm@latest RUN npm install -g eslint@5.16.0 jshint eslint-plugin-brace-rules +RUN pip3 install svn + +RUN git clone -b 0ad-fixes https://github.com/0ad/coala.git +RUN cd coala && pip3 install . + +RUN git clone -b 0ad-fixes https://github.com/0ad/coala-bears.git +RUN cd coala-bears && pip3 install . + USER builder diff --git a/build/jenkins/lint-patch.sh b/build/jenkins/lint-patch.sh deleted file mode 100755 index 5235984ccc..0000000000 --- a/build/jenkins/lint-patch.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Lint errors should not count as build failures -set +e -set -v - -# Move to the root of the repository (this script is in build/jenkins/) -cd "$(dirname $0)"/../../ - -arc patch --diff "$DIFF_ID" --force - -svn st | grep '^[AM]' | cut -c 9- | xargs coala --ci --flush-cache --limit-files > .phabricator-comment diff --git a/build/jenkins/pipelines/docker-differential.Jenkinsfile b/build/jenkins/pipelines/docker-differential.Jenkinsfile index 839b1d8c61..dac95eb883 100644 --- a/build/jenkins/pipelines/docker-differential.Jenkinsfile +++ b/build/jenkins/pipelines/docker-differential.Jenkinsfile @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -48,9 +48,16 @@ def build(compiler) { docker.image("0ad-${compiler}:latest").inside { sh "build/workspaces/update-workspaces.sh -j1 --jenkins-tests" - // TODO: Mark build as unstable in case of warnings and tweak the plugin accordingly. + try { + retry(3) { + sh "cd build/workspaces/gcc/ && make -j1 config=debug 2> ../../../builderr-debug-${compiler}.txt" + } + } catch(e) { + throw e + } finally { + stash includes: "builderr-debug-${compiler}.txt", name: "build-debug-${compiler}" + } - sh "cd build/workspaces/gcc/ && make -j1 config=debug" try { sh "binaries/system/test_dbg > cxxtest-debug-${compiler}.xml" } catch (e) { @@ -60,7 +67,16 @@ def build(compiler) { stash includes: "cxxtest-debug-${compiler}.xml", name: "tests-debug-${compiler}" } - sh "cd build/workspaces/gcc/ && make -j1 config=release" + try { + retry(3) { + sh "cd build/workspaces/gcc/ && make -j1 config=release 2> ../../../builderr-release-${compiler}.txt" + } + } catch(e) { + throw e + } finally { + stash includes: "builderr-release-${compiler}.txt", name: "build-release-${compiler}" + } + try { sh "binaries/system/test > cxxtest-release-${compiler}.xml" } catch (e) { @@ -107,10 +123,22 @@ pipeline { always { script { for(compiler in compilers) { + catchError { unstash "build-debug-${compiler}" } catchError { unstash "tests-debug-${compiler}" } + catchError { unstash "build-release-${compiler}" } catchError { unstash "tests-release-${compiler}" } } } + catchError { + sh ''' + for file in builderr-*.txt ; do + if [ -s "$file" ]; then + echo "$file" >> build-errors.txt + cat "$file" >> build-errors.txt + fi + done + ''' + } catchError { junit 'cxxtest*.xml' } } } @@ -120,22 +148,22 @@ pipeline { script { try { withDockerContainer("0ad-coala:latest") { - sh "svn st | grep '^[AM]' | cut -c 9- | xargs coala -d build/coala --ci --flush-cache --limit-files > coala-report" + sh ''' + svn st | grep '^[AM]' | cut -c 9- | xargs coala -d build/coala --ci --disable-caching \ + --format '{{ "name": "{origin}", "code": "{origin}", "severity": "{severity_str}", "path": "{file}", "line": {line}, "description": "`{message}`" }}' \ + --limit-files > coala-report + ''' } } catch (e) { - sh ''' - echo "Linter detected issues:" >> phabricator-comment - cat coala-report >> phabricator-comment - echo "\n" >> phabricator-comment - ''' + sh 'sed -i "s|$(pwd)/||g" coala-report' + sh 'sed -e "s/INFO/advice/g" -e "s/NORMAL/warning/g" -e "s/MAJOR/error/g" coala-report > .phabricator-lint' } } - echo (message: readFile (file: "coala-report")) } } stage("Data checks") { steps { - sh "cd source/tools/entity/ && perl checkrefs.pl --check-map-xml --validate-templates" + sh "cd source/tools/entity/ && perl checkrefs.pl --check-map-xml --validate-templates 2> data-errors.txt" } } } @@ -143,11 +171,21 @@ pipeline { post { always { script { + catchError { + sh "if [ -s build-errors.txt ]; then cat build-errors.txt >> .phabricator-comment ; fi" + sh ''' + if [ -s data-errors.txt ]; then + echo "Data checks errors:" >> .phabricator-comment + cat data-errors.txt >> .phabricator-comment + fi + ''' + } + try { - if (fileExists("phabricator-comment")) { - step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true, customComment: true, commentFile: "phabricator-comment"]) + if (fileExists(".phabricator-comment")) { + step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true, customComment: true, commentFile: ".phabricator-comment", processLint: true, lintFile: ".phabricator-lint"]) } else { - step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true]) + step([$class: 'PhabricatorNotifier', commentWithConsoleLinkOnFailure: true, processLint: true, lintFile: ".phabricator-lint"]) } } catch(e) { throw e diff --git a/build/jenkins/pipelines/macos-differential.Jenkinsfile b/build/jenkins/pipelines/macos-differential.Jenkinsfile index aeb98e399d..e077a48fb1 100644 --- a/build/jenkins/pipelines/macos-differential.Jenkinsfile +++ b/build/jenkins/pipelines/macos-differential.Jenkinsfile @@ -69,7 +69,7 @@ pipeline { } stage("Debug Build & Tests") { steps { - sh "cd build/workspaces/gcc/ && make -j4 config=debug" + sh "cd build/workspaces/gcc/ && make -j4 config=debug 2> ../../../builderr-debug-macos.txt" script { try { sh "binaries/system/test_dbg > cxxtest-debug.xml" @@ -84,7 +84,7 @@ pipeline { } stage("Release Build & Tests") { steps { - sh "cd build/workspaces/gcc/ && make -j4 config=release" + sh "cd build/workspaces/gcc/ && make -j4 config=release 2> ../../../builderr-release-macos.txt" script { try { sh "binaries/system/test > cxxtest-release.xml" @@ -101,11 +101,33 @@ pipeline { post { always { - step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true]) - sh "rm -f cxxtest_*.xml" - sh "svn revert -R ." - sh "svn st binaries/data/ | cut -c 9- | xargs rm -rf" - sh "svn st source/ | cut -c 9- | xargs rm -rf" + script { + catchError { + sh ''' + for file in builderr-*.txt ; do + if [ -s "$file" ]; then + echo "$file" >> .phabricator-comment + cat "$file" >> .phabricator-comment + fi + done + ''' + } + + try { + if (fileExists(".phabricator-comment")) { + step([$class: 'PhabricatorNotifier', commentOnSuccess: true, commentWithConsoleLinkOnFailure: true, customComment: true, commentFile: ".phabricator-comment"]) + } else { + step([$class: 'PhabricatorNotifier', commentWithConsoleLinkOnFailure: true]) + } + } catch(e) { + throw e + } finally { + sh "rm -f .phabricator-comment builderr-*.txt cxxtest_*.xml" + sh "svn revert -R ." + sh "svn st binaries/data/ | cut -c 9- | xargs rm -rf" + sh "svn st source/ | cut -c 9- | xargs rm -rf" + } + } } } }