forked from inveniosoftware/cookiecutter-invenio-rdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.sh
executable file
·70 lines (55 loc) · 1.77 KB
/
run-tests.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
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
#
# Copyright (C) 2019 CERN.
# Copyright (C) 2019 Northwestern University.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
# quit on errors:
set -o errexit
# quit on unbound symbols:
set -o nounset
WORKDIR=$(mktemp -d)
TESTDIR=$(pwd)
finish() {
echo "Cleaning up."
docker-compose -f ${PROJECTDIR}/docker-compose.full.yml down --volumes --remove-orphans &
pipenv --rm || true
rm -rf "${WORKDIR}"
echo "Test setup cleaned."
}
trap finish EXIT
PROJECT_NAME="my-site"
export PROJECT_NAME
cookiecutter --no-input -o "$WORKDIR" . \
project_name=${PROJECT_NAME} \
database=${COOKIECUTTER_DATABASE:-postgresql} \
elasticsearch=${COOKIECUTTER_ELASTICSEARCH:-elasticsearch6} \
file_storage=${COOKIECUTTER_FILE_STORAGE:-local}
PROJECTDIR=${WORKDIR}/${PROJECT_NAME}
export PROJECTDIR
# Check local installation (this also generates the Pipfile.lock)
${TESTDIR}/scripts/bootstrap
cd ${PROJECTDIR}
# Initialize git in the repository for 'check-manifest' to work
git init
git add -A
# Update MANIFEST.in
pipenv run check-manifest -u || true
# Build application docker images
${TESTDIR}/scripts/build-images.sh
# Fire up a full instance via docker-compose.full.yml
# We will use the services (DB, ES, etc) for running the tests locally
docker-compose -f docker-compose.full.yml up -d
${TESTDIR}/scripts/wait-for-services.sh --full
echo "All services are up."
docker-compose -f docker-compose.full.yml down
echo "Services successfully stopped"
# Fire up the services we need for testing
docker-compose up -d
${TESTDIR}/scripts/wait-for-services.sh
# Run the instance tests
# REQUIREMENTS=prod ./run-tests.sh