5 # This script allows Jenkins to build and test a patch inside the phabricator
8 # The important thing is determining how much cleanup is needed. For instance,
9 # if a patch adds a source file, it is necessary to delete it afterwards and
10 # remove all related build artifacts. It will also be necessary to rebuild the game
11 # for testing the next patch, even if that new patch doesn't change the code.
13 # However, rebuilding everything each time is expensive and prevents us from
14 # handling a decent input of patches on Phabricator.
16 # This script does its best to determine a somewhat minimal necessary amount of
17 # cleanup, and resorts to a clean checkout in case of failure.
19 if [ -z "$DIFF_ID" ]; then
20 echo 'No patch ID provided, aborting'
27 # Move to the root of the repository (this script is in build/jenkins/)
28 cd "$(dirname $0)"/..
/..
/
36 # Revert previously applied changes or deleted files (see full_cleanup).
39 # Removing non-ignored files from binaries/data/ might be necessary and
40 # doesn't impact the build, so do it each time.
41 svn status binaries
/data
/ | cut
-c 9- |
xargs rm -rf
43 # If we have non-ignored files under source/, we must delete them and
44 # clean the workspaces.
45 if [ "$(svn status source/)" ]; then
46 svn status source
/ | cut
-c 9- |
xargs rm -rf
47 build
/workspaces
/clean-workspaces.sh
--preserve-libs
51 # Patch errors (including successful hunks) are written to the Phab comment.
52 # If patching is successful, this will be overwritten in the build() step.
53 # If patching fails, the comment will be explicit about it.
54 arc
patch --diff "$DIFF_ID" --force 2> .phabricator-comment
60 svn st
--no-ignore | cut
-c 9- |
xargs rm -rf
61 patch # patch will revert everything, so don't worry about deleted files
67 echo 'Updating workspaces...'
68 build
/workspaces
/update-workspaces.sh
"${JOBS}" --with-system-nvtt --without-miniupnpc >/dev
/null ||
echo 'Updating workspaces failed!'
69 cd build
/workspaces
/gcc
70 echo 'Build (release)...'
71 make "${JOBS}" config
=release
2>&1 1>/dev
/null
72 echo 'Build (debug)...'
73 make "${JOBS}" config
=debug
2>&1 1>/dev
/null
74 cd ..
/..
/..
/binaries
/system
75 echo 'Running release tests...'
77 echo 'Running debug tests...'
79 cd ..
/..
/source
/tools
/xmlvalidator
80 echo 'Checking XML files...'
81 perl validate.pl
2>&1 1>/dev
/null
82 } > .phabricator-comment
86 # Try to patch, if that manages to fail, clean up everything.
87 # If it patches, make sure the libraries are not touched.
90 elif svn status libraries
/source
/ |
grep -v '^?' >/dev
/null
2>&1; then
94 # Try to build, if that fails, clean up everything.
95 if ! build
&& [ "$fully_cleaned" != true
]; then