1 | #!groovy
|
---|
2 |
|
---|
3 | node ('master') {
|
---|
4 |
|
---|
5 | user_email = ''
|
---|
6 | test_list = ''
|
---|
7 |
|
---|
8 | prepare_build()
|
---|
9 |
|
---|
10 | try {
|
---|
11 |
|
---|
12 | stage('Checkout') {
|
---|
13 | checkout scm
|
---|
14 |
|
---|
15 | sh 'git clean -xdf'
|
---|
16 |
|
---|
17 | sh 'git reset --hard'
|
---|
18 | }
|
---|
19 |
|
---|
20 | stage('Building x86') {
|
---|
21 | regen_tests('i386')
|
---|
22 | }
|
---|
23 |
|
---|
24 | stage('Building x64') {
|
---|
25 | regen_tests('x86_64')
|
---|
26 | }
|
---|
27 |
|
---|
28 | stage('Building arm64') {
|
---|
29 | regen_tests('arm64')
|
---|
30 | }
|
---|
31 |
|
---|
32 | stage('Patching') {
|
---|
33 | make_patch()
|
---|
34 | }
|
---|
35 |
|
---|
36 | stage('Email') {
|
---|
37 | email()
|
---|
38 | }
|
---|
39 | }
|
---|
40 | catch (Exception caughtError) {
|
---|
41 | email_error()
|
---|
42 |
|
---|
43 | throw caughtError
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | def prepare_build() {
|
---|
48 | properties ([ \
|
---|
49 | [$class: 'ParametersDefinitionProperty', \
|
---|
50 | parameterDefinitions: [ \
|
---|
51 | [$class: 'StringParameterDefinition', \
|
---|
52 | description: 'Who required the test', \
|
---|
53 | name: 'pEmail', \
|
---|
54 | ], \
|
---|
55 | [$class: 'StringParameterDefinition', \
|
---|
56 | description: 'Space separated list of tests to run', \
|
---|
57 | name: 'pTests', \
|
---|
58 | ], \
|
---|
59 | ],
|
---|
60 | ]])
|
---|
61 |
|
---|
62 | user_email = pEmail;
|
---|
63 | test_list = pTests;
|
---|
64 |
|
---|
65 | echo "User ${user_email} requested regenerating tests : ${ test_list }"
|
---|
66 | }
|
---|
67 |
|
---|
68 | def regen_tests( String arch ) {
|
---|
69 |
|
---|
70 | def install_dir = pwd tmp: true
|
---|
71 |
|
---|
72 | //Configure the conpilation (Output is not relevant)
|
---|
73 | //Use the current directory as the installation target so nothing
|
---|
74 | //escapes the sandbox
|
---|
75 | //Also specify the compiler by hand
|
---|
76 | sh "./configure CXX=clang++ CC=gcc-6 --host=${arch} --enable-silent-rules --quiet"
|
---|
77 |
|
---|
78 | //Compile the project
|
---|
79 | sh 'make -j 8 --no-print-directory'
|
---|
80 |
|
---|
81 | //Regenerate the desired tests
|
---|
82 | sh "src/tests/test.py --regenerate-expected ${test_list}"
|
---|
83 |
|
---|
84 | //Clean everything from the last build
|
---|
85 | sh 'make maintainer-clean > /dev/null'
|
---|
86 | }
|
---|
87 |
|
---|
88 | def make_patch() {
|
---|
89 |
|
---|
90 | def target_dir = pwd tmp: true
|
---|
91 |
|
---|
92 | //Add every file so new files appear in the diff
|
---|
93 | sh 'git add .'
|
---|
94 |
|
---|
95 | //Create a patch file
|
---|
96 | sh "git diff --cached --binary > ${target_dir}/result.patch"
|
---|
97 | }
|
---|
98 |
|
---|
99 | def email() {
|
---|
100 |
|
---|
101 | def target_dir = pwd tmp: true
|
---|
102 |
|
---|
103 | dir( target_dir ) {
|
---|
104 |
|
---|
105 | def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - Result"
|
---|
106 | def email_body = """This is an automated email from the Jenkins build machine. It was
|
---|
107 | generated https://cforall.uwaterloo.ca:8082/dashboard.html.
|
---|
108 |
|
---|
109 | Please apply the required changes using the following method :
|
---|
110 | - copy result.patch to your cforall repository of choice.
|
---|
111 | - call 'git apply [patch file name]' (WARNING: the changes may conflict with any current changes to the test expected results).
|
---|
112 | - validate that the changes are correct.
|
---|
113 | - commit the changes as usual."""
|
---|
114 |
|
---|
115 | //send email notification
|
---|
116 | emailext body: email_body, subject: email_subject, to: user_email, attachmentsPattern: "**/*.patch"
|
---|
117 | }
|
---|
118 | }
|
---|
119 |
|
---|
120 | def email_error() {
|
---|
121 |
|
---|
122 | def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - FAILURE"
|
---|
123 | def email_body = """This is an automated email from the Jenkins build machine. It was
|
---|
124 | generated https://cforall.uwaterloo.ca:8082/dashboard.html.
|
---|
125 |
|
---|
126 | Test generation encoutered an error please see attached logs
|
---|
127 |
|
---|
128 | -----------------------------------------------------------------------"""
|
---|
129 |
|
---|
130 | //send email notification
|
---|
131 | emailext body: email_body, subject: email_subject, to: user_email, attachLog: true
|
---|
132 | }
|
---|