~aleteoryx/muditaos

ref: 6c32205e1be369cbadf752c77eff68d1a2f963e1 muditaos/Jenkinsfile -rw-r--r-- 4.2 KiB
6c32205e — Marek Niepieklo [CP-371] Updater miscelanous developer mode and logs changes 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
def cancelPreviousBuilds() {

    def jobName = env.JOB_NAME
    def buildNumber = env.BUILD_NUMBER.toInteger()
    def currentJob = Jenkins.instance.getItemByFullName(jobName)

    for (def build : currentJob.builds) {
        def exec = build.getExecutor()

        /* Kill older jobs */
        if (build.isBuilding() && build.number.toInteger() < buildNumber && exec != null) {
            def cause = { "Job stoped by #${buildNumber}" as String} as CauseOfInterruption
            exec.interrupt(Result.ABORTED, cause)
            println("Aborting previous build:#${build.number}")
        }
    }
}
pipeline {
  agent {
    node {
      label 'jenkins-slave-ccache-ram'
    }
  }
  options{
    ansiColor('xterm')
    parallelsAlwaysFailFast()
  }
  environment {
    JOBS=15
  }
  stages {
    stage('Check for previous running builds') {
        
        steps {
            script {
                cancelPreviousBuilds()
            }
        }
    }

    stage('Initial checks') {
        when {
            changeRequest()
        }
        environment {
            GITHUB_BASE_REF="${pullRequest.base}"
            GITHUB_HEAD_REF="${pullRequest.headRef}"
        }
        steps {
            echo "Check if branch needs rebasing"
            sh '''#!/bin/bash -e
pushd ${WORKSPACE}

if [[ $(git log origin/${CHANGE_TARGET}..HEAD) ]]; then
    echo "Branch OK"
else
    echo "Branch is not rebased. Exiting"
    exit 1
fi


popd'''
            echo "Commit Message check"
            sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./tools/check_commit_messages.py
popd'''
            echo "Copyright notice check"
            sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./config/license_header_check.sh --ci --check-only
popd'''
            echo "Style checking"
            sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./config/style_check_hook.sh --last
popd'''
        }
    }
    stage('Build') {
        when {
            changeRequest()
        }
        stages{
        stage('Build RT1051') {
            steps {
                sh '''#!/bin/bash -e
PATH="/usr/local/cmake-3.19.5-Linux-x86_64/bin:/usr/local/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH"
export JOBS=${JOBS:-6}
export CCACHE_DIR=/ccache/RT1051

echo "JOBS=${JOBS}"
echo "\'workspace dir:${WORKSPACE}\'"

pushd "${WORKSPACE}"
echo "./configure.sh rt1051 Release -G Ninja"

./configure.sh rt1051 Release -G Ninja

pushd build-rt1051-Release
ninja -j ${JOBS}
popd
popd'''
                echo "CCache stats"
                sh '''#!/bin/bash
export CCACHE_DIR=/ccache/RT1051
ccache --show-stats'''
            }
        }

        stage('Build Linux') {
            environment {
                PATH="/usr/local/cmake-3.19.5-Linux-x86_64/bin:/usr/local/gcc-arm-none-eabi-10-2020-q4-major/bin:$PATH"
                CCACHE_DIR="/ccache/Linux"
            }

            steps {
                echo "Build"
                sh '''#!/bin/bash -e
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
echo "./configure.sh linux Debug -G Ninja"

./configure.sh linux Debug -G Ninja

pushd build-linux-Debug
ninja -j ${JOBS} Pure Bell
popd'''
            echo "Clang Tidy check"
            /* requires compilation database - must be run after configuration */
            sh '''#!/bin/bash -e
pushd ${WORKSPACE}
./config/clang_check.sh
popd'''
                echo "Build Unit Tests"
                sh '''#!/bin/bash -e
pushd "${WORKSPACE}"
pushd build-linux-Debug
ninja -j ${JOBS} unittests
popd
popd'''
                echo "CCache stats"
                sh '''#!/bin/bash
export CCACHE_DIR=/ccache/Linux
ccache --show-stats'''
                echo "Check for Statics"
                sh '''#!/bin/bash -e
pushd "${WORKSPACE}"
./tools/find_global_data.py build-linux-Debug/PurePhone.elf
popd'''
                echo "Run Unit Tests"
                sh '''#!/bin/bash -e
export JOBS=${JOBS:-6}
echo "JOBS=${JOBS}"
pushd "${WORKSPACE}"
pushd build-linux-Debug
ninja check -j ${JOBS}
./googletest-gui
popd
popd'''
            }
        }
    }
    }
    stage('master-jobs') {
        when {
            branch 'master'
        }
        steps {
            echo "run some tests"
            sh '''#!/bin/bash
                echo "HALL 9000 sleeps here."
            '''
            
        }
    }
  }
  post {
    always {
        cleanWs()
    }
  }
}