Skip to content

Mitigate #2387: Improve cloning logic #3850

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

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
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
17 changes: 9 additions & 8 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# We override the default clone step to workaround a bug with GitHub (see #3415)
clone:
git:
image: plugins/git
# We clone submodules ourselves
recursive: false

pipeline:
# We add a custom clone step to workaround a bug with GitHub (see #3415)
# and speed up cloning submodules
clone:
image: plugins/git
commands:
- sleep 5s
- git init
- git remote add origin $DRONE_REMOTE_URL
- git fetch --no-tags origin $DRONE_COMMIT_REF
- if [ $DRONE_BUILD_EVENT = "push" ]; then git reset --hard -q $DRONE_COMMIT_SHA; else git checkout -qf FETCH_HEAD; fi
- git submodule update --init --recursive
- ./project/scripts/ci-clone

pipeline:
# TESTS:
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
test_legacy:
Expand Down
12 changes: 12 additions & 0 deletions project/scripts/ci-clone
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env sh
set -eux

# if build is PR rebase on top of target branch
if [ "$DRONE_BUILD_EVENT" = "pull_request" ]; then
git config user.email "allan.renucci@gmail.com"
git config user.name "Allan Renucci"
git pull --rebase "$DRONE_REMOTE_URL" "$DRONE_BRANCH"
fi

# clone submodules in parallel
git submodule update --init --recursive --jobs 3