From b31d6188f946c4c65c061d67ed49e5f3b7ea2f5f Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 3 Feb 2017 16:19:22 -0800 Subject: [PATCH] added jenkins --- jenkins.groovy | 32 ++++++++++++++++++++++++++++ jenkins.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +++ travis-tests.sh | 1 - 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 jenkins.groovy create mode 100644 jenkins.sh diff --git a/jenkins.groovy b/jenkins.groovy new file mode 100644 index 00000000..193e506e --- /dev/null +++ b/jenkins.groovy @@ -0,0 +1,32 @@ +import jobs.generation.Utilities; +import jobs.generation.InternalUtilities; + +def project = GithubProject +def branch = GithubBranchName + +[true, false].each { isPR -> + def newJobName = InternalUtilities.getFullJobName(project, "Default", isPR) + def newJob = job(newJobName) { + steps { + shell("./jenkins.sh ${isPR}") + } + + if (!isPR) { + wrappers { + credentialsBinding { + string('PXT_ACCESS_TOKEN', 'pxt_access_token') + string('PXT_RELEASE_REPO', 'pxt_release_repo_calliope') + } + } + } + } + + Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020') + InternalUtilities.standardJobSetup(newJob, project, isPR, "*/*") + + if (isPR) { + Utilities.addGithubPRTrigger(newJob, "Default Testing") + } else { + Utilities.addGithubPushTrigger(newJob) + } +} diff --git a/jenkins.sh b/jenkins.sh new file mode 100644 index 00000000..2e8e964b --- /dev/null +++ b/jenkins.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Set up NVM +export NVM_DIR="/home/dotnet-bot/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + +nvm install 5 + +# Set up build environment variables +echo ---------- Setting build environment variables +echo Git branch: $GIT_BRANCH +echo isPR: $1 + +originRegex="^origin/.*" +branchRegex="^origin/\K.*(?=$)" + +if [[ "$GIT_BRANCH" =~ $originRegex ]]; then + branchName=$(echo ${GIT_BRANCH} | grep -oP $branchRegex) + echo Setting TRAVIS_BRANCH to ${branchName} + export TRAVIS_BRANCH=${branchName} +else + echo Setting TRAVIS_BRANCH to $GIT_BRANCH + export TRAVIS_BRANCH=$GIT_BRANCH +fi + +if [ "$1" == "false" ]; then + echo Setting TRAVIS_PULL_REQUEST to false + export TRAVIS_PULL_REQUEST=false + + if [ $TRAVIS_BRANCH == "master" ]; then + if [[ -z $PXT_RELEASE_REPO ]]; then + echo Cannot find release repo; skipping tag checks + else + gitTag=$(git describe --tags --exact-match 2> /dev/null) + builtTag=$(git ls-remote --tags $PXT_RELEASE_REPO | grep -o "refs/tags/$gitTag$") + + echo Current tag: $gitTag + echo Built tag: $builtTag + + if [[ ! -z $gitTag && -z $builtTag ]]; then + echo Built tag not found; building tag + echo Setting TRAVIS_BRANCH to $gitTag + export TRAVIS_BRANCH=$gitTag + echo Setting TRAVIS_TAG to $gitTag + export TRAVIS_TAG=$gitTag + else + echo Not a tag build + fi + fi + fi +fi + +# Perform build +npm install +npm test diff --git a/package.json b/package.json index 62f6e91b..7458224d 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,8 @@ }, "dependencies": { "pxt-core": "0.11.13" + }, + "scripts": { + "test": "node node_modules/pxt-core/built/pxt.js travis" } } diff --git a/travis-tests.sh b/travis-tests.sh index bcc0c613..f1b58d3c 100755 --- a/travis-tests.sh +++ b/travis-tests.sh @@ -7,4 +7,3 @@ export KS_FORCE_CLOUD=yes (cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js test) (cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js test) node node_modules/pxt-core/built/pxt.js testdir tests -(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-v1.json)