forked from Lullabot/drupal9ci
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-gitlab-ci.sh
executable file
·73 lines (62 loc) · 2.38 KB
/
setup-gitlab-ci.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
#!/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 GitLab CI configuration and sample tests.
wget -O "$tmpdir/master.zip" https://github.com/lullabot/drupal8ci/archive/master.zip
unzip "$tmpdir/master.zip" 'drupal8ci-master/dist/gitlabci/*' -d "$tmpdir"
rsync -va --ignore-existing "$tmpdir/drupal8ci-master/dist/gitlabci/" .
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 GitLab CI jobs.
composer require --dev \
dmore/chrome-mink-driver:^2.7 \
weitzman/drupal-test-traits:^1.2 \
drupal/coder:^8.2 \
consolidation/robo:^1.4 \
drush/drush
}
#######################################
# 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