From 8815766abf57e21498c7e8422c7dece38f503ec9 Mon Sep 17 00:00:00 2001 From: Jason Carver Date: Tue, 15 May 2018 11:52:40 -0700 Subject: [PATCH] circleci: merge (and reattempt) PR before testing --- .circleci/config.yml | 12 ++++++++++++ .circleci/merge_pr.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 .circleci/merge_pr.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 7c636af..af93963 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,6 +6,17 @@ common: &common working_directory: ~/repo steps: - checkout + - run: + name: merge pull request base + command: ./.circleci/merge_pr.sh + - run: + name: merge pull request base (2nd try) + command: ./.circleci/merge_pr.sh + when: on_fail + - run: + name: merge pull request base (3nd try) + command: ./.circleci/merge_pr.sh + when: on_fail - run: name: merge pull request base command: | @@ -33,6 +44,7 @@ common: &common command: ~/.local/bin/tox -r - save_cache: paths: + - .hypothesis - .tox - ~/.cache/pip - ~/.local diff --git a/.circleci/merge_pr.sh b/.circleci/merge_pr.sh new file mode 100644 index 0000000..91eb47c --- /dev/null +++ b/.circleci/merge_pr.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then + PR_INFO_URL=https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER + PR_BASE_BRANCH=$(curl -L "$PR_INFO_URL" | python -c 'import json, sys; obj = json.load(sys.stdin); sys.stdout.write(obj["base"]["ref"])') + git fetch origin +"$PR_BASE_BRANCH":circleci/pr-base + # We need these config values or git complains when creating the + # merge commit + git config --global user.name "Circle CI" + git config --global user.email "circleci@example.com" + git merge --no-edit circleci/pr-base +fi