Unverified Commit 76643a25 authored by Dannon's avatar Dannon Committed by GitHub
Browse files

Merge pull request #7583 from martenson/backportcci

[18.05] backport circleci testing
parents 0ab05b3c a9d21198
Loading
Loading
Loading
Loading

.circleci/config.yml

0 → 100644
+201 −0
Original line number Diff line number Diff line
# Python CircleCI 2.0 configuration file
version: 2
variables:
  restore_repo_cache: &restore_repo_cache
    restore_cache:
      keys:
        - v1-repo-{{ .Environment.CIRCLE_SHA1 }}
  restore_yarn_cache: &restore_yarn_cache
    restore_cache:
      keys:
        - v1-repo-{{ .Environment.CIRCLE_SHA1 }}
        - yarn-packages-{{ checksum "client/yarn.lock" }}
  save_yarn_cache: &save_yarn_cache
    save_cache:
      key: yarn-packages-{{ checksum "client/yarn.lock" }}
      paths:
        - ~/.cache/yarn
  install_tox: &install_tox
    run: sudo pip install tox
  set_workdir: &set_workdir
    working_directory: ~/repo
  requires_get_code: &requires_get_code
    requires:
      - get_code
jobs:
  get_code:
    docker:
      - image: circleci/python:2.7.15
    <<: *set_workdir
    steps:
      # Replace standard code checkout with shallow clone to speed things up.
      - run:
          name: Checkout code
          command: |-
              # Add github.com to known hosts
              mkdir -p ~/.ssh
              echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
              ' >> ~/.ssh/known_hosts

              # Add the user ssh key and set correct perms
              (umask 077; touch ~/.ssh/id_rsa)
              chmod 0600 ~/.ssh/id_rsa
              echo "$CHECKOUT_KEY" > ~/.ssh/id_rsa

              # Use git+ssh instead of https
              git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
              git config --global gc.auto 0 || true

              # Shallow clone
              git clone --depth=1 "${CIRCLE_REPOSITORY_URL}" .

              if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
                  # Update PR refs for testing.
                  FETCH_REFS="${FETCH_REFS} +refs/pull/${CIRCLE_PR_NUMBER}/head:pr/${CIRCLE_PR_NUMBER}/head"
                  FETCH_REFS="${FETCH_REFS} +refs/pull/${CIRCLE_PR_NUMBER}/merge:pr/${CIRCLE_PR_NUMBER}/merge"

                  # Retrieve the refs
                  git fetch --force origin ${FETCH_REFS}

                  # Checkout PR merge ref.
                  git checkout -f "pr/${CIRCLE_PR_NUMBER}/merge"

                  # Test for *some* merge conflicts.
                  git branch --merged | grep "pr/${CIRCLE_PR_NUMBER}/head" > /dev/null
              else
                  if [ -n "$CIRCLE_TAG" ]; then
                      git fetch --depth=1 --force origin "refs/tags/${CIRCLE_TAG}"
                  else
                      git fetch --depth=1 --force origin "$CIRCLE_BRANCH:remotes/origin/$CIRCLE_BRANCH"
                  fi
                  if [ -n "$CIRCLE_TAG" ]; then
                      git reset --hard "$CIRCLE_SHA1"
                      git checkout "$CIRCLE_TAG"
                  elif [ -n "$CIRCLE_BRANCH" ]; then
                      git reset --hard "$CIRCLE_SHA1"
                      git checkout -B "$CIRCLE_BRANCH"
                  fi
                  git reset --hard "${CIRCLE_SHA1}"
              fi
      - save_cache:
          key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
          paths:
            - ~/repo
  py27_lint:
    docker:
      - image: circleci/python:2.7.15
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - *install_tox
      - run: tox -e py27-lint
  py27_unit:
    docker:
      - image: circleci/python:2.7.15
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - *install_tox
      - run: tox -e py27-unit
  py27_docstring:
    docker:
      - image: circleci/python:2.7.15
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - *install_tox
      - run: tox -e py27-lint_docstring_include_list
  py27_first_startup:
    docker:
      - image: circleci/python:2.7.15
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - run: sh scripts/common_startup.sh
      - run: wget -q https://github.com/jmchilton/galaxy-downloads/raw/master/db_gx_rev_0127.sqlite
      - run: mv db_gx_rev_0127.sqlite database/universe.sqlite
      - run: sh manage_db.sh -c ./config/galaxy.yml.sample upgrade
      - *install_tox
      - run: tox -e py27-first_startup
  py35_lint:
    docker:
      - image: circleci/python:3.5
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - *install_tox
      - run: tox -e py35-lint
  py35_unit:
    docker:
      - image: circleci/python:3.5
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - *install_tox
      - run: tox -e py35-unit
  py35_first_startup:
    docker:
      - image: circleci/python:3.5
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - *install_tox
      - run: sudo apt-get update
      # For uwsgi
      - run: sudo apt-get install -y libpython3.5-dev
      - run: tox -e py35-first_startup
  validate_test_tools:
    docker:
      - image: circleci/python:2.7.15
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - run: sudo apt-get update
      - run: sudo apt-get install -y libxml2-utils
      - *install_tox
      - run: tox -e validate_test_tools
  check_py3_compatibility:
    docker:
      - image: circleci/python:2.7.15
    <<: *set_workdir
    steps:
      - *restore_repo_cache
      - run: sudo apt-get update
      - run: sudo apt-get install -y ack-grep
      - *install_tox
      - run: tox -e check_py3_compatibility
  js_unit:
    docker:
      - image: circleci/node:9-browsers
    <<: *set_workdir
    steps:
      - *restore_yarn_cache
      - run: cd client && yarn install --frozen-lockfile
      - *save_yarn_cache
      - run: cd client && yarn run build
      - run: cd client && yarn run test
workflows:
  version: 2
  get_code_and_test:
    jobs:
      - get_code
      - py27_lint:
          <<: *requires_get_code
      - py27_unit:
          <<: *requires_get_code
      - py27_first_startup:
          <<: *requires_get_code
      - py27_docstring:
          <<: *requires_get_code
      - py35_lint:
          <<: *requires_get_code
      - py35_unit:
          <<: *requires_get_code
      - py35_first_startup:
          <<: *requires_get_code
      - validate_test_tools:
          <<: *requires_get_code
      - check_py3_compatibility:
          <<: *requires_get_code
      - js_unit:
          <<: *requires_get_code