Fixes and improvements to the CI pipelines.

- Custom fixes to coala: support python3.8 and recent versions of
cppcheck
- Adapt .coafile to current coala
- Adapt LicenseYearBear to current `svn` python package
- Move the linter configuration to the coala directory
- Remove the now unused lint-patch script
- Update Jenkins pipelines to report build stderr as a comment on Unix
(including warnings when the build succeeds), and to report lint issues
inline

Tested on Jenkins during the past week.

Differential Revision: https://code.wildfiregames.com/D2931
This was SVN commit r23971.
This commit is contained in:
Nicolas Auvray 2020-08-18 12:47:09 +00:00
parent 78d973c11e
commit de53e2ac44
8 changed files with 103 additions and 42 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"
}
}
}
}
}