Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit bbffda6

Browse files
authored
Merge pull request #146 from okartau/run-qemu-test-on-builder
CI: various clean-ups and improvements
2 parents aac8937 + 57e46fc commit bbffda6

7 files changed

Lines changed: 33 additions & 86 deletions

File tree

Jenkinsfile

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ def global_sum_log = ""
2828
def added_commits = ""
2929
def builder_node = ""
3030
def builder_wspace = ""
31-
def slot_name = "builder-slot-"
31+
def slot_name = "ci-"
3232
// reasonable value: keep few recent, dont take risk to fill disk
3333
int num_build_dirs_to_keep = 4
3434

3535
// Define global environment common for all docker sessions
3636
def script_env = """
3737
export WORKSPACE=\$PWD
3838
export HOME=\$JENKINS_HOME
39-
export CURRENT_PROJECT=${current_project}
4039
export BUILD_CACHE_DIR=${env.PUBLISH_DIR}/bb-cache
4140
export GIT_PROXY_COMMAND=oe-git-proxy
4241
export CI_BUILD_ID=${ci_build_id}
4342
export GIT_COMMITTER_NAME="IOT Refkit CI"
4443
export GIT_COMMITTER_EMAIL='refkit-ci@yoctoproject.org'
4544
export TARGET_MACHINE=${target_machine}
45+
export CI_LOG=bitbake-${target_machine}-${ci_build_id}.log
4646
"""
4747

4848
try {
4949
timestamps {
5050
node('rk-docker') {
51-
ws("workspace/${slot_name}${env.EXECUTOR_NUMBER}") {
51+
ws("workspace/${slot_name}${ci_build_id}") {
5252
// remember node and workspace needed by workspace cleaner
5353
builder_node = "${env.NODE_NAME}"
5454
builder_wspace = "${env.WORKSPACE}"
@@ -102,11 +102,6 @@ try {
102102
added_commits = readFile("added_commits")
103103
}
104104
} // ws
105-
// rotate workspace out of way, rename using CI_BUILD_ID.
106-
// Older trees are deleted later in test_runs[], without keeping build waiting.
107-
ws("workspace") {
108-
sh "mv ${builder_wspace} ${builder_wspace}.ci-prev.${ci_build_id}"
109-
}
110105
} // node
111106
} // timestamps
112107

@@ -146,9 +141,12 @@ try {
146141
} finally {
147142
// read tests summary prepared by tester-exec.sh
148143
// Here one tester adds it's summary piece to the global buffer.
149-
global_sum_log += readFile "results-summary-${test_device}.${img}.log"
150-
archiveArtifacts allowEmptyArchive: true,
151-
artifacts: '*.log, *.xml'
144+
// Grab lock as we deal with global data from multiple workers
145+
lock(resource: "global_data") {
146+
global_sum_log += readFile "results-summary-${test_device}.${img}.log"
147+
archiveArtifacts allowEmptyArchive: true,
148+
artifacts: '*.log, *.xml'
149+
}
152150
}
153151
// without locking we may lose tester result set(s)
154152
// if testers run xunit step in nearly same time
@@ -220,12 +218,10 @@ def run_proxy_args() {
220218

221219
def build_user_args() {
222220
dir(pwd([tmp:true])+"/.build_user_args") {
223-
// get jenkins user uid/gid
224-
sh "id -u > jenkins_uid"
221+
// get jenkins user uid/gid
222+
sh "id -u > jenkins_uid && id -g > jenkins_gid"
225223
jenkins_uid = readFile("jenkins_uid").trim()
226-
sh "id -g > jenkins_gid"
227224
jenkins_gid = readFile("jenkins_gid").trim()
228-
deleteDir()
229225
}
230226
return "--build-arg uid=${jenkins_uid} --build-arg gid=${jenkins_gid}"
231227
}
@@ -300,12 +296,17 @@ def step_xunit() {
300296
}
301297

302298
// Delete older builder trees.
303-
// While majority/regular workspaces are named builder-slot-0, (for EXECUTOR=0),
304-
// Jenkins may create additional trees as builder-slot-0_X.
305-
// Wildcard covers all such workspaces, dont want some pattern filling disk independently.
299+
// While majority/regular workspaces are named ci-CI_BUILD_ID,
300+
// Jenkins may create additional trees as ci-build-CI_BUILD_ID_<NUM>
301+
// Regex with underscore should cover all such workspaces.
306302
def trim_build_dirs(slotname, num_to_keep) {
307303
sh """
308-
dirs=`find ${env.WORKSPACE} -mindepth 1 -maxdepth 1 -type d -name "${slotname}*.ci-prev.*" |sort -n |head -n -${num_to_keep} |tr '\n' ' '`
304+
# tmpdirs in separate pass
305+
dirs=`find . -mindepth 1 -maxdepth 1 -type d -regex ".*/${slotname}[0-9_-]*-build-[0-9_]*.*tmp\$" |sort -n |head -n -${num_to_keep} |tr '\n' ' '`
306+
if [ -n "\${dirs}" ]; then
307+
ionice -c 3 rm -fr \$dirs
308+
fi
309+
dirs=`find . -mindepth 1 -maxdepth 1 -type d -regex ".*/${slotname}[0-9_-]*-build-[0-9_]*\$" |sort -n |head -n -${num_to_keep} |tr '\n' ' '`
309310
if [ -n "\${dirs}" ]; then
310311
ionice -c 3 rm -fr \$dirs
311312
fi

docker/build-common-util.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ EOF
3636
# save sstate to workspace
3737
echo "SSTATE_DIR = \"${BUILD_CACHE_DIR}/sstate\"" >> conf/auto.conf
3838
fi
39+
# lower compression levels in a PR build, to save build time
40+
if [ -z ${CI_ARCHIVER_MODE+x} ]; then
41+
echo "ZIP_COMPRESSION_LEVEL ?= \"-1\"" >> conf/auto.conf
42+
echo "XZ_COMPRESSION_LEVEL ?= \"-0\"" >> conf/auto.conf
43+
fi
3944
}
4045

4146
auto_conf_archiver() {

docker/build-project.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ bitbake -S none ${_bitbake_targets}
103103

104104
if [ ! -z ${JOB_NAME+x} ]; then
105105
# CI run: save output to log file
106-
LOG=$WORKSPACE/bitbake-${TARGET_MACHINE}-${CI_BUILD_ID}.log
107-
bitbake ${_bitbake_targets} 2>&1 | tee -a $LOG
106+
bitbake ${_bitbake_targets} 2>&1 | tee -a $WORKSPACE/$CI_LOG
108107
else
109108
bitbake ${_bitbake_targets}
110109
fi

docker/opensuse-42.1/Dockerfile

Lines changed: 0 additions & 29 deletions
This file was deleted.

docker/opensuse-tumbleweed/Dockerfile

Lines changed: 0 additions & 29 deletions
This file was deleted.

docker/publish-project.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ _DEPL=${_BRESULT}/deploy
5858

5959
# create publishing destination structure and copy
6060
create_remote_dirs ${RSYNC_PUBLISH_DIR}/builds ${JOB_NAME}/${CI_BUILD_ID}
61-
[ -d ${_DEPL}/images ] && create_remote_dirs ${_RSYNC_DEST} images && rsync -avS --exclude=README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt ${_DEPL}/images/${TARGET_MACHINE} ${_RSYNC_DEST}/images/
61+
[ -d ${_DEPL}/images ] && create_remote_dirs ${_RSYNC_DEST} images && rsync -avS ${_DEPL}/images/${TARGET_MACHINE} ${_RSYNC_DEST}/images/
6262
[ -d ${_DEPL}/licenses ] && create_remote_dirs ${_RSYNC_DEST} licenses && rsync -az --ignore-existing ${_DEPL}/licenses ${_RSYNC_DEST}/
6363
[ -d ${_DEPL}/sources ] && create_remote_dirs ${_RSYNC_DEST} sources && rsync -av --ignore-existing ${_DEPL}/sources ${_RSYNC_DEST}/
6464
[ -d ${_DEPL}/tools ] && create_remote_dirs ${_RSYNC_DEST} tools && rsync -av --ignore-existing ${_DEPL}/tools ${_RSYNC_DEST}/
@@ -110,7 +110,7 @@ if [ -n "$(find ${_BRESULT}/log -maxdepth 1 -name 'isafw*' -print -quit)" ]; the
110110
fi
111111
fi
112112

113-
LOG="$WORKSPACE/bitbake-${TARGET_MACHINE}-${CI_BUILD_ID}.log"
113+
LOG=$WORKSPACE/$CI_LOG
114114
if [ -f "${LOG}" ]; then
115115
xz -v -k ${LOG}
116116
rsync -avz ${LOG}* ${_RSYNC_DEST}/

docker/tester-exec.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ testimg() {
7272
tar -xzf ${TEST_SUITE_FILE}
7373
tar -xzf ${TEST_CASES_FILE} -C iottest/
7474

75-
# Copy local WLAN settings to iottest over example file and chmod to readable
76-
_WLANCONF=./iottest/oeqa/runtime/connectivity/wifi/files/config.ini
77-
cp $HOME/.config.ini.wlan ${_WLANCONF}
78-
chmod 644 ${_WLANCONF}
79-
8075
FILENAME=${_IMG_NAME}-${MACHINE}-${CI_BUILD_ID}.wic
8176
set +e
8277
wget ${_WGET_OPTS} ${CI_BUILD_URL}/images/${MACHINE}/${FILENAME}.bmap
@@ -114,6 +109,11 @@ testimg() {
114109
if [ "${DEVICE}" = "qemu" ]; then
115110
test_qemu
116111
else
112+
# Copy local WLAN settings to iottest over example file and chmod to readable
113+
_WLANCONF=./iottest/oeqa/runtime/connectivity/wifi/files/config.ini
114+
cp $HOME/.config.ini.wlan ${_WLANCONF}
115+
chmod 644 ${_WLANCONF}
116+
117117
daft ${DEVICE} ${FILENAME} --record
118118
TEST_EXIT_CODE=$?
119119
fi

0 commit comments

Comments
 (0)