Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run circleCI on merge rather than head of PR's fork #7539

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,45 @@ jobs:
- run:
name: Checkout code
command: |-
# add github.com to known hosts
# 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
# 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
# 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_TAG" ]
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 -qf "pr/${CIRCLE_PR_NUMBER}/merge"

# Test for *some* merge conflicts.
git branch --merged | grep "pr/${CIRCLE_PR_NUMBER}/head" > /dev/null
elif [ -n "$CIRCLE_TAG" ]
then
git fetch --depth=10 --force origin "refs/tags/${CIRCLE_TAG}"
git fetch --depth=1 --force origin "refs/tags/${CIRCLE_TAG}"
elif [[ "$CIRCLE_BRANCH" =~ ^pull\/* ]]
then
# For PR from Fork
git fetch --depth=10 --force origin "$CIRCLE_BRANCH/head:remotes/origin/$CIRCLE_BRANCH"
git fetch --depth=1 --force origin "$CIRCLE_BRANCH/head:remotes/origin/$CIRCLE_BRANCH"
else
git fetch --depth=10 --force origin "$CIRCLE_BRANCH:remotes/origin/$CIRCLE_BRANCH"
git fetch --depth=1 --force origin "$CIRCLE_BRANCH:remotes/origin/$CIRCLE_BRANCH"
fi

if [ -n "$CIRCLE_TAG" ]
Expand Down