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
·160 lines (135 loc) · 6.18 KB
/
install.sh
File metadata and controls
executable file
·160 lines (135 loc) · 6.18 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
#!/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
PLUGIN_VERSION="$(bump-my-version show current_version | tail -n -1 | python -c 'from packaging.version import Version; print(Version(input()))')"
PLUGIN_SOURCE="./pulp_python/dist/pulp_python-${PLUGIN_VERSION}-py3-none-any.whl"
export PULP_API_ROOT="/pulp/"
PIP_REQUIREMENTS=("pulp-cli")
# This must be the **only** call to "pip install" on the test runner.
pip install ${PIP_REQUIREMENTS[*]}
# Check out the pulp-cli branch matching the installed version.
PULP_CLI_VERSION="$(pip freeze | sed -n -e 's/pulp-cli==//p')"
git clone --depth 1 --branch "$PULP_CLI_VERSION" https://github.com/pulp/pulp-cli.git ../pulp-cli
cd .ci/ansible/
if [ "$TEST" = "s3" ]; then
PLUGIN_SOURCE="${PLUGIN_SOURCE} pulpcore[s3]"
fi
if [ "$TEST" = "azure" ]; then
PLUGIN_SOURCE="${PLUGIN_SOURCE} pulpcore[azure]"
fi
cat >> vars/main.yaml << VARSYAML
image:
name: pulp
tag: "ci_build"
plugins:
- name: pulp_python
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" ]; then
cat >> vars/main.yaml << VARSYAML
lowerbounds: true
VARSYAML
fi
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"
VARSYAML
cat >> vars/main.yaml << VARSYAML
pulp_env: {}
pulp_settings: {"allowed_export_paths": "/tmp", "allowed_import_paths": "/tmp", "orphan_protection_time": 0, "pypi_api_hostname": "https://pulp:443"}
pulp_scheme: https
pulp_default_container: ghcr.io/pulp/pulp-ci-centos9:latest
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: {"MEDIA_ROOT": "", "STORAGES": {"default": {"BACKEND": "storages.backends.s3boto3.S3Boto3Storage", "OPTIONS": {"access_key": "AKIAIT2Z5TDYPX3ARJBA", "addressing_style": "path", "bucket_name": "pulp3", "default_acl": "@none", "endpoint_url": "http://minio:9000", "region_name": "eu-central-1", "secret_key": "fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS", "signature_version": "s3v4"}}, "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}}, "domain_enabled": true}\
pulp_scenario_env: {}\
' vars/main.yaml
export PULP_API_ROOT="/rerouted/djnd/"
fi
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 --skipApiVersionCheck --blobHost 0.0.0.0"' vars/main.yaml
sed -i -e '$a azure_test: true\
pulp_scenario_settings: {"MEDIA_ROOT": "", "STORAGES": {"default": {"BACKEND": "storages.backends.azure_storage.AzureStorage", "OPTIONS": {"account_key": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==", "account_name": "devstoreaccount1", "azure_container": "pulp-test", "connection_string": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://ci-azurite:10000/devstoreaccount1;", "expiration_secs": 120, "location": "pulp3", "overwrite_files": true}}, "staticfiles": {"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage"}}, "content_origin": null}\
pulp_scenario_env: {}\
' 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
pulp config create --base-url https://pulp --api-root "$PULP_API_ROOT" --username "admin" --password "password"
cp ~/.config/pulp/cli.toml "${REPO_ROOT}/../pulp-cli/tests/cli.toml"
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
# Plugins often write to ~/.config/pulp/cli.toml from the host
chmod 777 ~/.config/pulp
chmod 666 ~/.config/pulp/cli.toml
sudo chown -R 700:700 ~/.config
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::
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::