AusweisApp2/resources/jenkins/dsl/Reviews/Review_Formatting.groovy

65 lines
1.3 KiB
Groovy
Raw Normal View History

2017-07-03 09:30:10 +02:00
import common.Review
import static common.Constants.strip
def j = new Review
(
name: 'Formatting',
label: 'Common'
).generate(this)
j.with
{
2017-12-20 14:54:05 +01:00
concurrentBuild()
2017-07-03 09:30:10 +02:00
steps
{
shell('''\
cd source
2017-12-20 14:54:05 +01:00
hg revert -a -C
2017-07-03 09:30:10 +02:00
hg --config extensions.hgext.purge= purge --all
hg --config extensions.hgext.strip= strip -r 'secret() or draft()' --no-backup --force 2>/dev/null || echo "No changeset stripped"
'''.stripIndent().trim())
2017-12-20 14:54:05 +01:00
shell('cd build; cmake -Werror=dev ../source -Dtools.only=true')
2017-07-03 09:30:10 +02:00
shell('''\
cd build
make format
cd ../source
STATUS=$(hg status | wc -c)
if [ "$STATUS" != "0" ]; then
2017-12-20 14:54:05 +01:00
echo 'Current repository state is not formatted!'
2017-07-03 09:30:10 +02:00
hg addremove
2017-12-20 14:54:05 +01:00
hg diff
2017-07-03 09:30:10 +02:00
hg commit -m "fix formatting" -s
fi
(hg --config phases.new-commit=secret import -m 'jenkins patch formatting' -d 'today' -u 'jenkins' ../patch.diff)
if [ "$?" != "0" ]; then
echo 'FORMATTING FAILED: Patch cannot be applied'
exit 0
fi
cd ../build
make rebuild_cache
make format
cd ../source
STATUS=$(hg status | wc -c)
if [ "$STATUS" != "0" ]; then
echo 'FORMATTING FAILED: Patch is not formatted'
2017-12-20 14:54:05 +01:00
hg diff
hg revert -a -C
2017-07-03 09:30:10 +02:00
exit 0
fi
'''.stripIndent().trim())
}
publishers
{
textFinder('FORMATTING FAILED', '', true, false, true)
}
}