From 7fe127675a873d5e9d1bf01b21ace11ae7809760 Mon Sep 17 00:00:00 2001 From: Lane Jennison Date: Sat, 25 Jan 2020 16:15:59 -0500 Subject: [PATCH] commit scripts im using --- .gitignore | 25 ------------ README.md | 7 ++++ config-jenkins-kernel.conf | 23 +++++++++++ jenkins_kernel_build.sh | 79 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 25 deletions(-) create mode 100644 config-jenkins-kernel.conf create mode 100755 jenkins_kernel_build.sh diff --git a/.gitignore b/.gitignore index 6df01d6..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +0,0 @@ -#Learn more about Jenkins and JENKINS_HOME directory for which this file is intended. -# http://jenkins-ci.org/ -# https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins - -#ignore all JENKINS_HOME except jobs directory, root xml config, and .gitignore file -/* -!/jobs -!/.gitignore -!/*.xml - -#ignore all files in jobs subdirectories except for folders -#note: git doesn't track folders, only file content -jobs/** -!jobs/**/ - -#uncomment the following line to save next build numbers with config -#!jobs/**/nextBuildNumber - -#exclude only config.xml files in repository subdirectories -!config.xml - -#don't track workspaces (when users build on the master) -jobs/**/*workspace - -#as a result only settings and job config.xml files in JENKINS_HOME will be tracked by git diff --git a/README.md b/README.md index 64a8799..4691d0a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # ci-testing-tools scripts, tools, configs for CI-testing + +Currently just shell scripts called by jenkins. May evolve into somethign more elegant such as a jenkins file. + +Uses some simple logic for a best-effort attempt to compile a kernel based on what code has changed + +## dependencies +* https://github.com/slimm609/monorepo-gitwatcher.git diff --git a/config-jenkins-kernel.conf b/config-jenkins-kernel.conf new file mode 100644 index 0000000..ff61561 --- /dev/null +++ b/config-jenkins-kernel.conf @@ -0,0 +1,23 @@ +# Read build script documentation https://docs.armbian.com/Developer-Guide_Build-Options/ +# for detailed explanation of these options and for additional options not listed here + +KERNEL_ONLY="yes" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt +KERNEL_CONFIGURE="no" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt +CLEAN_LEVEL="make,debs,oldcache,sources" # comma-separated list of clean targets: "make" = make clean for selected kernel and u-boot, + # "debs" = delete packages in "./output/debs" for current branch and family, + # "alldebs" = delete all packages in "./output/debs", "images" = delete "./output/images", + # "cache" = delete "./output/cache", "sources" = delete "./sources" + # "oldcache" = remove old cached rootfs except for the newest 8 files + +DEST_LANG="en_US.UTF-8" # sl_SI.UTF-8, en_US.UTF-8 + +# advanced +EXTERNAL_NEW="prebuilt" # compile and install or install prebuilt additional packages +INSTALL_HEADERS="" # install kernel headers package +LIB_TAG="master" # change to "branchname" to use any branch currently available. +USE_TORRENT="yes" # use torrent network for faster toolchain and cache download +DOWNLOAD_MIRROR="" # set to "china" to use mirrors.tuna.tsinghua.edu.cn +CARD_DEVICE="" # device name /dev/sdx of your SD card to burn directly to the card when done +FORCE_CHECKOUT="no" +EXPERT="yes" +BUILD_DESKTOP="no" diff --git a/jenkins_kernel_build.sh b/jenkins_kernel_build.sh new file mode 100755 index 0000000..0c630f5 --- /dev/null +++ b/jenkins_kernel_build.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +configure_monorepo_watcher() { + echo "config/kernel" > family.watch + echo "config/sources" >> family.watch + echo "patch/kernel" >> family.watch + echo "patch/u-boot" >> family.watch + + echo "config/boards" > board.watch + echo "config/bootscripts" >> board.watch + +} + +generate_test_table() { + config_dir=build/config/boards + files=$(ls ${config_dir}/*.conf ${config_dir}/*.wip ${config_dir}/*.csc) + + rm -f test_table.csv + + for file in ${files}; do + source ${file} + board=$(basename ${file}|cut -d '.' -f1) + support_level=$(basename ${file}|cut -d'.' -f2) + echo "${BOARDFAMILY},${BOARD_NAME},${board},${support_level}" >> test_table.csv + +done + +} + +get_files_changed() { + ## these var values needed by detectGitChanges.sh + GIT_COMMIT=${GITHUB_PR_HEAD_SHA} + GIT_PREVIOUS_COMMIT=HEAD + + cd build + family_changed="$(../monorepo-gitwatcher/detectGitChanges.sh ../family.watch)" + board_changed="$(../monorepo-gitwatcher/detectGitChanges.sh ../board.watch)" + +} + +get_build_target() { + OLDIFS=${IFS} + IFS=$'\n' + + # reverse sort improves grep accuracy + for row in $(cat ../test_table.csv|sort -r); do + + family=$(echo $row|cut -d',' -f1) + board=$(echo $row|cut -d',' -f3) + for family_row in ${family_changed}; do + echo "family_row: ${family_row}" + if echo $family_row | fgrep -q $family; then + ARMBIAN_BOARD=${board} + for branch in current dev legacy; do + if echo $family_row |fgrep -q $branch; then + echo "ARMBIAN_BRANCH=${branch}" + ARMBIAN_BRANCH=${branch} + fi + done + break 2 + fi + done + for board_row in ${board_changed}; do + if echo $board_row | fgrep -q $board; then + ARMBIAN_BOARD=${board} + break + fi + done + + done + IFS=${OLDIFS} +} + +build_kernel() { + git checkout ${GIT_COMMIT} + ./compile.sh CONFIG=../ci-testing-tools/config-jenkins-kernel.conf BOARD=${ARMBIAN_BOARD} BRANCH=${ARMBIAN_BRANCH} + +} +