Commit b005141d by Will Daly

Updated Jenkins scripts

parent ae61db9a
#!/usr/bin/env bash
set -e
###############################################################################
#
# edx-acceptance.sh
#
# Execute acceptance tests for edx-platform.
#
# This script can be called from a Jenkins
# job that defines these environment variables:
#
# `TEST_SUITE` defines which acceptance test suite to run
# Possible values are:
#
# - "lms": Run the acceptance (Selenium) tests for the LMS
# - "cms": Run the acceptance (Selenium) tests for Studio
#
# `FEATURE_PATH` is the path to the lettuce .feature file
# containing the tests to run. If empty, run all the tests.
#
# Other assumptions:
#
# - The edx-platform git repository is checked out by the Jenkins git plugin.
#
# - Jenkins logs in as user "jenkins"
#
# - The Jenkins file system root is "/home/jenkins"
#
# - An init script creates a virtualenv at "/home/jenkins/edx-venv"
# with some requirements pre-installed (such as scipy)
#
# Jenkins worker setup:
# See the edx/configuration repo for Jenkins worker provisioning scripts.
# The provisioning scripts install requirements that this script depends on!
#
###############################################################################
source $HOME/jenkins_env
# Clean up previous builds
git clean -qxfd
# Clear the mongo database
# Note that this prevents us from running jobs in parallel on a single worker.
mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})'
# Ensure we have fetched origin/master
# Some of the reporting tools compare the checked out branch to origin/master;
# depending on how the GitHub plugin refspec is configured, this may
# not already be fetched.
git fetch origin master:refs/remotes/origin/master
# Bootstrap Ruby requirements so we can run the tests
bundle install
# Activate the Python virtualenv
source $HOME/edx-venv/bin/activate
rake test:acceptance:${TEST_SUITE}["-v 3 ${FEATURE_PATH}"]
#!/usr/bin/env bash
set -e
###############################################################################
#
# edx-all-tests.sh
#
# Execute all tests for edx-platform.
#
# This script can be called from a Jenkins
# multiconfiguration job that defines these environment
# variables:
#
# `TEST_SUITE` defines which kind of test to run.
# Possible values are:
#
# - "quality": Run the quality (pep8/pylint) checks
# - "unit": Run the JavaScript and Python unit tests
# (also tests building the Sphinx documentation,
# because we couldn't think of a better place to put it)
# - "lms-acceptance": Run the acceptance (Selenium) tests for the LMS
# - "cms-acceptance": Run the acceptance (Selenium) tests for Studio
#
# `SHARD` is a number (1, 2, or 3) indicating which subset of the tests
# to build. Currently, "lms-acceptance" has two shards (1 and 2),
# "cms-acceptance" has three shards (1, 2, and 3), and all the
# other test suites have one shard.
#
# Jenkins configuration:
#
# - The edx-platform git repository is checked out by the Jenkins git plugin.
#
# - Jenkins logs in as user "jenkins"
#
# - The Jenkins file system root is "/home/jenkins"
#
# - An init script creates a virtualenv at "/home/jenkins/edx-venv"
# with some requirements pre-installed (such as scipy)
#
# Jenkins worker setup:
# See the edx/configuration repo for Jenkins worker provisioning scripts.
# The provisioning scripts install requirements that this script depends on!
#
###############################################################################
source $HOME/jenkins_env
# Clean up previous builds
git clean -qxfd
# Clear the mongo database
# Note that this prevents us from running jobs in parallel on a single worker.
mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})'
# Ensure we have fetched origin/master
# Some of the reporting tools compare the checked out branch to origin/master;
# depending on how the GitHub plugin refspec is configured, this may
# not already be fetched.
git fetch origin master:refs/remotes/origin/master
# Bootstrap Ruby requirements so we can run the tests
bundle install
# Activate the Python virtualenv
source $HOME/edx-venv/bin/activate
case "$TEST_SUITE" in
"quality")
rake pep8 > pep8.log || { cat pep8.log ; exit 1; }
rake pylint > pylint.log || { cat pylint.log; exit 1; }
rake quality
# Need to create an empty test result so the post-build
# action doesn't fail the build.
mkdir -p reports
cat > reports/quality.xml <<END
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="quality" tests="1" errors="0" failures="0" skip="0">
<testcase classname="quality" name="quality" time="0.604"></testcase>
</testsuite>
END
;;
"unit")
rake test
rake coverage
;;
"lms-acceptance")
rake test:acceptance:lms["-v 3 --tag shard_${SHARD}"]
;;
"cms-acceptance")
rake test:acceptance:cms["-v 3 --tag shard_${SHARD}"]
;;
esac
#! /bin/bash
set -e
set -x
##
## requires >= 1.3.0 of the Jenkins git plugin
##
function github_status {
if [[ ! ${GIT_URL} =~ git@github.com:([^/]+)/([^\.]+).git ]]; then
echo "Cannot parse Github org or repo from URL, using defaults."
ORG="edx"
REPO="edx-platform"
else
ORG=${BASH_REMATCH[1]}
REPO=${BASH_REMATCH[2]}
fi
gcli status create $ORG $REPO $GIT_COMMIT \
--params=$1 \
target_url:$BUILD_URL \
description:"Build #$BUILD_NUMBER $2" \
-f csv
}
function github_mark_failed_on_exit {
trap '[ $? == "0" ] || github_status state:failure "failed"' EXIT
}
git remote prune origin
github_mark_failed_on_exit
github_status state:pending "is running"
# Reset the submodule, in case it changed
git submodule foreach 'git reset --hard HEAD'
# Assumes that Xvfb has been started by upstart
# and is capturing display :1
# The command for this is:
# /usr/bin/Xvfb :1 -screen 0 1024x268x24
# This allows us to run Chrome or Firefox without a display
export DISPLAY=:1
# Set the IO encoding to UTF-8 so that askbot will start
export PYTHONIOENCODING=UTF-8
GIT_BRANCH=${GIT_BRANCH/HEAD/master}
# When running in parallel on jenkins, workspace could be suffixed by @x
# In that case, we want to use a separate virtualenv that matches up with
# workspace
#
# We need to handle both the case of /path/to/workspace
# and /path/to/workspace@2, which is why we use the following substitutions
#
# $WORKSPACE is the absolute path for the workspace
WORKSPACE_SUFFIX=$(expr "$WORKSPACE" : '.*\(@.*\)') || true
VIRTUALENV_DIR="/mnt/virtualenvs/${JOB_NAME}${WORKSPACE_SUFFIX}"
if [ ! -d "$VIRTUALENV_DIR" ]; then
mkdir -p "$VIRTUALENV_DIR"
virtualenv --system-site-packages "$VIRTUALENV_DIR"
fi
export PIP_DOWNLOAD_CACHE=/mnt/pip-cache
source $VIRTUALENV_DIR/bin/activate
bundle install
rake install_prereqs
rake clobber
# Run the unit tests (use phantomjs for javascript unit tests)
rake test
# Generate pylint and pep8 reports
rake pep8 > pep8.log || cat pep8.log
rake pylint > pylint.log || cat pylint.log
# Generate coverage reports
rake coverage
# Generate quality reports
rake quality
rake autodeploy_properties
github_status state:success "passed"
#! /bin/bash
set -e
set -x
git remote prune origin
# Reset the submodule, in case it changed
git submodule foreach 'git reset --hard HEAD'
# Set the IO encoding to UTF-8 so that askbot will start
export PYTHONIOENCODING=UTF-8
if [ ! -d /mnt/virtualenvs/"$JOB_NAME" ]; then
mkdir -p /mnt/virtualenvs/"$JOB_NAME"
virtualenv --system-site-packages /mnt/virtualenvs/"$JOB_NAME"
fi
export PIP_DOWNLOAD_CACHE=/mnt/pip-cache
source /mnt/virtualenvs/"$JOB_NAME"/bin/activate
rake install_prereqs
rake clobber
TESTS_FAILED=0
# Assumes that Xvfb has been started by upstart
# and is capturing display :1
# The command for this is:
# /usr/bin/Xvfb :1 -screen 0 1024x268x24
# This allows us to run Chrome or Firefox without a display
export DISPLAY=:1
SKIP_TESTS=""
# Testing for the existance of these environment variables
if [ ! -z ${LETTUCE_BROWSER+x} ]; then
SKIP_TESTS="--tag -skip_$LETTUCE_BROWSER"
fi
if [ "$LETTUCE_SELENIUM_CLIENT" == saucelabs ]; then
# SAUCE_INFO is a - seperated string PLATFORM-BROWSER-VERSION-DEVICE
# Error checking is done in the setting up of the browser
IFS='-' read -a SAUCE <<< "${SAUCE_INFO}"
SKIP_TESTS="--tag -skip_sauce --tag -skip_${SAUCE[1]}"
fi
# Run the lms and cms acceptance tests
rake test:acceptance["$SKIP_TESTS"] || TESTS_FAILED=1
[ $TESTS_FAILED == '0' ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment