<commit_before>#!/usr/bin/env bash

# Required on OS X.
export set ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

function banner() {
  echo
  echo "[== $@ ==]"
  echo
}

function die() {
  if (( $# > 0 )); then
    echo -e "\n$@"
  fi
  exit 1
}

function usage() {
  echo "Runs commons tests for local or hosted CI."
  echo
  echo "Usage: $0 (-h|-bsdjp)"
  echo " -h           print out this help message"
  echo " -b           skip bootstraping pants from local sources"
  echo " -s           skip self-distribution tests"
  echo " -d           if running jvm tests, don't use nailgun daemons"
  echo " -j           skip jvm tests"
  echo " -p           skip python tests"
  echo " -c           skip pants integration tests"
  if (( $# > 0 )); then
    die "$@"
  else
    exit 0
  fi
}

daemons="--ng-daemons"

while getopts "hbsdjpc" opt; do
  case ${opt} in
    h) usage ;;
    b) skip_bootstrap="true" ;;
    s) skip_distribution="true" ;;
    d) daemons="--no-ng-daemons" ;;
    j) skip_java="true" ;;
    p) skip_python="true" ;;
    c) skip_integration="true" ;;
    *) usage "Invalid option: -${OPTARG}" ;;
  esac
done

banner "CI BEGINS"

if [[ "${skip_bootstrap:-false}" == "false" ]]; then
  banner "Bootstrapping pants"
  (
    ./build-support/python/clean.sh && \
    PANTS_VERBOSE=1 PEX_VERBOSE=1 PYTHON_VERBOSE=1 ./pants;
    ./pants.pex goal goals
  ) || die "Failed to bootstrap pants."
fi

./pants.pex goal clean-all || die "Failed to clean-all."

# TODO(<NAME>): Re-plumb build such that it grabs constraints from the built python_binary
# target(s).
INTERPRETER_CONSTRAINTS=(
  "CPython>=2.6,<3"
  "CPython>=3.3"
)
for constraint in ${INTERPRETER_CONSTRAINTS[@]}; do
  COMMAND_INTERPRETER_CONSTRAINTS=(
    ${COMMAND_INTERPRETER_CONSTRAINTS[@]}
    -i "${constraint}"
  )
  GOAL_INTERPRETER_CONSTRAINTS=(
    ${GOAL_INTERPRETER_CONSTRAINTS[@]}
    --test-pytest-interpreter="${constraint}"
  )
done

if [[ "${skip_distribution:-false}" == "false" ]]; then
  # TODO(<NAME>): Take this further and dogfood a bootstrap from the sdists generated by
  # setup_py
  banner "Running pants distribution tests"
  (
    ./pants.pex py --pex ${COMMAND_INTERPRETER_CONSTRAINTS[@]} \
      src/python/pants:_pants_transitional_publishable_binary_ && \
    mv dist/_pants_transitional_publishable_binary_.pex dist/self.pex && \
    ./dist/self.pex build ${COMMAND_INTERPRETER_CONSTRAINTS[@]} \
      src/python/pants:_pants_transitional_publishable_binary_ && \
    ./dist/self.pex setup_py --recursive src/python/pants:pants-packaged
  ) || die "Failed to create pants distributions."
fi

if [[ "${skip_java:-false}" == "false" ]]; then
  banner "Running jvm tests"
  (
    ./pants.pex goal test {src,tests}/{java,scala}:: $daemons
  ) || die "Jvm test failure."
fi

if [[ "${skip_python:-false}" == "false" ]]; then
  banner "Running python tests"
  (
    PANTS_PYTHON_TEST_FAILSOFT=1 ./pants.pex goal test tests/python/pants_test:all \
      ${GOAL_INTERPRETER_CONSTRAINTS[@]}
  ) || die "Python test failure"
fi

if [[ "${skip_integration:-false}" == "false" ]]; then
  banner "Running Pants Integration tests"
  (
    PANTS_PYTHON_TEST_FAILSOFT=1 ./pants.pex goal test tests/python/pants_test:integration \
      ${GOAL_INTERPRETER_CONSTRAINTS[@]}
  ) || die "Pants Integration test failure"
fi

banner "CI SUCCESS"<commit_msg>Fix ci.sh flags.<commit_after>#!/usr/bin/env bash

# Required on OS X.
export set ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

function banner() {
  echo
  echo "[== $@ ==]"
  echo
}

function die() {
  if (( $# > 0 )); then
    echo -e "\n$@"
  fi
  exit 1
}

function usage() {
  echo "Runs commons tests for local or hosted CI."
  echo
  echo "Usage: $0 (-h|-bsdjp)"
  echo " -h           print out this help message"
  echo " -b           skip bootstraping pants from local sources"
  echo " -s           skip self-distribution tests"
  echo " -d           if running jvm tests, don't use nailgun daemons"
  echo " -j           skip jvm tests"
  echo " -p           skip python tests"
  echo " -c           skip pants integration tests"
  if (( $# > 0 )); then
    die "$@"
  else
    exit 0
  fi
}

daemons="--ng-daemons"

while getopts "hbsdjpc" opt; do
  case ${opt} in
    h) usage ;;
    b) skip_bootstrap="true" ;;
    s) skip_distribution="true" ;;
    d) daemons="--no-ng-daemons" ;;
    j) skip_java="true" ;;
    p) skip_python="true" ;;
    c) skip_integration="true" ;;
    *) usage "Invalid option: -${OPTARG}" ;;
  esac
done

banner "CI BEGINS"

if [[ "${skip_bootstrap:-false}" == "false" ]]; then
  banner "Bootstrapping pants"
  (
    ./build-support/python/clean.sh && \
    PANTS_VERBOSE=1 PEX_VERBOSE=1 PYTHON_VERBOSE=1 ./pants;
    ./pants.pex goal goals
  ) || die "Failed to bootstrap pants."
fi

./pants.pex goal clean-all || die "Failed to clean-all."

# TODO(<NAME>): Re-plumb build such that it grabs constraints from the built python_binary
# target(s).
INTERPRETER_CONSTRAINTS=(
  "CPython>=2.6,<3"
  "CPython>=3.3"
)
for constraint in ${INTERPRETER_CONSTRAINTS[@]}; do
  INTERPRETER_CONSTRAINT_ARGS=(
    ${INTERPRETER_CONSTRAINT_ARGS[@]}
    -i "${constraint}"
  )
done

if [[ "${skip_distribution:-false}" == "false" ]]; then
  # TODO(<NAME>): Take this further and dogfood a bootstrap from the sdists generated by
  # setup_py
  banner "Running pants distribution tests"
  (
    ./pants.pex py --pex ${INTERPRETER_CONSTRAINT_ARGS[@]} \
      src/python/pants:_pants_transitional_publishable_binary_ && \
    mv dist/_pants_transitional_publishable_binary_.pex dist/self.pex && \
    ./dist/self.pex build ${INTERPRETER_CONSTRAINT_ARGS[@]} \
      src/python/pants:_pants_transitional_publishable_binary_ && \
    ./dist/self.pex setup_py --recursive src/python/pants:pants-packaged
  ) || die "Failed to create pants distributions."
fi

if [[ "${skip_java:-false}" == "false" ]]; then
  banner "Running jvm tests"
  (
    ./pants.pex goal test {src,tests}/{java,scala}:: $daemons
  ) || die "Jvm test failure."
fi

if [[ "${skip_python:-false}" == "false" ]]; then
  banner "Running python tests"
  (
    PANTS_PYTHON_TEST_FAILSOFT=1 ./pants.pex goal test tests/python/pants_test:all \
      ${INTERPRETER_CONSTRAINT_ARGS[@]}
  ) || die "Python test failure"
fi

if [[ "${skip_integration:-false}" == "false" ]]; then
  banner "Running Pants Integration tests"
  (
    PANTS_PYTHON_TEST_FAILSOFT=1 ./pants.pex goal test tests/python/pants_test:integration \
      ${INTERPRETER_CONSTRAINT_ARGS[@]}
  ) || die "Pants Integration test failure"
fi

banner "CI SUCCESS"
{'fraction_non_alphanumeric': 0.1469294920394238, 'fraction_numerical': 0.004548900682335102, 'mean_word_length': 3.2254964766175527, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, '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': '2229332', 'n_tokens_mistral': 2452, 'n_tokens_neox': 2330, 'n_words': 580}