Skip to content

Commit

Permalink
jenkins: add llnode pipeline and shell scripts
Browse files Browse the repository at this point in the history
The llnode CI isn't working right now, but hopefully by committing this
we can then iterate in GitHub.

Refs: nodejs#777
  • Loading branch information
gibfahn authored and refack committed Jun 1, 2018
1 parent aa8b341 commit 26f87d0
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jenkins/pipelines/llnode-pipeline.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env groovy

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 versions = params['NODE_VERSIONs'].split()
def buildJobs = [:]
for (int i = 0; i < versions.length; i++) {
int index = i // locally scoped copy.
def p = pr.collect() // local copy of params
p.push(string(name: 'NODE_VERSION', value: versions[index]))
buildJobs["${versions[index]}"] = { build(job: 'llnode-continuous-integration', parameters: p) }
}

println buildJobs
parallel(buildJobs)
}
63 changes: 63 additions & 0 deletions jenkins/scripts/common/colors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Helper vars for printing in colour. Use with:
# echo -e "${RED}foo${NC}" # Echo foo in red, then reset colour.
# printf "${BBLUE}foo${NC}" # Echo foo in bright blue, then reset colour.

# Include (source) with this line:
# . $(dirname $0)/helpers/colours.sh # Load helper script from gcfg/helpers.

# Colour 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 colour combos, but I haven't needed these yet.

case $- in *x*) xSet=true ;; esac # Note whether -x was set before.
set +x

# Reset colour:
NC='\033[0m' # No Colour.

# Basic colours:
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 colours:
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 colours:
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 colours:
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.
75 changes: 75 additions & 0 deletions jenkins/scripts/common/getNode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash -ex

# This script downloads the relevant Node binary for the arch from nodejs.org.
# Download the latest master/v6/v4 build from nodejs.org

. "$(dirname $0)"/colors.sh # Load colors.

# Help text to print on error.
sep="${MAGENTA}:${NC}" # Separator to use in help text.
helpText="Download the node binary for your machine from nodejs.org.
${CYAN}USAGE:${NC}
$0 8.9.1 [-m ubuntu1604-64] [-c Carbon] [-b v8.x] [-d 2017-11-20] [-m] [-r /path/to/node/]
8.9.0 $sep Node to download (8.9.0, master, 8, 8.9.0-nightly, latest, 6.2.)
Inexact values get most recent from range.
-p 8.9.0 $sep Previous version in this release line
-m ubuntu1604-64 $sep The jenkins machine label."

################################################################################
## Parse parameters

unset VERSION
while getopts ":b:c:d:p:hm" option; do
case "${option}" in
b) BRANCH="$OPTARG" ;;
h) echo -e "$helpText"; exit 0;;
\?) echo "Invalid option -$OPTARG."; exit 1 ;;
:) echo "Option -$OPTARG takes a parameter."; exit 1 ;;
*) echo "getopts gave me: ($OPTIND) $OPTARG"; exit 1 ;;
esac
done
shift $((OPTIND-1))

error() { echo -e "${BRED}ERROR:${NC} $1"; exit 1; }

[ -z "$1" ] && error "Must provide a node version to download"
NODE_VERSION="${1#v}"; shift # If node version has a v, drop it.

rm -rf ./node-*

DOWNLOAD_DIR="https://nodejs.org/download/release/"
case $NODE_VERSION in
*-nightly*) DOWNLOAD_DIR="https://nodejs.org/download/nightly/" ;;
esac

# Get available versions, grep for NODE_VERSION, and sort by biggest version number.
nodeGrep="$(echo "$NODE_VERSION" | sed 's/\./\\./g')" # Escape dots.
availableVersions=$(curl "$DOWNLOAD_DIR" | grep "^<a href="| cut -d \" -f 2 | tr -d /)

if $(echo "$availableVersions" | grep -q "^v\?$nodeGrep$"); then
version="$NODE_VERSION"
else
version=$(echo "$availableVersions" | grep "^v$nodeGrep" |
sort -n -t . -k 1.2 -k 2 -k 3 | tail -1)
fi

# Calculate OS and ARCH.
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH=$(uname -m)

case $OS in
*nt*|*NT*) OS=win EXT=zip;;
aix) ARCH=ppc64 ;;
esac
[ "$OS" != win ] && EXT=tar.gz

# TODO(gib): Handle x86 SmartOS (currently uses x64).
# TODO(gib): Handle arm64 machines.
case $ARCH in
x86_64|i86pc) ARCH=x64 ;; # i86pc is SmartOS.
i686) ARCH=x86 ;;
esac

curl -O "$DOWNLOAD_DIR$LINK/node-$LINK-$OS-$ARCH.$EXT"
gzip -cd node-$LINK-$OS-$ARCH.$EXT | tar xf - # Non-GNU tar can't handle gzips.
34 changes: 34 additions & 0 deletions jenkins/scripts/llnode-continuous-integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash -ex

"$(dirname $0)"/common/getNode.sh # Load colors.

export UNZIP_DIR=`ls |grep "node" |grep -v "gz"`
cd $WORKSPACE/node-*/bin

export PATH=$PWD:$PATH
cd $WORKSPACE
export NPM_CONFIG_USERCONFIG=$WORKSPACE/npmrc
export NPM_CONFIG_CACHE=$WORKSPACE/npm-cache
node -v
npm -v
export npm_loglevel=error
npm set progress=false
ls
git clone https://github.com/$GIT_REPO.git llnode
cd llnode
if [ $GIT_BRANCH != master ]; then
git fetch origin $GIT_BRANCH:testBranch
git checkout testBranch
fi

[ $(uname) = Darwin ] && git clone --depth=1 -b release_39 https://github.com/llvm-mirror/lldb.git lldb
# Initialize GYP
git clone https://chromium.googlesource.com/external/gyp.git tools/gyp
# Configure
[ $(uname) = Linux ] && GYP_ARGS="-Dlldb_dir=/usr/lib/llvm-3.8/" || GYP_ARGS=""
./gyp_llnode $GYP_ARGS
# Build
make -C out/ -j9

npm install
npm test

0 comments on commit 26f87d0

Please sign in to comment.