Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022-2023 Savoir-faire Linux Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Affero General Public License as |
| 6 | * published by the Free Software Foundation; either version 3 of the |
| 7 | * License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Affero General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Affero General Public |
| 15 | * License along with this program. If not, see |
| 16 | * <https://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | // Requirements: |
| 20 | // - gerrit-trigger plugin |
| 21 | // - Docker plugin |
| 22 | // - ansicolor plugin |
| 23 | |
| 24 | pipeline { |
| 25 | agent { |
| 26 | node { |
| 27 | label 'jami-buildmachine-04.mtl.sfl' |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | triggers { |
| 32 | gerrit customUrl: '', |
| 33 | gerritProjects: [ |
| 34 | [branches: [[compareType: 'PLAIN', pattern: 'master']], |
| 35 | compareType: 'PLAIN', |
| 36 | disableStrictForbiddenFileVerification: false, |
| 37 | pattern: 'jami-plugins']], |
| 38 | triggerOnEvents: [ |
| 39 | commentAddedContains('!build'), |
| 40 | patchsetCreated(excludeDrafts: true, excludeNoCodeChange: true, |
| 41 | excludeTrivialRebase: true)] |
| 42 | } |
| 43 | |
| 44 | options { |
| 45 | ansiColor('xterm') |
| 46 | } |
| 47 | |
| 48 | parameters { |
| 49 | string(name: 'GERRIT_REFSPEC', |
| 50 | defaultValue: 'refs/heads/master', |
Aline Gondim Santos | 92998b3 | 2023-06-05 10:21:54 -0300 | [diff] [blame] | 51 | description: 'The Gerrit plugins refspec to fetch.') |
Aline Gondim Santos | 4bea163 | 2023-06-05 11:26:29 -0300 | [diff] [blame] | 52 | string(name: 'DAEMON_REFSPEC', |
| 53 | defaultValue: 'refs/heads/master', |
| 54 | description: 'The Gerrit daemon refspec to fetch.') |
| 55 | string(name: 'dockerfile', |
| 56 | defaultValue: 'Dockerfile_ubuntu_20.04_onnxruntime', |
| 57 | description: 'Dockerfile in plugins/docker/ repository to use for the build') |
| 58 | string(name: 'GERRIT_TOPIC', |
| 59 | defaultValue: '', |
| 60 | description: 'topic must match the plugins name if the pipeline is to build that plugins.') |
| 61 | } |
| 62 | |
| 63 | environment { |
| 64 | jenkinsUID = sh(returnStdout: true, script: 'id -u jenkins').replaceAll("\n", '').trim() |
| 65 | jenkinsGID = sh(returnStdout: true, script: 'id -g jenkins').replaceAll("\n", '').trim() |
| 66 | jenkinsUser = '${jenkinsUID}:${jenkinsGID}' |
| 67 | cpuCount = sh returnStdout: true, script: 'nproc || echo -n 4' |
Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | stages { |
| 71 | stage('SCM Checkout') { |
| 72 | steps { |
| 73 | // Wipe workspace and fetch jami-plugins |
| 74 | checkout changelog: true, poll: false, |
| 75 | scm: [$class: 'GitSCM', |
| 76 | branches: [[name: 'FETCH_HEAD']], |
| 77 | doGenerateSubmoduleConfigurations: false, |
| 78 | extensions: [ |
| 79 | [$class: 'CloneOption', noTags: true, reference: '', shallow: true], |
| 80 | [$class: 'WipeWorkspace']], |
| 81 | submoduleCfg: [], |
| 82 | userRemoteConfigs: [[refspec: '${GERRIT_REFSPEC}', url: 'https://${JAMI_GERRIT_URL}/jami-plugins']]] |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | stage('Init repository') { |
| 87 | steps { |
| 88 | script { |
| 89 | sh """ |
Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 90 | git rev-parse HEAD |
| 91 | git submodule update --init --recursive |
| 92 | """ |
| 93 | if (env.DAEMON_REFSPEC != null) { |
| 94 | sh """ |
| 95 | cd daemon |
| 96 | git fetch origin ${DAEMON_REFSPEC} && git checkout FETCH_HEAD |
Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 97 | """ |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
Aline Gondim Santos | 4bea163 | 2023-06-05 11:26:29 -0300 | [diff] [blame] | 103 | stage('Building Docker Image') { |
| 104 | steps { |
| 105 | script { |
| 106 | docker.build('plugins-linux', "-f docker/${dockerfile} --no-cache .") |
| 107 | } |
| 108 | } |
| 109 | } |
Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 110 | |
Aline Gondim Santos | 4bea163 | 2023-06-05 11:26:29 -0300 | [diff] [blame] | 111 | stage('Setup and Build Dependencies') { |
| 112 | steps { |
| 113 | script { |
| 114 | def jenkinsUID = sh(returnStdout: true, script: 'id -u jenkins').replaceAll("\n", '').trim() |
| 115 | def jenkinsGID = sh(returnStdout: true, script: 'id -g jenkins').replaceAll("\n", '').trim() |
| 116 | def jenkinsUser = jenkinsUID+':'+jenkinsGID |
| 117 | def cpuCount = sh returnStdout: true, script: 'nproc || echo -n 4' |
| 118 | docker.image('plugins-linux').withRun('-t -u '+jenkinsUser+' -v '+pwd()+':/root/jami/:rw -w /root/ -e BATCH_MODE=1', '/bin/bash') { |
| 119 | container -> code:{ |
| 120 | def base_cmd = 'docker exec -t '+container.id+" sh -c '" |
| 121 | def exec_cmd = { cmd -> sh base_cmd+cmd+"'" } |
Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 122 | |
Aline Gondim Santos | 4bea163 | 2023-06-05 11:26:29 -0300 | [diff] [blame] | 123 | ansiColor('css') { |
| 124 | exec_cmd(""" |
| 125 | pwd |
| 126 | cd ./jami/daemon/contrib |
| 127 | mkdir native |
| 128 | cd native |
| 129 | ../bootstrap --enable-ffmpeg --disable-argon2 --disable-asio --enable-fmt --disable-gcrypt --disable-gmp --disable-gnutls --disable-gpg-error --disable-gsm --disable-http_parser --disable-iconv --disable-jack --disable-jsoncpp --disable-libarchive --disable-libressl --disable-msgpack --disable-natpmp --disable-nettle --enable-opencv --disable-opendht --disable-pjproject --disable-portaudio --disable-restinio --disable-secp256k1 --disable-speexdsp --disable-upnp --disable-uuid --disable-yaml-cpp --disable-zlib |
| 130 | make list |
| 131 | make -j${cpuCount} |
| 132 | """) |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 139 | |
Aline Gondim Santos | 4bea163 | 2023-06-05 11:26:29 -0300 | [diff] [blame] | 140 | stage('Build GreenScreen cpu') { |
| 141 | steps { |
| 142 | script { |
| 143 | if(env.GERRIT_TOPIC == "all" || env.GERRIT_TOPIC == "GreenScreen") { |
| 144 | docker.image('plugins-linux').withRun('-t -u '+jenkinsUser+' -v '+pwd()+':/root/jami/:rw -w /root/ -e BATCH_MODE=1', '/bin/bash') { |
| 145 | container -> code:{ |
| 146 | def base_cmd = 'docker exec -t '+container.id+" sh -c '" |
| 147 | def exec_cmd = { cmd -> sh base_cmd+cmd+"'" } |
| 148 | |
| 149 | ansiColor('css') { |
| 150 | exec_cmd(""" |
| 151 | cd jami |
| 152 | AUTHOR="SFL" DIVISION="Internal" python3 build-plugin.py --projects="GreenScreen" |
| 153 | """) |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | if (!fileExists("./build/x86_64-linux-gnu/cpu/GreenScreen.jpl")) { |
| 158 | error "GreenScreen build output not found" |
| 159 | } |
| 160 | archiveArtifacts 'build/x86_64-linux-gnu/cpu/GreenScreen.jpl' |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | stage('Build GreenScreen nvidia-gpu') { |
| 167 | steps { |
| 168 | script { |
| 169 | if(env.GERRIT_TOPIC == "all" || env.GERRIT_TOPIC == "GreenScreen") { |
| 170 | docker.image('plugins-linux').withRun('-t -u '+jenkinsUser+' -v '+pwd()+':/root/jami/:rw -w /root/ -e BATCH_MODE=1', '/bin/bash') { |
| 171 | container -> code:{ |
| 172 | def base_cmd = 'docker exec -t '+container.id+" sh -c '" |
| 173 | def exec_cmd = { cmd -> sh base_cmd+cmd+"'" } |
| 174 | |
| 175 | ansiColor('css') { |
| 176 | exec_cmd(""" |
| 177 | cd jami |
| 178 | AUTHOR="SFL" DIVISION="Internal" PROCESSOR=NVIDIA python3 build-plugin.py --projects="GreenScreen" |
| 179 | """) |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | if (!fileExists("./build/x86_64-linux-gnu/nvidia-gpu/GreenScreen.jpl")) { |
| 184 | error "GreenScreen build output not found" |
| 185 | } |
| 186 | archiveArtifacts 'build/x86_64-linux-gnu/nvidia-gpu/GreenScreen.jpl' |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | stage('Build AudioFilter') { |
| 193 | steps { |
| 194 | script { |
| 195 | if(env.GERRIT_TOPIC == "all" || env.GERRIT_TOPIC == "AudioFilter") { |
| 196 | docker.image('plugins-linux').withRun('-t -u '+jenkinsUser+' -v '+pwd()+':/root/jami/:rw -w /root/ -e BATCH_MODE=1', '/bin/bash') { |
| 197 | container -> code:{ |
| 198 | def base_cmd = 'docker exec -t '+container.id+" sh -c '" |
| 199 | def exec_cmd = { cmd -> sh base_cmd+cmd+"'" } |
| 200 | |
| 201 | ansiColor('css') { |
| 202 | exec_cmd(""" |
| 203 | cd jami |
| 204 | AUTHOR="SFL" DIVISION="Internal" python3 build-plugin.py --projects="AudioFilter" |
| 205 | """) |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | if (!fileExists("./build/x86_64-linux-gnu/AudioFilter.jpl")) { |
| 210 | error "AudioFilter build output not found" |
| 211 | } |
| 212 | archiveArtifacts 'build/x86_64-linux-gnu/AudioFilter.jpl' |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | stage('Build AutoAnswer') { |
| 219 | steps { |
| 220 | script { |
| 221 | if(env.GERRIT_TOPIC == "all" || env.GERRIT_TOPIC == "AutoAnswer") { |
| 222 | docker.image('plugins-linux').withRun('-t -u '+jenkinsUser+' -v '+pwd()+':/root/jami/:rw -w /root/ -e BATCH_MODE=1', '/bin/bash') { |
| 223 | container -> code:{ |
| 224 | def base_cmd = 'docker exec -t '+container.id+" sh -c '" |
| 225 | def exec_cmd = { cmd -> sh base_cmd+cmd+"'" } |
| 226 | |
| 227 | ansiColor('css') { |
| 228 | exec_cmd(""" |
| 229 | cd jami |
| 230 | AUTHOR="SFL" DIVISION="Internal" python3 build-plugin.py --projects="AutoAnswer" |
| 231 | """) |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | if (!fileExists("./build/x86_64-linux-gnu/AutoAnswer.jpl")) { |
| 236 | error "AutoAnswer build output not found" |
| 237 | } |
| 238 | archiveArtifacts 'build/x86_64-linux-gnu/AutoAnswer.jpl' |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | stage('Build WaterMark') { |
| 245 | steps { |
| 246 | script { |
| 247 | if(env.GERRIT_TOPIC == "all" || env.GERRIT_TOPIC == "WaterMark") { |
| 248 | docker.image('plugins-linux').withRun('-t -u '+jenkinsUser+' -v '+pwd()+':/root/jami/:rw -w /root/ -e BATCH_MODE=1', '/bin/bash') { |
| 249 | container -> code:{ |
| 250 | def base_cmd = 'docker exec -t '+container.id+" sh -c '" |
| 251 | def exec_cmd = { cmd -> sh base_cmd+cmd+"'" } |
| 252 | |
| 253 | ansiColor('css') { |
| 254 | exec_cmd(""" |
| 255 | cd jami |
| 256 | AUTHOR="SFL" DIVISION="Internal" python3 build-plugin.py --projects="WaterMark" |
| 257 | """) |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | if (!fileExists("./build/x86_64-linux-gnu/WaterMark.jpl")) { |
| 262 | error "WaterMark build output not found" |
| 263 | } |
| 264 | archiveArtifacts 'build/x86_64-linux-gnu/WaterMark.jpl' |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | stage('Build Whisper') { |
| 271 | steps { |
| 272 | script { |
| 273 | if(env.GERRIT_TOPIC == "all" || env.GERRIT_TOPIC == "Whisper" || env.GERRIT_TOPIC == "WhisperTranscript") { |
| 274 | docker.image('plugins-linux').withRun('-t -u '+jenkinsUser+' -v '+pwd()+':/root/jami/:rw -w /root/ -e BATCH_MODE=1', '/bin/bash') { |
| 275 | container -> code:{ |
| 276 | def base_cmd = 'docker exec -t '+container.id+" sh -c '" |
| 277 | def exec_cmd = { cmd -> sh base_cmd+cmd+"'" } |
| 278 | |
| 279 | ansiColor('css') { |
| 280 | exec_cmd(""" |
| 281 | cd jami |
| 282 | AUTHOR="SFL" DIVISION="Internal" python3 build-plugin.py --projects="WhisperTranscript" |
| 283 | """) |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | if (!fileExists("./build/x86_64-linux-gnu/WhisperTranscript.jpl")) { |
| 288 | error "WhisperTranscript build output not found" |
| 289 | } |
| 290 | archiveArtifacts 'build/x86_64-linux-gnu/WhisperTranscript.jpl' |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | } |
Xavier Jouslin de Noray | d0f1cb4 | 2023-06-09 10:02:25 -0400 | [diff] [blame^] | 295 | |
| 296 | stage('Build test dependencies') { |
| 297 | steps { |
| 298 | sh 'pip install -r ./SDK/certificate_requirements.txt' |
| 299 | sh 'pip install -r ./SDK/requirements.txt' |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | stage('Test Certificate') { |
| 304 | steps { |
| 305 | sh 'PYTHONPATH="./SDK/" python3 ./extras/tests/CertificateTester.py' |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | stage('Test Plugin Certificate') { |
| 310 | steps { |
| 311 | sh 'PYTHONPATH="./SDK/" python3 ./extras/tests/PluginCertificateTester.py' |
| 312 | } |
| 313 | } |
Aline Gondim Santos | e6b8e1d | 2023-06-05 08:57:00 -0300 | [diff] [blame] | 314 | } |
| 315 | } |