-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathinstall.sh.j2
executable file
·225 lines (190 loc) · 6.85 KB
/
install.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/usr/bin/env bash
{% include 'header.j2' %}
# make sure this script runs at the repo root
cd "$(dirname "$(realpath -e "$0")")"/../../..
REPO_ROOT="$PWD"
set -euv
source .github/workflows/scripts/utils.sh
PLUGIN_VERSION="$(bump-my-version show current_version | tail -n -1 | python -c 'from packaging.version import Version; print(Version(input()))')"
PLUGIN_SOURCE="./{{ plugin_name }}/dist/{{ plugin_name | snake }}-${PLUGIN_VERSION}-py3-none-any.whl"
export PULP_API_ROOT="{{ api_root }}"
PIP_REQUIREMENTS=("{{ cli_package }}")
# This must be the **only** call to "pip install" on the test runner.
pip install ${PIP_REQUIREMENTS[*]}
{% if test_cli -%}
# Check out the {{ cli_package }} branch matching the installed version.
PULP_CLI_VERSION="$(pip freeze | sed -n -e 's/{{ cli_package }}==//p')"
git clone --depth 1 --branch "$PULP_CLI_VERSION" {{ cli_repo }} ../{{ cli_package }}
{%- endif %}
cd .ci/ansible/
{%- set PULPCORE_PREFIX = "" if plugin_name == "pulpcore" else " pulpcore" %}
{%- if test_s3 %}
if [ "$TEST" = "s3" ]; then
PLUGIN_SOURCE="${PLUGIN_SOURCE}{{ PULPCORE_PREFIX }}[s3]"
fi
{%- endif %}
{%- if test_azure %}
if [ "$TEST" = "azure" ]; then
PLUGIN_SOURCE="${PLUGIN_SOURCE}{{ PULPCORE_PREFIX }}[azure]"
fi
{%- endif %}
{%- if test_gcp %}
if [ "$TEST" = "gcp" ]; then
PLUGIN_SOURCE="${PLUGIN_SOURCE}{{ PULPCORE_PREFIX }}[google]"
fi
{%- endif %}
cat >> vars/main.yaml << VARSYAML
image:
name: pulp
tag: "ci_build"
plugins:
- name: {{ plugin_name }}
source: "${PLUGIN_SOURCE}"
VARSYAML
if [[ -f ../../ci_requirements.txt ]]; then
cat >> vars/main.yaml << VARSYAML
ci_requirements: true
VARSYAML
fi
if [ "$TEST" = "pulp" ]; then
cat >> vars/main.yaml << VARSYAML
upperbounds: true
VARSYAML
fi
{%- if test_lowerbounds %}
if [ "$TEST" = "lowerbounds" ]; then
cat >> vars/main.yaml << VARSYAML
lowerbounds: true
VARSYAML
fi
{%- endif %}
cat >> vars/main.yaml << VARSYAML
services:
- name: pulp
image: "pulp:ci_build"
volumes:
- ./settings:/etc/pulp
- ./ssh:/keys/
- ~/.config:/var/lib/pulp/.config
- ../../../pulp-openapi-generator:/root/pulp-openapi-generator
env:
PULP_WORKERS: "4"
PULP_HTTPS: "{{ 'true' if pulp_scheme == 'https' else 'false' }}"
VARSYAML
cat >> vars/main.yaml << VARSYAML
pulp_env: {{ pulp_env | tojson }}
pulp_settings: {{ pulp_settings | tojson }}
pulp_scheme: {{ pulp_scheme }}
{%- if ci_base_image.count(":") %}
pulp_default_container: {{ ci_base_image }}
{% else %}
pulp_default_container: {{ ci_base_image + ":latest" }}
{% endif -%}
VARSYAML
{%- if docker_fixtures %}
SCENARIOS=("pulp" "performance" "azure" "gcp" "s3" "generate-bindings" "lowerbounds")
if [[ " ${SCENARIOS[*]} " =~ " ${TEST} " ]]; then
sed -i -e '/^services:/a \
- name: pulp-fixtures\
image: docker.io/pulp/pulp-fixtures:latest\
env: {BASE_URL: "http://pulp-fixtures:8080"}' vars/main.yaml
export REMOTE_FIXTURES_ORIGIN="http://pulp-fixtures:8080"
fi
{%- endif %}
{%- if test_s3 %}
if [ "$TEST" = "s3" ]; then
export MINIO_ACCESS_KEY=AKIAIT2Z5TDYPX3ARJBA
export MINIO_SECRET_KEY=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
sed -i -e '/^services:/a \
- name: minio\
image: minio/minio\
env:\
MINIO_ACCESS_KEY: "'$MINIO_ACCESS_KEY'"\
MINIO_SECRET_KEY: "'$MINIO_SECRET_KEY'"\
command: "server /data"' vars/main.yaml
sed -i -e '$a s3_test: true\
minio_access_key: "'$MINIO_ACCESS_KEY'"\
minio_secret_key: "'$MINIO_SECRET_KEY'"\
pulp_scenario_settings: {{ pulp_settings_s3 | tojson }}\
pulp_scenario_env: {{ pulp_env_s3 | tojson }}\
' vars/main.yaml
{%- if test_reroute %}
export PULP_API_ROOT="/rerouted/djnd/"
{%- endif %}
fi
{%- endif %}
{%- if test_azure %}
if [ "$TEST" = "azure" ]; then
sed -i -e '/^services:/a \
- name: ci-azurite\
image: mcr.microsoft.com/azure-storage/azurite\
volumes:\
- ./azurite:/etc/pulp\
command: "azurite-blob --blobHost 0.0.0.0"' vars/main.yaml
sed -i -e '$a azure_test: true\
pulp_scenario_settings: {{ pulp_settings_azure | tojson }}\
pulp_scenario_env: {{ pulp_env_azure | tojson }}\
' vars/main.yaml
fi
{%- endif %}
{%- if test_gcp %}
if [ "$TEST" = "gcp" ]; then
mkdir -p cigcp
cd cigcp
openssl req -newkey rsa:2048 -x509 -nodes -keyout gcpkey.pem -new -out gcpcert.pem -sha256 -days 365 -addext "subjectAltName=DNS:ci-gcp" -subj "/C=CO/ST=ST/L=LO/O=OR/OU=OU/CN=CN"
sudo cp gcpcert.pem /usr/local/share/ca-certificates/gcpcert.crt
sudo dpkg-reconfigure ca-certificates
cd ..
sed -i -e '/^services:/a \
- name: ci-gcp\
image: fsouza/fake-gcs-server\
volumes:\
- storage_data:/etc/pulp\
command: "{% if pulp_scheme == "https" %} -cert-location /etc/pulp/gcpcert.pem {% else %} -scheme http{% endif %}"' vars/main.yaml
sed -i -e '$a gcp_test: true\
pulp_scenario_settings: {{ pulp_settings_gcp | tojson }}\
pulp_scenario_env: {{ pulp_env_gcp | tojson }}\
' vars/main.yaml
fi
{%- endif %}
echo "PULP_API_ROOT=${PULP_API_ROOT}" >> "$GITHUB_ENV"
if [ "${PULP_API_ROOT:-}" ]; then
sed -i -e '$a api_root: "'"$PULP_API_ROOT"'"' vars/main.yaml
fi
pulp config create --base-url {{ pulp_scheme }}://pulp{% if pulp_scheme != 'https' %} --no-verify-ssl{% endif %} --api-root "$PULP_API_ROOT" --username "admin" --password "password"
{% if test_cli -%}
cp ~/.config/pulp/cli.toml "${REPO_ROOT}/../{{ cli_package }}/tests/cli.toml"
{%- endif %}
ansible-playbook build_container.yaml
ansible-playbook start_container.yaml
# .config needs to be accessible by the pulp user in the container, but some
# files will likely be modified on the host by post/pre scripts.
chmod 777 ~/.config/pulp_smash/
chmod 666 ~/.config/pulp_smash/settings.json
{% if test_cli -%}
# Plugins often write to ~/.config/pulp/cli.toml from the host
chmod 777 ~/.config/pulp
chmod 666 ~/.config/pulp/cli.toml
{%- endif %}
sudo chown -R 700:700 ~/.config
{%- if pulp_scheme == "https" %}
echo ::group::SSL
# Copy pulp CA
sudo docker cp pulp:/etc/pulp/certs/pulp_webserver.crt /usr/local/share/ca-certificates/pulp_webserver.crt
# Hack: adding pulp CA to certifi.where()
CERTIFI=$(python -c 'import certifi; print(certifi.where())')
cat /usr/local/share/ca-certificates/pulp_webserver.crt | sudo tee -a "$CERTIFI" > /dev/null
# Hack: adding pulp CA to default CA file
CERT=$(python -c 'import ssl; print(ssl.get_default_verify_paths().openssl_cafile)')
cat /usr/local/share/ca-certificates/pulp_webserver.crt | sudo tee -a "$CERT" > /dev/null
# Updating certs
sudo update-ca-certificates
echo ::endgroup::
{%- endif %}
if [[ "$TEST" = "azure" ]]; then
AZURE_STORAGE_CONNECTION_STRING='DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;'
az storage container create --name pulp-test --connection-string $AZURE_STORAGE_CONNECTION_STRING
fi
echo ::group::PIP_LIST
cmd_prefix bash -c "pip3 list"
echo ::endgroup::