| pipeline { |
| agent { |
| docker { |
| registryUrl 'https://ci.trafficserver.apache.org/' |
| image 'ci.trafficserver.apache.org/ats/rockylinux:8' |
| args '--init --cap-add=SYS_PTRACE --network=host -v ${HOME}/ccache:/tmp/ccache:rw' |
| label 'branch' |
| } |
| } |
| |
| environment { |
| CCACHE_DIR = "/tmp/ccache" |
| } |
| |
| stages { |
| stage('Initialization') { |
| steps { |
| script { |
| if (env.SHA1) { |
| currentBuild.description = env.SHA1 |
| } |
| if (env.AUTEST_SHARD) { |
| String[] arr = env.AUTEST_SHARD.split('of') |
| if (2 == arr.length) { |
| shard = arr[0] as int |
| shardcnt = arr[1] as int |
| if (shard < shardcnt) { |
| env.SHARD = shard |
| env.SHARDCNT = shardcnt |
| currentBuild.displayName = "#${BUILD_NUMBER} ${GITHUB_BRANCH} ${AUTEST_SHARD}" |
| } |
| } |
| } |
| |
| if (!env.SHARD || ! env.SHARDCNT) { |
| currentBuild.displayName = "#${BUILD_NUMBER} ${GITHUB_BRANCH}" |
| env.SHARD = 0 |
| env.SHARDCNT = 0 |
| } |
| } |
| } |
| } |
| |
| stage('Clone') { |
| steps { |
| dir('ci') { |
| git url: 'https://github.com/apache/trafficserver-ci', |
| branch: 'main' |
| } |
| dir('src') { |
| script { |
| String branch = env.SHA1 |
| if (! branch) { |
| branch = '*/' + env.GITHUB_BRANCH |
| } |
| |
| timeout(time: 1, unit: 'MINUTES') { |
| retry(3) { |
| checkout([$class: 'GitSCM', |
| branches: [[name: branch]], |
| userRemoteConfigs: [[url: env.GITHUB_URL]], |
| extensions: [[$class: 'CloneOption', timeout: 10]] |
| ]) |
| } |
| } |
| } |
| } |
| |
| echo 'Finished Cloning' |
| } |
| } |
| stage('Build') { |
| steps { |
| echo 'Starting build' |
| dir('src') { |
| sh ''' |
| source /opt/rh/gcc-toolset-11/enable |
| sudo update-crypto-policies --set LEGACY |
| |
| # We want to pick up the OpenSSL-QUIC version of curl in /opt/bin. |
| # The HTTP/3 AuTests depend upon this, so update the PATH accordingly. |
| export PATH=/opt/bin:${PATH} |
| |
| # Change permissions so that all files are readable |
| # (default user umask may change and make these unreadable) |
| sudo chmod -R o+r . |
| autoreconf -fiv |
| ./configure --enable-experimental-plugins --enable-example-plugins --prefix=/tmp/ats --enable-werror --enable-debug --enable-wccp --enable-luajit --enable-ccache |
| make -j4 |
| make install |
| ''' |
| } |
| } |
| } |
| |
| stage('AuTest') { |
| steps { |
| echo 'Starting AuTest' |
| dir('src/tests') { |
| |
| sh '''#!/bin/bash -x |
| #set +e |
| # We want to pick up the OpenSSL-QUIC version of curl in /opt/bin. |
| # The HTTP/3 AuTests depend upon this, so update the PATH accordingly. |
| export PATH=/opt/bin:${PATH} |
| |
| mkdir -p ${WORKSPACE}/output/${GITHUB_BRANCH} |
| |
| if [ ${SHARDCNT} -le 0 ]; then |
| ./autest.sh --ats-bin /tmp/ats/bin/ --sandbox /tmp/sandbox || true |
| else |
| testsall=( $( find . -iname "*.test.py" | awk -F'/' '{print $NF}' | awk -F'.' '{print $1}' ) ) |
| |
| testsall=( $( |
| for el in "${testsall[@]}" ; do |
| echo $el |
| done | sort) ) |
| ntests=${#testsall[@]} |
| |
| shardsize=$((${ntests} / ${SHARDCNT})) |
| [ 0 -ne $((${ntests} % ${shardsize})) ] && shardsize=$((${shardsize} + 1)) |
| shardbeg=$((${shardsize} * ${SHARD})) |
| sliced=${testsall[@]:${shardbeg}:${shardsize}} |
| ./autest.sh --ats-bin /tmp/ats/bin/ --sandbox /tmp/sandbox -f ${sliced[@]} || true |
| |
| exit |
| fi |
| |
| if [ -n "$(ls -A /tmp/sandbox/)" ]; then |
| cp -rf /tmp/sandbox/ ${WORKSPACE}/output/${GITHUB_BRANCH}/ |
| sudo chmod -R 777 ${WORKSPACE} |
| exit 1 |
| else |
| sudo touch ${WORKSPACE}/output/${GITHUB_BRANCH}/No_autest_failures |
| sudo chmod -R 777 ${WORKSPACE} |
| exit 0 |
| fi |
| ''' |
| } |
| } |
| } |
| } |
| |
| post { |
| always { |
| // We exclude socket files because archiveArtifacts doesn't deal well with |
| // their file type. |
| archiveArtifacts artifacts: 'output/**/*', fingerprint: false, allowEmptyArchive: true, excludes: '**/*.sock, **/cache.db' |
| } |
| cleanup { |
| cleanWs() |
| } |
| } |
| } |