<commit_before>#!/bin/bash

set -e

# Kill background tasks if the script exits early
# single quotes are intentional
# see http://stackoverflow.com/questions/360201/how-do-i-kill-background-processes-jobs-when-my-shell-script-exits
# and https://wiki.jenkins-ci.org/display/JENKINS/Aborting+a+build
trap 'JOBS=$(jobs -p); if [ -n "${JOBS}" ]; then kill "${JOBS}"; fi' SIGINT SIGTERM EXIT

echo "################################################################################"
echo "# INSTALLING LEGACY DEPENDENCIES"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm install

echo "################################################################################"
echo "# CLEANING"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm run grunt -- clean
docker run ${DOCKER_RUN_OPTS} npm run grunt:concurrent -- clean
docker run ${DOCKER_RUN_OPTS} npm run clean-empty-packages
rm -rf "${SDK_ROOT_DIR}/.sauce/*/sc.*"
rm -rf "${SDK_ROOT_DIR}/.sauce/*/sauce_connect*log"

rm -rf ${SDK_ROOT_DIR}/reports
mkdir -p ${SDK_ROOT_DIR}/reports/coverage
mkdir -p ${SDK_ROOT_DIR}/reports/coverage-final
mkdir -p ${SDK_ROOT_DIR}/reports/junit
mkdir -p ${SDK_ROOT_DIR}/reports/logs
mkdir -p ${SDK_ROOT_DIR}/reports/sauce
chmod -R ugo+w ${SDK_ROOT_DIR}/reports

echo "################################################################################"
echo "# BOOTSTRAPPING MODULES"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm run bootstrap

echo "################################################################################"
echo "# BUILDING MODULES"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm run build

echo "################################################################################"
echo "# RUNNING TESTS"
echo "################################################################################"

PIDS=""

# Ideally, the following would be done with lerna but there seem to be some bugs
# in --scope and --ignore
PACKAGES=$(ls "${SDK_ROOT_DIR}/packages")
PACKAGES+=" legacy-node"
PACKAGES+=" legacy-browser"
for PACKAGE in ${PACKAGES}; do
  if ! echo ${PACKAGE} | grep -qc -v test-helper ; then
    continue
  fi

  if ! echo ${PACKAGE} | grep -qc -v bin- ; then
    continue
  fi

  if ! echo ${PACKAGE} | grep -qc -v xunit-with-logs ; then
    continue
  fi

  CONTAINER_NAME="${PACKAGE}-${BUILD_NUMBER}"

  if [ -n "${CONCURRENCY}" ]; then<commit_msg>chore(tooling): do not run legacy browser tests when sauce is down<commit_after>#!/bin/bash

set -e

# Kill background tasks if the script exits early
# single quotes are intentional
# see http://stackoverflow.com/questions/360201/how-do-i-kill-background-processes-jobs-when-my-shell-script-exits
# and https://wiki.jenkins-ci.org/display/JENKINS/Aborting+a+build
trap 'JOBS=$(jobs -p); if [ -n "${JOBS}" ]; then kill "${JOBS}"; fi' SIGINT SIGTERM EXIT

echo "################################################################################"
echo "# INSTALLING LEGACY DEPENDENCIES"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm install

echo "################################################################################"
echo "# CLEANING"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm run grunt -- clean
docker run ${DOCKER_RUN_OPTS} npm run grunt:concurrent -- clean
docker run ${DOCKER_RUN_OPTS} npm run clean-empty-packages
rm -rf "${SDK_ROOT_DIR}/.sauce/*/sc.*"
rm -rf "${SDK_ROOT_DIR}/.sauce/*/sauce_connect*log"

rm -rf ${SDK_ROOT_DIR}/reports
mkdir -p ${SDK_ROOT_DIR}/reports/coverage
mkdir -p ${SDK_ROOT_DIR}/reports/coverage-final
mkdir -p ${SDK_ROOT_DIR}/reports/junit
mkdir -p ${SDK_ROOT_DIR}/reports/logs
mkdir -p ${SDK_ROOT_DIR}/reports/sauce
chmod -R ugo+w ${SDK_ROOT_DIR}/reports

echo "################################################################################"
echo "# BOOTSTRAPPING MODULES"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm run bootstrap

echo "################################################################################"
echo "# BUILDING MODULES"
echo "################################################################################"
docker run ${DOCKER_RUN_OPTS} npm run build

echo "################################################################################"
echo "# RUNNING TESTS"
echo "################################################################################"

PIDS=""

# Ideally, the following would be done with lerna but there seem to be some bugs
# in --scope and --ignore
PACKAGES=$(ls "${SDK_ROOT_DIR}/packages")
PACKAGES+=" legacy-node"
if [ -z "${SAUCE_IS_DOWN}" ]; then
  PACKAGES+=" legacy-browser"
fi
for PACKAGE in ${PACKAGES}; do
  if ! echo ${PACKAGE} | grep -qc -v test-helper ; then
    continue
  fi

  if ! echo ${PACKAGE} | grep -qc -v bin- ; then
    continue
  fi

  if ! echo ${PACKAGE} | grep -qc -v xunit-with-logs ; then
    continue
  fi

  CONTAINER_NAME="${PACKAGE}-${BUILD_NUMBER}"

  if [ -n "${CONCURRENCY}" ]; then
{'fraction_non_alphanumeric': 0.4000742252737057, 'fraction_numerical': 0.002226758211170904, 'mean_word_length': 6.455048409405256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '59097', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1460, 'n_words': 390}