forked from pulp/pulp_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·170 lines (147 loc) · 5.4 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·170 lines (147 loc) · 5.4 KB
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
#!/usr/bin/env bash
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_python' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template
# 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
export PULP_API_ROOT="/pulp/"
if [[ "$TEST" = "docs" || "$TEST" = "publish" ]]; then
pip install -r ../pulpcore/doc_requirements.txt
pip install -r doc_requirements.txt
fi
cd .ci/ansible/
TAG=ci_build
PULPCORE=./pulpcore
if [[ "$TEST" == "plugin-from-pypi" ]]; then
PLUGIN_NAME=pulp_python
elif [[ "${RELEASE_WORKFLOW:-false}" == "true" ]]; then
PLUGIN_NAME=./pulp_python/dist/pulp_python-$PLUGIN_VERSION-py3-none-any.whl
else
PLUGIN_NAME=./pulp_python
fi
if [[ "${RELEASE_WORKFLOW:-false}" == "true" ]]; then
# Install the plugin only and use published PyPI packages for the rest
# Quoting ${TAG} ensures Ansible casts the tag as a string.
cat >> vars/main.yaml << VARSYAML
image:
name: pulp
tag: "${TAG}"
plugins:
- name: pulpcore
source: pulpcore
- name: pulp_python
source: "${PLUGIN_NAME}"
- name: pulp-smash
source: ./pulp-smash
VARSYAML
else
cat >> vars/main.yaml << VARSYAML
image:
name: pulp
tag: "${TAG}"
plugins:
- name: pulp_python
source: "${PLUGIN_NAME}"
- name: pulpcore
source: "${PULPCORE}"
- name: pulp-smash
source: ./pulp-smash
VARSYAML
fi
cat >> vars/main.yaml << VARSYAML
services:
- name: pulp
image: "pulp:${TAG}"
volumes:
- ./settings:/etc/pulp
- ./ssh:/keys/
- ~/.config:/var/lib/pulp/.config
- ../../../pulp-openapi-generator:/root/pulp-openapi-generator
env:
PULP_WORKERS: "4"
VARSYAML
cat >> vars/main.yaml << VARSYAML
pulp_settings: {"orphan_protection_time": 0, "pypi_api_hostname": "https://pulp:443"}
pulp_scheme: https
pulp_container_tag: https
VARSYAML
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: null\
' vars/main.yaml
export PULP_API_ROOT="/rerouted/djnd/"
fi
if [ "$TEST" = "azure" ]; then
mkdir -p azurite
cd azurite
openssl req -newkey rsa:2048 -x509 -nodes -keyout azkey.pem -new -out azcert.pem -sha256 -days 365 -addext "subjectAltName=DNS:ci-azurite" -subj "/C=CO/ST=ST/L=LO/O=OR/OU=OU/CN=CN"
sudo cp azcert.pem /usr/local/share/ca-certificates/azcert.crt
sudo dpkg-reconfigure ca-certificates
cd ..
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 --cert /etc/pulp/azcert.pem --key /etc/pulp/azkey.pem"' vars/main.yaml
sed -i -e '$a azure_test: true\
pulp_scenario_settings: null\
' vars/main.yaml
fi
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
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
sudo chown -R 700:700 ~runner/.config
# Plugins often write to ~/.config/pulp/cli.toml from the host
sudo chmod 777 ~runner/.config/pulp
sudo chmod 666 ~runner/.config/pulp/cli.toml
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
if [[ "$TEST" = "azure" ]]; then
cat /usr/local/share/ca-certificates/azcert.crt | sudo tee -a "$CERTIFI" > /dev/null
fi
# Hack: adding pulp CA to default CA file
CERT=$(python -c 'import ssl; print(ssl.get_default_verify_paths().openssl_cafile)')
cat "$CERTIFI" | sudo tee -a "$CERT" > /dev/null
# Updating certs
sudo update-ca-certificates
echo ::endgroup::
if [[ "$TEST" = "azure" ]]; then
AZCERTIFI=$(/opt/az/bin/python3 -c 'import certifi; print(certifi.where())')
cat /usr/local/share/ca-certificates/azcert.crt >> $AZCERTIFI
cat /usr/local/share/ca-certificates/azcert.crt | cmd_stdin_prefix tee -a /usr/local/lib/python3.8/site-packages/certifi/cacert.pem > /dev/null
cat /usr/local/share/ca-certificates/azcert.crt | cmd_stdin_prefix tee -a /etc/pki/tls/cert.pem > /dev/null
AZURE_STORAGE_CONNECTION_STRING='DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://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 && pip3 install pipdeptree && pipdeptree"
echo ::endgroup::