forked from Lullabot/drupal9ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-circleci.sh
executable file
·75 lines (64 loc) · 2.48 KB
/
setup-circleci.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
#######################################
# Installation script to do the heavy lifting.
#
# We put this inside of a function to avoid any issues that might arise by
# piping this script to bash. Ideally you should avoid piping scripts to bash.
# If you'd like to install without this script, here's where to look:
#######################################
drupal8ci_install() {
check_dependencies
# Create a temporary directory for installation.
tmpdir=`mktemp -d`
# Now that we've created a temp dir, clean up after ourselves on exit.
trap "cleanup $tmpdir" EXIT
# Turn on xtracing and error detection so users know what's happening.
set -ex
# Download and extract CircleCI configuration and sample tests.
wget -O "$tmpdir/master.zip" https://github.com/Lullabot/drupal8ci/archive/master.zip
unzip "$tmpdir/master.zip" 'drupal8ci-master/dist/circleci/*' -d "$tmpdir"
rsync -va --ignore-existing "$tmpdir/drupal8ci-master/dist/circleci/" .
unzip "$tmpdir/master.zip" 'drupal8ci-master/dist/common/*' -d "$tmpdir"
rsync -va --ignore-existing "$tmpdir/drupal8ci-master/dist/common/" .
# Add development dependencies to run the CircleCI jobs.
#
# behat/mink-extension is pinned until https://github.com/Behat/MinkExtension/pull/311 gets fixed.
composer require --dev \
behat/mink-extension:v2.2 \
behat/mink-selenium2-driver:^1.3 \
bex/behat-screenshot \
drupal/coder:^8.2 \
drupal/drupal-extension:^4.0
}
#######################################
# Helper function to output a string to stderr and exit.
#######################################
echoerr() {
echo "$@" 1>&2;
exit 23
}
#######################################
# Ensure we have a proper environment for installation.
#######################################
check_dependencies() {
hash composer ||
echoerr "You must have composer for this install script to work."
# Ensure this is a Composer managed Drupal project.
composer config repositories | grep packages.drupal.org > /dev/null 2>&1 ||
echoerr "This does not appear to be a Composer managed Drupal project."
# Verify certain packages exist.
hash wget ||
echoerr "You must have wget for this install script to work."
hash unzip ||
echoerr "You must have unzip for this install script to work."
}
#######################################
# Helper function to use with trap to clean up after exit.
# Arguments:
# * param1: The temporary directory to delete.
#######################################
cleanup() {
echo "Removing $1."
rm -r $1
}
drupal8ci_install