forked from xmos/xcore_iot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
150 lines (145 loc) · 5.31 KB
/
Jenkinsfile
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
@Library('[email protected]') _
def withXTAG(String target, Closure body) {
// Acquire an xtag adapter-id by target name
def adapterID = sh (script: "xtagctl acquire ${target}", returnStdout: true).trim()
// Run the closure
body(adapterID)
// Release the xtag by adapter-id
sh ("xtagctl release ${adapterID}")
}
// Wait here until specified artifacts appear
def artifactUrls = getGithubArtifactUrls([
"bare-metal_examples",
"freertos_core_examples",
"freertos_aiot_examples"
// "host_apps",
// "rtos_tests"
])
getApproval()
pipeline {
agent {
label 'sdk'
}
options {
disableConcurrentBuilds()
skipDefaultCheckout()
timestamps()
// on develop discard builds after a certain number else keep forever
buildDiscarder(logRotator(
numToKeepStr: env.BRANCH_NAME ==~ /develop/ ? '25' : '',
artifactNumToKeepStr: env.BRANCH_NAME ==~ /develop/ ? '25' : ''
))
}
parameters {
string(
name: 'TOOLS_VERSION',
defaultValue: '15.1.4',
description: 'The XTC tools version'
)
}
environment {
PYTHON_VERSION = "3.8.11"
VENV_DIRNAME = ".venv"
DOWNLOAD_DIRNAME = "build"
SDK_TEST_RIG_TARGET = "xcore_sdk_test_rig"
}
stages {
stage('Checkout') {
steps {
checkout scm
sh "git clone [email protected]:xmos/xcore_sdk.git"
}
}
stage('Download artifacts') {
steps {
dir("$DOWNLOAD_DIRNAME") {
downloadExtractZips(artifactUrls)
// List extracted files for log
sh "ls -la"
}
}
}
stage('Create virtual environment') {
steps {
// Create venv
sh "pyenv install -s $PYTHON_VERSION"
sh "~/.pyenv/versions/$PYTHON_VERSION/bin/python -m venv $VENV_DIRNAME"
// Install dependencies
withVenv() {
// NOTE: only one dependency so not using a requirements.txt file here yet
sh "pip install git+https://github0.xmos.com/xmos-int/xtagctl.git"
}
}
}
stage('Cleanup xtagctl') {
steps {
// Cleanup any xtagctl cruft from previous failed runs
withTools(params.TOOLS_VERSION) {
withVenv {
sh "xtagctl reset_all $SDK_TEST_RIG_TARGET"
}
}
sh "rm -f ~/.xtag/status.lock ~/.xtag/acquired"
}
}
stage('Run FreeRTOS examples') {
steps {
withTools(params.TOOLS_VERSION) {
withVenv {
script {
if (fileExists("$DOWNLOAD_DIRNAME/example_freertos_getting_started.xe")) {
withXTAG("$SDK_TEST_RIG_TARGET") { adapterID ->
sh "test/examples/run_freertos_getting_started_tests.sh $adapterID"
}
} else {
echo 'SKIPPED: example_freertos_getting_started'
}
}
script {
if (fileExists("$DOWNLOAD_DIRNAME/example_freertos_explorer_board.xe")) {
withXTAG("$SDK_TEST_RIG_TARGET") { adapterID ->
sh "test/examples/run_freertos_explorer_board_tests.sh $adapterID"
}
} else {
echo 'SKIPPED: example_freertos_explorer_board'
}
}
script {
if (fileExists("$DOWNLOAD_DIRNAME/example_freertos_dispatcher.xe")) {
withXTAG("$SDK_TEST_RIG_TARGET") { adapterID ->
sh "test/examples/run_freertos_dispatcher_tests.sh $adapterID"
}
} else {
echo 'SKIPPED: example_freertos_dispatcher'
}
}
script {
if (fileExists("$DOWNLOAD_DIRNAME/example_freertos_l2_cache.xe")) {
withXTAG("$SDK_TEST_RIG_TARGET") { adapterID ->
sh "test/examples/run_freertos_l2_cache_tests.sh $adapterID"
}
} else {
echo 'SKIPPED: example_freertos_l2_cache'
}
}
}
}
}
}
// stage('Run bare-metal examples') {
// steps {
// withTools(params.TOOLS_VERSION) {
// withVenv {
// script {
// }
// }
// }
// }
// }
}
post {
cleanup {
cleanWs()
}
}
}