You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ez...@apache.org on 2021/03/25 21:45:43 UTC

[trafficserver-ci] branch main updated: Adding github PR pipelines and toplevel so far. These are still a work in progress

This is an automated email from the ASF dual-hosted git repository.

eze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/trafficserver-ci.git


The following commit(s) were added to refs/heads/main by this push:
     new 346ae6e  Adding github PR pipelines and toplevel so far. These are still a work in progress
     new 24f9161  Merge pull request #9 from ezelkow1/main
346ae6e is described below

commit 346ae6e4169c86c50da0edf068c4ce57276f4892
Author: Evan Zelkowitz <ev...@gmail.com>
AuthorDate: Thu Mar 25 14:44:05 2021 -0700

    Adding github PR pipelines and toplevel so far. These are still a work in progress
---
 jenkins/github/README                  |  18 ++++
 jenkins/github/centos.pipeline         |  45 ++++++++++
 jenkins/github/clang-analyzer.pipeline |  55 ++++++++++++
 jenkins/github/clang-format.pipeline   |  74 ++++++++++++++++
 jenkins/github/fedora.pipeline         |  51 +++++++++++
 jenkins/github/rat.pipeline            |  49 +++++++++++
 jenkins/github/toplevel.pipeline       | 150 +++++++++++++++++++++++++++++++++
 jenkins/github/ubuntu-clang.pipeline   |  44 ++++++++++
 jenkins/github/ubuntu.pipeline         |  44 ++++++++++
 9 files changed, 530 insertions(+)

diff --git a/jenkins/github/README b/jenkins/github/README
new file mode 100644
index 0000000..99c8bfa
--- /dev/null
+++ b/jenkins/github/README
@@ -0,0 +1,18 @@
+To set these up setup a top level pipeline first with:
+ - github project url set
+ - string paramter of SHA1
+ - github pull requests build trigger - Hooks with persisted data
+	- cancel queued
+	- abort running
+	- trigger on:
+		- comment pattern ".*\[approve\W+ci(.*)\]"
+		- pull request opened
+		- commit changed
+		- not merged - skip
+
+Each Individual build pipeline needs to have parameters of:
+	- SHA1
+	- GITHUB_URL
+
+and clang-analyzer also needs:
+	- GITHUB_PR_NUMBER
diff --git a/jenkins/github/centos.pipeline b/jenkins/github/centos.pipeline
new file mode 100644
index 0000000..92dfab0
--- /dev/null
+++ b/jenkins/github/centos.pipeline
@@ -0,0 +1,45 @@
+pipeline {
+    agent {
+        docker {
+            image 'controller.trafficserver.org/ats/centos:8'
+            registryUrl 'https://controller.trafficserver.org/'
+            label 'docker'
+        }
+    }
+    stages {
+        stage('Clone') {
+            steps {
+                dir('src') {
+                    echo "${sha1}"
+                    checkout([$class: 'GitSCM',
+                        branches: [[name: sha1]],
+                        extensions: [],
+                        //+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/merge
+                        userRemoteConfigs: [[url: github_url, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/${sha1}/merge:refs/remotes/origin/pull/${sha1}/merge']]])
+                    sh 'head -1 README'
+                }
+                echo 'Finished Cloning'
+            }
+        }
+        stage('Build') {
+            steps {
+                echo 'Starting build'
+                dir('src') {
+                    sh('head -1 README')
+                    sh('source /opt/rh/gcc-toolset-9/enable')
+                    sh('autoreconf -fiv')
+                    sh('./configure --enable-experimental-plugins')
+                    sh('make -j3')
+                }
+            }
+        }
+    }
+    
+    post { 
+        cleanup { 
+            cleanWs()
+        }
+    }
+}
diff --git a/jenkins/github/clang-analyzer.pipeline b/jenkins/github/clang-analyzer.pipeline
new file mode 100644
index 0000000..d3c8d17
--- /dev/null
+++ b/jenkins/github/clang-analyzer.pipeline
@@ -0,0 +1,55 @@
+pipeline {
+    agent {
+        docker {
+            image 'controller.trafficserver.org/ats/ubuntu:20.04'
+            registryUrl 'https://controller.trafficserver.org/'
+            args '-v /home/rooter/clang-analyzer:/tmp/clang-analyzer:rw'
+            label 'docker'
+        }
+    }
+    stages {
+        stage('Clone') {
+            steps {
+                dir('src') {
+                    echo "${sha1}"
+                    checkout([$class: 'GitSCM',
+                        branches: [[name: sha1]],
+                        extensions: [],
+                        //+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/merge
+                        userRemoteConfigs: [[url: github_url, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/${sha1}/merge:refs/remotes/origin/pull/${sha1}/merge']]])
+                    sh 'head -1 README'
+                }
+                echo 'Finished Cloning'
+            }
+        }
+        stage('Build') {
+            steps {
+                echo 'Starting build'
+                dir('src') {
+                    sh('head -1 README')
+                    sh('autoreconf -fiv')
+                    sh('scan-build-10 --keep-cc ./configure --enable-experimental-plugins --with-luajit')
+                    sh('make -j3 -C lib all-local V=1 Q=')
+                    sh '''scan-build-10 --keep-cc -enable-checker alpha.unix.cstring.BufferOverlap -enable-checker \
+                    alpha.core.BoolAssignment -enable-checker alpha.core.CastSize -enable-checker alpha.core.SizeofPtr \
+                    --status-bugs --keep-empty \
+                    -o /home/rooter/workspace/Github_Builds/clang-analyzer/output/${GITHUB_PR_NUMBER} --html-title="clang-analyzer: ${GITHUB_PR_NUMBER}" \
+                    make -j3 V=1 Q='''
+                    //sh('CC="clang" CXX="clang++" CXXFLAGS="-Qunused-arguments" WITH_LIBCPLUSPLUS="yes" ./configure --enable-experimental-plugins')
+                    sh('make -j3')
+                }
+            }
+        }
+    }
+    
+    post { 
+        success {
+            archiveArtifacts artifacts: 'output/**/*', fingerprint: true, allowEmptyArchive: true
+        }
+        cleanup { 
+            cleanWs()
+        }
+    }
+}
diff --git a/jenkins/github/clang-format.pipeline b/jenkins/github/clang-format.pipeline
new file mode 100644
index 0000000..5ba44a8
--- /dev/null
+++ b/jenkins/github/clang-format.pipeline
@@ -0,0 +1,74 @@
+pipeline {
+    agent {
+        docker {
+            image 'controller.trafficserver.org/ats/docs_build:30'
+            registryUrl 'https://controller.trafficserver.org/'
+            label 'docker'
+            // We need host networking for clang-format to download
+            args '--network host'
+        }
+    }
+    stages {
+        stage('Clone') {
+            steps {
+                dir('src') {
+                    echo "${sha1}"
+                    checkout([$class: 'GitSCM',
+                        branches: [[name: sha1]],
+                        extensions: [],
+                        userRemoteConfigs: [[url: github_url, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                    sh 'head -1 README'
+                }
+                echo 'Finished Cloning'
+            }
+        }
+        stage('Build') {
+            steps {
+                echo 'Starting build'
+                dir('src') {
+                    // STILL NEED TO MAKE CLANG_FORMAT IMG, Include Pip for pep8
+                    sh('head -1 README')
+                    sh '''#!/bin/bash
+                            git grep -IE ' +$' | fgrep -v '.gold:'
+                            if [ "1" != "$?" ]; then
+                                echo "Error: Trailing whitespaces are not allowed!"
+                                echo "Error: Please run: git grep -IE ' +$'"
+                                exit 1
+                            fi
+                            echo "Success! No trailing whitespace"
+                            git grep -IE $'\r$' | fgrep -v 'lib/yamlcpp'
+                            if [ "1" != "$?" ]; then
+                                echo "Error: Please make sure to run dos2unix on the above file(s)"
+                                exit 1
+                            fi
+                            echo "Success! No DOS carriage return"
+
+                            set -x
+
+                            autoreconf -if && ./configure && make clang-format
+                            [ "0" != "$?" ] && exit 1
+
+                            # Only enforce autopep8 on branches where the pre-commit hook was updated to
+                            # check it. Otherwise, none of the PRs for older branches will pass this check.
+                            if grep -q autopep8 tools/git/pre-commit; then
+                                make autopep8
+                                [ "0" != "$?" ] && exit 1
+                            fi
+
+                            git diff --exit-code
+                            [ "0" != "$?" ] && exit 1
+
+                            # Normal exit
+                            exit 0                            
+                        '''
+                }
+            }
+        }
+    }
+    
+    post { 
+        cleanup { 
+            cleanWs()
+        }
+    }
+}
diff --git a/jenkins/github/fedora.pipeline b/jenkins/github/fedora.pipeline
new file mode 100644
index 0000000..8322136
--- /dev/null
+++ b/jenkins/github/fedora.pipeline
@@ -0,0 +1,51 @@
+pipeline {
+    agent {
+        docker {
+            image 'ats/old_ci/fedora:30'
+            //registryUrl 'https://controller.trafficserver.org/'
+            args '-v /home/rooter/ccache:/tmp/ccache:rw'
+            label 'linux'
+        }
+    }
+    environment {
+        CCACHE_DIR = "/tmp/ccache"
+    }
+    stages {
+        stage('Clone') {
+            steps {
+                dir('src') {
+                    
+                    echo "${sha1}"
+                    checkout([$class: 'GitSCM',
+                        branches: [[name: sha1]],
+                        extensions: [],
+                        //+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/merge
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        userRemoteConfigs: [[url: github_url, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/${sha1}/merge:refs/remotes/origin/pull/${sha1}/merge']]])
+                    sh 'head -1 README'
+                }
+                echo 'Finished Cloning'
+            }
+        }
+        stage('Build') {
+            steps {
+                echo 'Starting build'
+                dir('src') {
+                    //sh('source ci/jenkins/bin/environment.sh && source ci/jenkins/bin/build.sh && ~jenkins/bin/regression.sh')
+                    sh('head -1 README')
+                    //sh('autoreconf -fiv')
+                    //sh('./configure --enable-experimental-plugins')
+                    //sh('./configure')
+                    //sh('make -j3')
+                }
+            }
+        }
+    }
+    post { 
+        cleanup { 
+            cleanWs()
+        }
+    }
+}
diff --git a/jenkins/github/rat.pipeline b/jenkins/github/rat.pipeline
new file mode 100644
index 0000000..9f3ed5a
--- /dev/null
+++ b/jenkins/github/rat.pipeline
@@ -0,0 +1,49 @@
+pipeline {
+    agent {
+        docker {
+            image 'controller.trafficserver.org/ats/docs_build:30'
+            registryUrl 'https://controller.trafficserver.org/'
+            label 'docker'
+            // We need host networking for clang-format to download
+            args '--network host'
+        }
+    }
+    stages {
+        stage('Clone') {
+            steps {
+                dir('src') {
+                    echo "${sha1}"
+                    checkout([$class: 'GitSCM',
+                        branches: [[name: sha1]],
+                        extensions: [],
+                        userRemoteConfigs: [[url: github_url, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                    sh 'head -1 README'
+                }
+                echo 'Finished Cloning'
+            }
+        }
+        stage('Build') {
+            steps {
+                echo 'Starting build'
+                dir('src') {
+                    // STILL NEED TO MAKE CLANG_FORMAT IMG, Include Pip for pep8
+                    sh('head -1 README')
+                    sh('autoreconf -if && ./configure')
+                    sh('rm -f lib/ts/stamp-h1')
+
+                    // Run RAT
+                    sh('make rat | tee RAT.txt')
+
+                    // Mark as failed if there are any unknown licesnes
+                    sh('grep \'0 Unknown Licenses\' RAT.txt > /dev/null || exit -1')
+                }
+            }
+        }
+    }
+    
+    post { 
+        cleanup { 
+            cleanWs()
+        }
+    }
+}
diff --git a/jenkins/github/toplevel.pipeline b/jenkins/github/toplevel.pipeline
new file mode 100644
index 0000000..7a5983d
--- /dev/null
+++ b/jenkins/github/toplevel.pipeline
@@ -0,0 +1,150 @@
+String buildJob(String ghcontext, String jobName) {
+        setGitHubPullRequestStatus(context: ghcontext, message: 'Building', state: 'PENDING')
+        def jobBuild = build job: jobName, propagate: false, parameters: [string(name: 'SHA1', value: GITHUB_PR_HEAD_SHA), string(name: 'GITHUB_URL', value: GITHUB_REPO_GIT_URL), string(name: 'GITHUB_PR_NUMBER', value: GITHUB_PR_NUMBER)]
+        def jobResult = jobBuild.getResult()
+        echo "Build of '${jobName}' returned result: ${jobResult}"
+
+        if (jobResult == 'SUCCESS') {
+            setGitHubPullRequestStatus(context: ghcontext, message: 'Success', state: jobResult)
+        } else {
+            setGitHubPullRequestStatus(context: ghcontext, message: 'Failure', state: jobResult)
+        }
+    return jobResult
+}
+
+pipeline {
+    agent none
+    
+    stages {
+        stage('Quick Checks') {
+            parallel {
+                stage('Clang-Format') {
+                    when {
+                        anyOf {
+                            environment name: 'GITHUB_PR_COMMENT_BODY_MATCH', value: ''
+                            expression { GITHUB_PR_COMMENT_BODY_MATCH ==~ /.*clang-format.*/ }
+                        }
+                    }
+                    steps {
+                        script {
+                            echo GITHUB_PR_COMMENT_BODY_MATCH
+                            result = buildJob('Clang-Format', 'Github_Builds/clang-format')
+                            if (result == 'FAILURE') {
+                                error('Clang-Format failed')
+                            }
+                        }
+                    }
+                }
+                stage('RAT') {
+                    when {
+                        anyOf {
+                            environment name: 'GITHUB_PR_COMMENT_BODY_MATCH', value: ''
+                            expression { GITHUB_PR_COMMENT_BODY_MATCH ==~ /.*RAT.*/ }
+                        }
+                    }
+                    steps {
+                        script {
+                            result = buildJob('RAT', 'Github_Builds/rat-build')
+                            if (result == 'FAILURE') {
+                                error('RAT failed')
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        
+        
+        stage('OS Builds') {
+            parallel {
+                stage('Ubuntu Build') {
+                    when {
+                        anyOf {
+                            environment name: 'GITHUB_PR_COMMENT_BODY_MATCH', value: ''
+                            expression { GITHUB_PR_COMMENT_BODY_MATCH ==~ /.*ubuntu.*/ }
+                        }
+                    }
+                    steps {
+                        script {
+                            result = buildJob('Ubuntu-test', 'Github_Builds/ubuntu-build-param')
+                            if (result == 'FAILURE') {
+                                error('Ubuntu build failed')
+                            }
+                        }
+                    }
+                }
+                stage('Fedora Build') {
+                    when {
+                        anyOf {
+                            environment name: 'GITHUB_PR_COMMENT_BODY_MATCH', value: ''
+                            expression { GITHUB_PR_COMMENT_BODY_MATCH ==~ /.*fedora.*/ }
+                        }
+                    }                    
+                    steps {
+                        script {
+                            result = buildJob('Fedora-test', 'Github_Builds/fedora-build-param')
+                            if (result == 'FAILURE') {
+                                error('Fedora build failed')
+                            }
+                        }
+                    }
+                }
+                stage('Debian Build') {
+                    when {
+                        anyOf {
+                            environment name: 'GITHUB_PR_COMMENT_BODY_MATCH', value: ''
+                            expression { GITHUB_PR_COMMENT_BODY_MATCH ==~ /.*debian.*/ }
+                        }
+                    }                    
+                    steps {
+                        script {
+                            result = buildJob('Debian-test', 'Github_Builds/debian-build-param')
+                            if (result == 'FAILURE') {
+                                error('Debian build failed')
+                            }
+                        }
+                    }
+                }
+                stage('CentOS Build') {
+                    when {
+                        anyOf {
+                            environment name: 'GITHUB_PR_COMMENT_BODY_MATCH', value: ''
+                            expression { GITHUB_PR_COMMENT_BODY_MATCH ==~ /.*centos.*/ }
+                        }
+                    }                    
+                    steps {
+                        script {
+                            result = buildJob('CentOS-test', 'Github_Builds/centos-build-param')
+                            if (result == 'FAILURE') {
+                                error('CentOS build failed')
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        
+        
+        stage('Tests') {
+            parallel {
+                stage('Clang-Analyzer') {
+                    when {
+                        anyOf {
+                            environment name: 'GITHUB_PR_COMMENT_BODY_MATCH', value: ''
+                            expression { GITHUB_PR_COMMENT_BODY_MATCH ==~ /.*clang-analyzer.*/ }
+                        }
+                    }                    
+                    steps {
+                        script {
+                            result = buildJob('Clang-Analyzer', 'Github_Builds/clang-analyzer')
+                            if (result == 'FAILURE') {
+                                error('Clang-Analyzer failed')
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        
+    }
+}
diff --git a/jenkins/github/ubuntu-clang.pipeline b/jenkins/github/ubuntu-clang.pipeline
new file mode 100644
index 0000000..2e36503
--- /dev/null
+++ b/jenkins/github/ubuntu-clang.pipeline
@@ -0,0 +1,44 @@
+pipeline {
+    agent {
+        docker {
+            image 'controller.trafficserver.org/ats/ubuntu:20.04'
+            registryUrl 'https://controller.trafficserver.org/'
+            label 'docker'
+        }
+    }
+    stages {
+        stage('Clone') {
+            steps {
+                dir('src') {
+                    echo "${sha1}"
+                    checkout([$class: 'GitSCM',
+                        branches: [[name: sha1]],
+                        extensions: [],
+                        //+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/merge
+                        userRemoteConfigs: [[url: github_url, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/${sha1}/merge:refs/remotes/origin/pull/${sha1}/merge']]])
+                    sh 'head -1 README'
+                }
+                echo 'Finished Cloning'
+            }
+        }
+        stage('Build') {
+            steps {
+                echo 'Starting build'
+                dir('src') {
+                    sh('head -1 README')
+                    sh('autoreconf -fiv')
+                    sh('CC="clang" CXX="clang++" CXXFLAGS="-Qunused-arguments" WITH_LIBCPLUSPLUS="yes" ./configure --enable-experimental-plugins')
+                    sh('make -j3')
+                }
+            }
+        }
+    }
+    
+    post { 
+        cleanup { 
+            cleanWs()
+        }
+    }
+}
diff --git a/jenkins/github/ubuntu.pipeline b/jenkins/github/ubuntu.pipeline
new file mode 100644
index 0000000..8823bbc
--- /dev/null
+++ b/jenkins/github/ubuntu.pipeline
@@ -0,0 +1,44 @@
+pipeline {
+    agent {
+        docker {
+            image 'controller.trafficserver.org/ats/ubuntu:20.04'
+            registryUrl 'https://controller.trafficserver.org/'
+            label 'docker'
+        }
+    }
+    stages {
+        stage('Clone') {
+            steps {
+                dir('src') {
+                    echo "${sha1}"
+                    checkout([$class: 'GitSCM',
+                        branches: [[name: sha1]],
+                        extensions: [],
+                        //+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/merge
+                        userRemoteConfigs: [[url: github_url, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/*:refs/remotes/origin/pr/*']]])
+                        //userRemoteConfigs: [[url: 'https://github.com/ezelkow1/trafficserver', refspec: '+refs/pull/${sha1}/merge:refs/remotes/origin/pull/${sha1}/merge']]])
+                    sh 'head -1 README'
+                }
+                echo 'Finished Cloning'
+            }
+        }
+        stage('Build') {
+            steps {
+                echo 'Starting build'
+                dir('src') {
+                    sh('head -1 README')
+                    sh('autoreconf -fiv')
+                    sh('./configure --enable-experimental-plugins')
+                    sh('make -j3')
+                }
+            }
+        }
+    }
+    
+    post { 
+        cleanup { 
+            cleanWs()
+        }
+    }
+}