-
Notifications
You must be signed in to change notification settings - Fork 34
/
script.sh.j2
executable file
·131 lines (107 loc) · 3.82 KB
/
script.sh.j2
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
# coding=utf-8
{% include 'header.j2' %}
set -mveuo pipefail
export POST_SCRIPT=$TRAVIS_BUILD_DIR/.travis/post_script.sh
export POST_DOCS_TEST=$TRAVIS_BUILD_DIR/.travis/post_docs_test.sh
export FUNC_TEST_SCRIPT=$TRAVIS_BUILD_DIR/.travis/func_test_script.sh
# Needed for both starting the service and building the docs.
# Gets set in .travis/settings.yml, but doesn't seem to inherited by
# this script.
export DJANGO_SETTINGS_MODULE=pulpcore.app.settings
if [ "$TEST" = 'docs' ]; then
cd docs
make html
cd ..
if [ -f $POST_DOCS_TEST ]; then
$POST_DOCS_TEST
fi
exit
fi
if [ "$TEST" = 'bindings' ]; then
COMMIT_MSG=$(git log --format=%B --no-merges -1)
export PULP_BINDINGS_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulp-openapi-generator\/pull\/(\d+)' | awk -F'/' '{print $7}')
cd ..
git clone https://github.com/pulp/pulp-openapi-generator.git
cd pulp-openapi-generator
if [ -n "$PULP_BINDINGS_PR_NUMBER" ]; then
git fetch origin +refs/pull/$PULP_BINDINGS_PR_NUMBER/merge
git checkout FETCH_HEAD
fi
./generate.sh pulpcore python
pip install ./pulpcore-client
{% if plugin_name == 'pulpcore' %} ./generate.sh pulp_file python
pip install ./pulp_file-client{% else %} ./generate.sh {{ plugin_snake }} python
pip install ./{{ plugin_snake }}-client
{% endif %}
python $TRAVIS_BUILD_DIR/.travis/test_bindings.py
if [ ! -f $TRAVIS_BUILD_DIR/.travis/test_bindings.rb ]
then
exit
fi
rm -rf ./pulpcore-client
./generate.sh pulpcore ruby
cd pulpcore-client
gem build pulpcore_client
gem install --both ./pulpcore_client-0.gem
cd ..
{% if plugin_name == 'pulpcore' %} rm -rf ./pulp_file-client
./generate.sh pulp_file ruby
cd pulp_file-client
gem build pulp_file_client
gem install --both ./pulp_file_client-0.gem
cd ..
{% else %} rm -rf ./{{ plugin_snake }}-client
./generate.sh {{ plugin_snake }} ruby
cd {{ plugin_snake }}-client
gem build {{ plugin_snake }}_client
gem install --both ./{{ plugin_snake }}_client-0.gem
cd ..
{% endif %}
ruby $TRAVIS_BUILD_DIR/.travis/test_bindings.rb
exit
fi
# Aliases for running commands in the pulp-api container.
export PULP_API_POD=$(sudo kubectl get pods | grep -E -o "pulp-api-(\w+)-(\w+)")
# Run a command
export CMD_PREFIX="sudo kubectl exec $PULP_API_POD --"
# Run a command, and pass STDIN
export CMD_STDIN_PREFIX="sudo kubectl exec -i $PULP_API_POD --"
# The alias does not seem to work in Travis / the scripting framework
#alias pytest="$CMD_PREFIX pytest"
# Run unit tests.
$CMD_PREFIX bash -c "PULP_DATABASES__default__USER=postgres django-admin test --noinput /usr/local/lib/python${TRAVIS_PYTHON_VERSION}/site-packages/{{ plugin_snake }}/tests/unit/"
# Note: This function is in the process of being merged into after_failure
show_logs_and_return_non_zero() {
readonly local rc="$?"
{%- if plugin_name == 'pulp_rpm' %}
echo "container yum/dnf repos":
echo -en "travis_fold:start:$containerlog"'\\r'
$CMD_PREFIX bash -c "ls -latr /etc/yum.repos.d/"
$CMD_PREFIX bash -c "cat /etc/yum.repos.d/*"
echo -en "travis_fold:end:$containerlog"'\\r'
{%- endif %}
return "${rc}"
}
export -f show_logs_and_return_non_zero
# Run functional tests
set +u
{% if plugin_name == 'pulpcore' %}
export PYTHONPATH=$TRAVIS_BUILD_DIR:${PYTHONPATH}
{% else %}
export PYTHONPATH=$TRAVIS_BUILD_DIR:$TRAVIS_BUILD_DIR/../pulpcore:${PYTHONPATH}
{% endif %}
set -u
if [[ "$TEST" == "performance" ]]; then
echo "--- Performance Tests ---"
pytest -vv -r sx --color=yes --pyargs --durations=0 {{ plugin_snake }}.tests.performance || show_logs_and_return_non_zero
exit
fi
if [ -f $FUNC_TEST_SCRIPT ]; then
$FUNC_TEST_SCRIPT
else
pytest -v -r sx --color=yes --pyargs {{ plugin_snake }}.tests.functional || show_logs_and_return_non_zero
fi
if [ -f $POST_SCRIPT ]; then
$POST_SCRIPT
fi