# Python CircleCI 2.0 configuration file version: 2 variables: restore_repo_cache: &restore_repo_cache restore_cache: keys: - v1-repo-{{ .Environment.CIRCLE_SHA1 }} install_tox: &install_tox run: pip install tox set_workdir: &set_workdir working_directory: ~/repo requires_get_code: &requires_get_code requires: - get_code jobs: get_code: docker: - image: cimg/python:3.10 <<: *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 AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk= ' >> ~/.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 validate_test_tools: docker: - image: cimg/python:3.10 <<: *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 workflows: version: 2 get_code_and_test: jobs: - get_code - validate_test_tools: <<: *requires_get_code