From 08503158e9d37394dbde9e8ce5190cec9e6375f6 Mon Sep 17 00:00:00 2001 From: keithm-xmos <35048036+keithm-xmos@users.noreply.github.com> Date: Fri, 9 Oct 2020 10:16:24 -0400 Subject: [PATCH] Jenkinfile seed (#6) Integrated Jenkins CI --- Dockerfile | 33 +++++++++++++++++++ Jenkinsfile | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ environment.yml | 10 ++++++ 3 files changed, 128 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile create mode 100644 environment.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..9e9305094 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM continuumio/miniconda3:4.8.2 + +# This Dockerfile is for use by the XMOS CI system +# It provides a minimal environment needed to execute the Jenkinsfile +# Most of the dependecies here are handled conda so we only include: +# - conda setup +# - xmos tools setup + +# fix conda perms +RUN chmod -R 777 /opt/conda \ + && mkdir -p /.conda \ + && chmod -R 777 /.conda + +# install tools lib dependencies +RUN apt-get update && apt-get install -y \ + libncurses5 libncurses5-dev \ + tcl environment-modules \ + && apt-get clean autoclean +# install get_tools.py script +# requires connection to XMOS network at build and run time +# if not possible, find another way to install the tools +RUN mkdir -m 777 /XMOS && cd /XMOS \ + && wget -q https://github0.xmos.com/raw/xmos-int/get_tools/master/get_tools.py \ + && chmod a+x get_tools.py \ + && echo "export MODULES_SILENT_SHELL_DEBUG=1\nexport MODULEPATH=/XMOS/modulefiles:/XMOS/template_modulefiles\nexport PATH=$PATH:/XMOS" \ + >> /etc/profile.d/xmos_tools.sh \ + && chmod a+x /etc/profile.d/xmos_tools.sh + +# install compiler +RUN apt-get install -y build-essential + +# set login shell +SHELL ["/bin/bash", "-l", "-c"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..42e1ec11e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,85 @@ +@Library('xmos_jenkins_shared_library@v0.14.2') _ + +getApproval() + +pipeline { + agent { + dockerfile { + args "" + } + } + + parameters { // Available to modify on the job page within Jenkins if starting a build + string( // use to try different tools versions + name: 'TOOLS_VERSION', + defaultValue: '15.0.2', + description: 'The tools version to build with (check /projects/tools/ReleasesTools/)' + ) + booleanParam( // use to check results of rolling all conda deps forward + name: 'UPDATE_ALL', + defaultValue: false, + description: 'Update all conda packages before building' + ) + } + + options { // plenty of things could go here + //buildDiscarder(logRotator(numToKeepStr: '10')) + timestamps() + } + + environment { + XMOS_AIOT_SDK_PATH = "${env.WORKSPACE}" + } + + stages { + stage("Setup") { + // Clone and install build dependencies + steps { + // clean auto default checkout + sh "rm -rf *" + // clone + checkout([ + $class: 'GitSCM', + branches: scm.branches, + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'SubmoduleOption', + threads: 8, + timeout: 20, + shallow: false, + parentCredentials: true, + recursiveSubmodules: true], + [$class: 'CleanCheckout']], + userRemoteConfigs: [[credentialsId: 'xmos-bot', + url: 'git@github.com:xmos/aiot_sdk']] + ]) + // create venv + sh "conda env create -q -p aiot_sdk_venv -f environment.yml" + // Install xmos tools version + sh "/XMOS/get_tools.py " + params.TOOLS_VERSION + } + } + stage("Update all packages") { + // Roll all conda packages forward beyond their pinned versions + when { expression { return params.UPDATE_ALL } } + steps { + sh "conda update --all -y -q -p aiot_sdk_venv" + } + } + stage("Build examples") { + steps { + sh """pushd /XMOS/tools/${params.TOOLS_VERSION}/XMOS/xTIMEcomposer/${params.TOOLS_VERSION} && . SetEnv && popd && + . activate ./aiot_sdk_venv && ./build_examples.sh""" + } + } + stage("Build distribution") { + steps { + sh """. activate ./aiot_sdk_venv && ./build_dist.sh""" + } + } + } + post { + cleanup { + cleanWs() + } + } +} diff --git a/environment.yml b/environment.yml new file mode 100644 index 000000000..d157e9dda --- /dev/null +++ b/environment.yml @@ -0,0 +1,10 @@ +channels: + - mvdbeek + - bioconda + - conda-forge + - anaconda + - defaults +dependencies: + - cmake=3.14.0 + - make=4.2.1 + - ncurses=6.1