Skip to content

Commit a5368f7

Browse files
gibfahnrefack
authored andcommitted
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: #777 Responsible-commiter: Refael Ackermann <[email protected]> Reviewed-By: Matheus Marchini <[email protected]>
1 parent 060809a commit a5368f7

File tree

6 files changed

+291
-0
lines changed

6 files changed

+291
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env groovy
2+
3+
properties([
4+
parameters([
5+
string(name: 'GIT_REPO', defaultValue: 'nodejs/llnode', description: 'Fetch from this repo (e.g. gibfahn/llnode)'),
6+
string(name: 'GIT_BRANCH', defaultValue: 'master', description: 'Branch to test (e.g. master, refs/pull/999/head).'),
7+
string(name: 'NODE_VERSIONS', defaultValue: 'v6 v8 v9 v10 nightly canary', description: 'Space separated list of NODE_VERSIONS to pass to llnode-continuous-integration.'),
8+
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.'),
9+
string(name: 'MACHINES', defaultValue: 'all', description: '''Can be "all" or a space-separated list of nodes, eg:
10+
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'''),
11+
]),
12+
])
13+
14+
if (!params['GIT_REPO']) { error("You didn't define a GIT_REPO.") }
15+
16+
def pr = [] // Mutable parameter set to pass to jobs. I know this is crazy.
17+
String printParams = '' // String of params to print
18+
for (param in params) {
19+
printParams += param.toString() + '\n'
20+
if (param.key != 'NODE_VERSIONS') {
21+
pr.push(string(name: param.key, value: param.value))
22+
}
23+
}
24+
println "\n### BUILD PARAMETERS ###\n${printParams}"
25+
26+
stage('Test llnode') {
27+
def nodeVersions = params['NODE_VERSIONS'].split()
28+
def lldbVersions = params['LLDB_VERSIONS'].split()
29+
def buildJobs = [:]
30+
for (int i = 0; i < nodeVersions.length; i++) {
31+
int nodeIndex = i // locally scoped copy.
32+
for (int j = 0; j < lldbVersions.length; j++) {
33+
int lldbIndex = j // locally scoped copy.
34+
def p = pr.collect() // local copy of params
35+
p.push(string(name: 'NODE_VERSION', value: nodeVersions[nodeIndex]))
36+
p.push(string(name: 'LLDB_VERSION', value: lldbVersions[lldbIndex]))
37+
buildJobs["Node.js ${nodeVersions[nodeIndex]} lldb ${lldbVersions[lldbIndex]}"] = { build(job: 'llnode-continuous-integration', parameters: p) }
38+
}
39+
}
40+
41+
println buildJobs
42+
parallel(buildJobs)
43+
}

jenkins/scripts/common/colors.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Helper vars for printing in color. Use with:
2+
# echo -e "${RED}foo${NC}" # Echo foo in red, then reset color.
3+
# printf "${BBLUE}foo${NC}" # Echo foo in bright blue, then reset color.
4+
5+
# Include (source) with this line:
6+
# . $(dirname $0)/helpers/colors.sh # Load helper script from gcfg/helpers.
7+
8+
# Color escape codes, use with . Don't change \033 to \e, that doesn't work on
9+
# macOS (\x1B instead).
10+
11+
# I've kept the standard names, even though e.g. WHITE isn't white (use BWHITE).
12+
# There are also a bajillion more combos (e.g. BGREDFGBLUE) with different
13+
# FG/BG color combos, but I haven't needed these yet.
14+
15+
case $- in *x*) xSet=true ;; esac # Note whether -x was set before.
16+
set +x
17+
18+
# Reset color:
19+
NC='\033[0m' # No Color.
20+
21+
# Basic colors:
22+
BLACK='\033[0;30m' # Black.
23+
RED='\033[0;31m' # Red.
24+
GREEN='\033[0;32m' # Green.
25+
YELLOW='\033[0;33m' # Yellow.
26+
BLUE='\033[0;34m' # Blue.
27+
MAGENTA='\033[0;35m' # Magenta (purple).
28+
CYAN='\033[0;36m' # Light blue.
29+
WHITE='\033[0;37m' # Light grey.
30+
31+
# Bright colors:
32+
BBLACK='\033[1;30m' # Bright black (dark grey).
33+
BRED='\033[1;31m' # Bright Red.
34+
BGREEN='\033[1;32m' # Bright Green.
35+
BYELLOW='\033[1;33m' # Bright Yellow.
36+
BBLUE='\033[1;34m' # Bright Blue.
37+
BMAGENTA='\033[1;35m' # Bright Magenta (pink).
38+
BCYAN='\033[1;36m' # Bright Light blue.
39+
BWHITE='\033[1;37m' # Bright white (white).
40+
41+
# Background colors:
42+
BGBLACK='\033[0;40m' # Background Black.
43+
BGRED='\033[0;41m' # Background Red.
44+
BGGREEN='\033[0;42m' # Background Green.
45+
BGYELLOW='\033[0;43m' # Background Yellow.
46+
BGBLUE='\033[0;44m' # Background Blue.
47+
BGMAGENTA='\033[0;45m' # Background Magenta (purple).
48+
BGCYAN='\033[0;46m' # Background Light blue.
49+
BGWHITE='\033[0;47m' # Background Light grey.
50+
51+
# Bright background colors:
52+
BGBBLACK='\033[1;40m' # Background Bright Black (dark grey).
53+
BGBRED='\033[1;41m' # Background Bright Red.
54+
BGBGREEN='\033[1;42m' # Background Bright Green.
55+
BGBYELLOW='\033[1;43m' # Background Bright Yellow.
56+
BGBBLUE='\033[1;44m' # Background Bright Blue.
57+
BGBMAGENTA='\033[1;45m' # Background Bright Magenta (pink).
58+
BGBCYAN='\033[1;46m' # Background Bright Light blue.
59+
BGBWHITE='\033[1;47m' # Background Bright white.
60+
61+
[ "$xSet" ] && set -x # If -x was set before, restore it.

jenkins/scripts/common/getLLDB.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash -ex
2+
3+
DOWNLOAD_DIR="http://apt.llvm.org/xenial/pool/main/l/llvm-toolchain-$LLDB_VERSION/"
4+
5+
rm -rf lldb-bin/
6+
7+
# Calculate os and arch.
8+
os="$(uname | tr '[:upper:]' '[:lower:]')"
9+
arch=$(uname -m)
10+
11+
case $os in
12+
linux) echo "$os found. Assuming Ubuntu 16.04...";;
13+
darwin) exit 0;;
14+
*) echo "$os CI is not supported yet"; exit 1;;
15+
esac
16+
17+
case $arch in
18+
x86_64) arch=amd64;;
19+
esac
20+
21+
files=$(curl --compressed -L -s "$DOWNLOAD_DIR" | grep "^<a href=" | cut -d \" -f 2)
22+
debFilename=$(echo "$files" | grep "^lldb-$LLDB_VERSION.*$arch.deb")
23+
debFilename2=$(echo "$files" | grep "^libllvm$LLDB_VERSION.*$arch.deb")
24+
25+
mkdir lldb-bin
26+
27+
dpkg-deb -xv <(curl -L -s "${DOWNLOAD_DIR}${debFilename}") lldb-bin/
28+
dpkg-deb -xv <(curl -L -s "${DOWNLOAD_DIR}lib${debFilename}") lldb-bin/
29+
dpkg-deb -xv <(curl -L -s "${DOWNLOAD_DIR}${debFilename2}") lldb-bin/
30+
31+
ln -s $(pwd)/lldb-bin/usr/bin/lldb-${LLDB_VERSION} $(pwd)/lldb-bin/usr/bin/lldb

jenkins/scripts/common/getNode.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash -ex
2+
3+
# This script downloads the relevant Node binary for the arch from nodejs.org.
4+
# Download the latest v10/v9/v8/v6/v4 build from nodejs.org
5+
6+
. "$(dirname $0)"/colors.sh # Load colors.
7+
8+
# Help text to print on error.
9+
sep="${MAGENTA}:${NC}" # Separator to use in help text.
10+
helpText="Download the node binary for your machine from nodejs.org.
11+
${CYAN}USAGE:${NC}
12+
$0 8.9.1
13+
14+
8.9.0 $sep Node to download (8.9.0, master, 8, 8.9.0-nightly, latest, 6.2.)
15+
Inexact values get most recent from range."
16+
17+
################################################################################
18+
## Parse parameters
19+
20+
unset NODE_VERSION
21+
while getopts ":h" option; do
22+
case "${option}" in
23+
h) echo -e "$helpText"; exit 0;;
24+
\?) echo "Invalid option -$OPTARG."; exit 1 ;;
25+
:) echo "Option -$OPTARG takes a parameter."; exit 1 ;;
26+
*) echo "Script doesn't catch the parameter at $OPTIND, $OPTARG."; exit 1 ;;
27+
esac
28+
done
29+
shift $((OPTIND-1))
30+
31+
error() { echo -e "${BRED}ERROR:${NC} $1"; exit 1; }
32+
33+
[ -z "$1" ] && error "Must provide a node version to download"
34+
NODE_VERSION="${1#v}"; shift # If node version has a v, drop it.
35+
36+
################################################################################
37+
## Work out version to download
38+
39+
rm -rf node-bin/
40+
41+
DOWNLOAD_DIR="https://nodejs.org/download/release/"
42+
case $NODE_VERSION in
43+
*nightly*) DOWNLOAD_DIR="https://nodejs.org/download/nightly/" ;;
44+
*canary*) DOWNLOAD_DIR="https://nodejs.org/download/v8-canary/" ;;
45+
esac
46+
47+
# Get available versions, grep for NODE_VERSION, and sort by biggest version number.
48+
nodeGrep="$(echo "$NODE_VERSION" | sed 's/\./\\./g')" # Escape dots.
49+
availableVersions=$(curl "$DOWNLOAD_DIR" | grep "^<a href="| cut -d \" -f 2 | tr -d /)
50+
51+
if $(echo "$availableVersions" | grep -q "^v\?$nodeGrep$"); then
52+
version="$NODE_VERSION"
53+
else
54+
version=$(echo "$availableVersions" | grep "$nodeGrep" |
55+
sort -n -t . -k 1.2 -k 2 -k 3 | tail -1)
56+
fi
57+
58+
# Calculate os and arch.
59+
os="$(uname | tr '[:upper:]' '[:lower:]')"
60+
arch=$(uname -m)
61+
62+
case $os in
63+
*nt*|*NT*) os=win ext=zip;;
64+
aix) arch=ppc64 ;;
65+
esac
66+
[ "$os" != win ] && ext=tar.gz
67+
68+
# TODO(gib): Handle x86 SmartOS (currently uses x64).
69+
# TODO(gib): Handle arm64 machines.
70+
case $arch in
71+
x86_64|i86pc) arch=x64 ;; # i86pc is SmartOS.
72+
i686) arch=x86 ;;
73+
esac
74+
75+
################################################################################
76+
## Download and extract Node
77+
78+
curl "$DOWNLOAD_DIR$version/node-$version-$os-$arch.$ext" |
79+
gzip -cd | tar xf - # Non-GNU tar can't handle gzips.
80+
mv node-$version-$os-$arch node-bin/

jenkins/scripts/common/helpers.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Helper functions and variables. Script should be sourced.
2+
3+
# No POSIX way to get dir of sourced script.
4+
[ "$BASH_VERSION" ] && thisDir="$(dirname ${BASH_SOURCE[0]})"
5+
[ "$ZSH_VERSION" ] && thisDir="$(dirname $0)"
6+
[ -z "$thisDir" ] && { echo "Must be run through bash or ZSH to get sourced dir"; exit 1; }
7+
8+
# Set BUILD_TOOLS to path to BUILD_TOOLS dir, change if you move this file.
9+
export BUILD_TOOLS="$(cd $thisDir/../../; pwd)"
10+
11+
# Get colour aliases.
12+
. "$BUILD_TOOLS"/jenkinsnode/common/colours.sh
13+
14+
error() { echo -e "${BRED}ERROR:${NC} $1"; exit 1; }
15+
warn() { echo -e "${YELLOW}Warning:${NC} $1"; }
16+
17+
# Separator to use in help text.
18+
sep="${MAGENTA}:${NC}"
19+
20+
21+
# Set OS and ARCH variables if unset.
22+
if [ -z "$OS" -a -z "$ARCH" ]; then
23+
OS="$(uname | tr '[:upper:]' '[:lower:]')"
24+
ARCH=$(uname -m)
25+
26+
case $OS in
27+
*nt*|*NT*) OS=win ;;
28+
aix) ARCH=ppc64 ;;
29+
esac
30+
31+
case $ARCH in
32+
x86_64) ARCH=x64 ;;
33+
i686) ARCH=x86 ;;
34+
esac
35+
export OS ARCH
36+
fi
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash -ex
2+
3+
[ -z "$NODE_VERSION" ] &&
4+
[ -z "$LLDB_VERSION" ] &&
5+
6+
rm -rf llnode npm
7+
8+
# Download node tarball.
9+
bash -$- "$(dirname $0)"/common/getNode.sh ${NODE_VERSION:? Undefined.}
10+
11+
# Download lldb binary
12+
bash -$- "$(dirname $0)"/common/getLLDB.sh ${LLDB_VERSION:? Undefined.}
13+
14+
export PATH="$PWD/node-bin/bin:$PATH"
15+
export PATH="$PWD/lldb-bin/usr/bin:$PATH"
16+
17+
arch=$(uname -m)
18+
export LD_LIBRARY_PATH="$PWD/lldb-bin/usr/lib/${arch}-linux-gnu/"
19+
20+
export npm_config_userconfig="$PWD"/npm/npmrc
21+
mkdir -p npm/{cache,devdir,tmp}
22+
23+
cat <<!!EOF >npm/npmrc
24+
tmpdir=$PWD/npm/tmp
25+
cache=$PWD/npm/cache
26+
devdir=$PWD/npm/devdir
27+
loglevel=error
28+
progress=false
29+
!!EOF
30+
31+
node -v
32+
npm -v
33+
ls
34+
35+
rm -Rf llnode
36+
git clone --depth=1 -b ${GIT_BRANCH:?Undefined.} https://github.com/${GIT_REPO:?Undefined.}.git llnode
37+
cd llnode
38+
39+
npm install --nodedir=$(dirname $(dirname $(which node)))/include/node
40+
npm test

0 commit comments

Comments
 (0)