1414# limitations under the License.
1515*/
1616
17- def getBuildClosure (def architecture , def makeCommand , def makeTarget ) {
18- return {
19- container(' docker' ) {
20- stage(architecture) {
21- sh " ${ makeCommand} ${ makeTarget} "
17+ podTemplate (cloud :' sw-gpu-cloudnative' ,
18+ containers : [
19+ containerTemplate(name : ' docker' , image : ' docker:dind' , ttyEnabled : true , privileged : true ),
20+ containerTemplate(name : ' golang' , image : ' golang:1.14.2' , ttyEnabled : true )
21+ ]) {
22+ node(POD_LABEL ) {
23+ stage(' checkout' ) {
24+ checkout scm
25+ }
26+ stage(' dependencies' ) {
27+ container(' golang' ) {
28+ sh ' GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell'
29+ sh ' GO111MODULE=off go get -u github.com/gordonklaus/ineffassign'
30+ sh ' GO111MODULE=off go get -u golang.org/x/lint/golint'
2231 }
32+ container(' docker' ) {
33+ sh ' apk add --no-cache make bash'
34+ }
35+ }
36+ stage(' check' ) {
37+ parallel (
38+ getGolangStages([" assert-fmt" , " lint" , " vet" , " ineffassign" , " misspell" ])
39+ )
40+ }
41+ stage(' test' ) {
42+ parallel (
43+ getGolangStages([" test" ])
44+ )
45+ }
46+ stage(' build-one' ) {
47+ parallel (
48+ getSingleBuildForArchitectures([" amd64" , " ppc64le" , " arm64" ])
49+ )
50+ }
51+ stage(' build-all' ) {
52+ parallel (
53+ getAllBuildForArchitectures([" amd64" , " ppc64le" , " arm64" , " x86_64" , " aarch64" ])
54+ )
2355 }
2456 }
2557}
2658
27- def getBuildStagesForArchitectures (def architectures , def makeCommand , def makeTargetPrefix ) {
59+ def getGolangStages (def targets ) {
2860 stages = [:]
2961
30- for (a in architectures ) {
31- stages[a ] = getBuildClosure(a, makeCommand, " ${ makeTargetPrefix } - ${ a } " )
62+ for (t in targets ) {
63+ stages[t ] = getLintClosure(t )
3264 }
3365
3466 return stages
@@ -43,28 +75,32 @@ def getAllBuildForArchitectures(def architectures) {
4375 return getBuildStagesForArchitectures(architectures, " echo make" , " docker" )
4476}
4577
46- podTemplate (cloud :' sw-gpu-cloudnative' ,
47- containers : [
48- containerTemplate(name : ' docker' , image : ' docker:dind' , ttyEnabled : true , privileged : true )
49- ]) {
50- node(POD_LABEL ) {
51- stage(' checkout' ) {
52- checkout scm
53- }
54- stage(' dependencies' ) {
55- container(' docker' ) {
56- sh ' apk add --no-cache make bash'
78+ def getBuildStagesForArchitectures (def architectures , def makeCommand , def makeTargetPrefix ) {
79+ stages = [:]
80+
81+ for (a in architectures) {
82+ stages[a] = getBuildClosure(a, makeCommand, " ${ makeTargetPrefix} -${ a} " )
83+ }
84+
85+ return stages
86+ }
87+
88+ def getBuildClosure (def architecture , def makeCommand , def makeTarget ) {
89+ return {
90+ container(' docker' ) {
91+ stage(architecture) {
92+ sh " ${ makeCommand} ${ makeTarget} "
5793 }
5894 }
59- stage( ' build-one ' ) {
60- parallel (
61- getSingleBuildForArchitectures([ " amd64 " , " ppc64le " , " arm64 " ])
62- )
63- }
64- stage( ' build-all ' ) {
65- parallel (
66- getAllBuildForArchitectures([ " amd64 " , " ppc64le " , " arm64 " , " x86_64 " , " aarch64 " ])
67- )
95+ }
96+ }
97+
98+ def getLintClosure ( def target ) {
99+ return {
100+ container( ' golang ' ) {
101+ stage(target) {
102+ sh " make ${ target } "
103+ }
68104 }
69105 }
70- }
106+ }
0 commit comments