From a5368f7d8f7846d7269a052ec1f0b45d1a5078e8 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Wed, 26 Sep 2018 01:16:24 +0100 Subject: [PATCH] jenkins: add llnode pipeline and shell scripts (#1025) * jenkins: add llnode pipeline and shell scripts The llnode CI isn't working right now, but hopefully by committing this we can then iterate in GitHub. Refs: https://github.com/nodejs/build/issues/777 Responsible-commiter: Refael Ackermann Reviewed-By: Matheus Marchini --- jenkins/pipelines/llnode-pipeline.jenkinsfile | 43 ++++++++++ jenkins/scripts/common/colors.sh | 61 ++++++++++++++ jenkins/scripts/common/getLLDB.sh | 31 +++++++ jenkins/scripts/common/getNode.sh | 80 +++++++++++++++++++ jenkins/scripts/common/helpers.sh | 36 +++++++++ .../scripts/llnode-continuous-integration.sh | 40 ++++++++++ 6 files changed, 291 insertions(+) create mode 100644 jenkins/pipelines/llnode-pipeline.jenkinsfile create mode 100644 jenkins/scripts/common/colors.sh create mode 100755 jenkins/scripts/common/getLLDB.sh create mode 100755 jenkins/scripts/common/getNode.sh create mode 100644 jenkins/scripts/common/helpers.sh create mode 100755 jenkins/scripts/llnode-continuous-integration.sh diff --git a/jenkins/pipelines/llnode-pipeline.jenkinsfile b/jenkins/pipelines/llnode-pipeline.jenkinsfile new file mode 100644 index 000000000..f05398d79 --- /dev/null +++ b/jenkins/pipelines/llnode-pipeline.jenkinsfile @@ -0,0 +1,43 @@ +#!/usr/bin/env groovy + +properties([ + parameters([ + string(name: 'GIT_REPO', defaultValue: 'nodejs/llnode', description: 'Fetch from this repo (e.g. gibfahn/llnode)'), + string(name: 'GIT_BRANCH', defaultValue: 'master', description: 'Branch to test (e.g. master, refs/pull/999/head).'), + string(name: 'NODE_VERSIONS', defaultValue: 'v6 v8 v9 v10 nightly canary', description: 'Space separated list of NODE_VERSIONS to pass to llnode-continuous-integration.'), + string(name: 'LLDB_VERSIONS', defaultValue: '3.9 4.0 5.0 6.0', description: 'Space separated list of LLDB_VERSIONS to pass to llnode-continuous-integration.'), + string(name: 'MACHINES', defaultValue: 'all', description: '''Can be "all" or a space-separated list of nodes, eg: + debian8-64 fedora22 fedora23 osx1010 ppcle-ubuntu1404 ubuntu1204-64 ubuntu1404-64 ubuntu1604-64 rhel72-s390x aix61-ppc64 ppcbe-ubuntu1404 smartos16-64 smartos15-64 win10 win2012r2'''), + ]), +]) + +if (!params['GIT_REPO']) { error("You didn't define a GIT_REPO.") } + +def pr = [] // Mutable parameter set to pass to jobs. I know this is crazy. +String printParams = '' // String of params to print +for (param in params) { + printParams += param.toString() + '\n' + if (param.key != 'NODE_VERSIONS') { + pr.push(string(name: param.key, value: param.value)) + } +} +println "\n### BUILD PARAMETERS ###\n${printParams}" + +stage('Test llnode') { + def nodeVersions = params['NODE_VERSIONS'].split() + def lldbVersions = params['LLDB_VERSIONS'].split() + def buildJobs = [:] + for (int i = 0; i < nodeVersions.length; i++) { + int nodeIndex = i // locally scoped copy. + for (int j = 0; j < lldbVersions.length; j++) { + int lldbIndex = j // locally scoped copy. + def p = pr.collect() // local copy of params + p.push(string(name: 'NODE_VERSION', value: nodeVersions[nodeIndex])) + p.push(string(name: 'LLDB_VERSION', value: lldbVersions[lldbIndex])) + buildJobs["Node.js ${nodeVersions[nodeIndex]} lldb ${lldbVersions[lldbIndex]}"] = { build(job: 'llnode-continuous-integration', parameters: p) } + } + } + + println buildJobs + parallel(buildJobs) +} diff --git a/jenkins/scripts/common/colors.sh b/jenkins/scripts/common/colors.sh new file mode 100644 index 000000000..2dd6fe989 --- /dev/null +++ b/jenkins/scripts/common/colors.sh @@ -0,0 +1,61 @@ +# Helper vars for printing in color. Use with: +# echo -e "${RED}foo${NC}" # Echo foo in red, then reset color. +# printf "${BBLUE}foo${NC}" # Echo foo in bright blue, then reset color. + +# Include (source) with this line: +# . $(dirname $0)/helpers/colors.sh # Load helper script from gcfg/helpers. + +# Color escape codes, use with . Don't change \033 to \e, that doesn't work on +# macOS (\x1B instead). + +# I've kept the standard names, even though e.g. WHITE isn't white (use BWHITE). +# There are also a bajillion more combos (e.g. BGREDFGBLUE) with different +# FG/BG color combos, but I haven't needed these yet. + +case $- in *x*) xSet=true ;; esac # Note whether -x was set before. +set +x + +# Reset color: +NC='\033[0m' # No Color. + +# Basic colors: +BLACK='\033[0;30m' # Black. +RED='\033[0;31m' # Red. +GREEN='\033[0;32m' # Green. +YELLOW='\033[0;33m' # Yellow. +BLUE='\033[0;34m' # Blue. +MAGENTA='\033[0;35m' # Magenta (purple). +CYAN='\033[0;36m' # Light blue. +WHITE='\033[0;37m' # Light grey. + +# Bright colors: +BBLACK='\033[1;30m' # Bright black (dark grey). +BRED='\033[1;31m' # Bright Red. +BGREEN='\033[1;32m' # Bright Green. +BYELLOW='\033[1;33m' # Bright Yellow. +BBLUE='\033[1;34m' # Bright Blue. +BMAGENTA='\033[1;35m' # Bright Magenta (pink). +BCYAN='\033[1;36m' # Bright Light blue. +BWHITE='\033[1;37m' # Bright white (white). + +# Background colors: +BGBLACK='\033[0;40m' # Background Black. +BGRED='\033[0;41m' # Background Red. +BGGREEN='\033[0;42m' # Background Green. +BGYELLOW='\033[0;43m' # Background Yellow. +BGBLUE='\033[0;44m' # Background Blue. +BGMAGENTA='\033[0;45m' # Background Magenta (purple). +BGCYAN='\033[0;46m' # Background Light blue. +BGWHITE='\033[0;47m' # Background Light grey. + +# Bright background colors: +BGBBLACK='\033[1;40m' # Background Bright Black (dark grey). +BGBRED='\033[1;41m' # Background Bright Red. +BGBGREEN='\033[1;42m' # Background Bright Green. +BGBYELLOW='\033[1;43m' # Background Bright Yellow. +BGBBLUE='\033[1;44m' # Background Bright Blue. +BGBMAGENTA='\033[1;45m' # Background Bright Magenta (pink). +BGBCYAN='\033[1;46m' # Background Bright Light blue. +BGBWHITE='\033[1;47m' # Background Bright white. + +[ "$xSet" ] && set -x # If -x was set before, restore it. diff --git a/jenkins/scripts/common/getLLDB.sh b/jenkins/scripts/common/getLLDB.sh new file mode 100755 index 000000000..6cc50f6dc --- /dev/null +++ b/jenkins/scripts/common/getLLDB.sh @@ -0,0 +1,31 @@ +#!/bin/bash -ex + +DOWNLOAD_DIR="http://apt.llvm.org/xenial/pool/main/l/llvm-toolchain-$LLDB_VERSION/" + +rm -rf lldb-bin/ + +# Calculate os and arch. +os="$(uname | tr '[:upper:]' '[:lower:]')" +arch=$(uname -m) + +case $os in + linux) echo "$os found. Assuming Ubuntu 16.04...";; + darwin) exit 0;; + *) echo "$os CI is not supported yet"; exit 1;; +esac + +case $arch in + x86_64) arch=amd64;; +esac + +files=$(curl --compressed -L -s "$DOWNLOAD_DIR" | grep "^npm/npmrc +tmpdir=$PWD/npm/tmp +cache=$PWD/npm/cache +devdir=$PWD/npm/devdir +loglevel=error +progress=false +!!EOF + +node -v +npm -v +ls + +rm -Rf llnode +git clone --depth=1 -b ${GIT_BRANCH:?Undefined.} https://github.com/${GIT_REPO:?Undefined.}.git llnode +cd llnode + +npm install --nodedir=$(dirname $(dirname $(which node)))/include/node +npm test