|
7 | 7 | # |
8 | 8 | # For more info visit https://github.com/pulp/plugin_template |
9 | 9 |
|
| 10 | +# This script prepares the scenario definition in the .ci/ansible/vars/main.yaml file. |
| 11 | +# |
| 12 | +# It requires the following environment: |
| 13 | +# TEST - The name of the scenario to prepare. |
| 14 | +# |
| 15 | +# It may also dump the {lower,upper}bounds_constraints.txt for the specific scenario. |
| 16 | + |
| 17 | +set -eu -o pipefail |
| 18 | + |
10 | 19 | # make sure this script runs at the repo root |
11 | 20 | cd "$(dirname "$(realpath -e "$0")")"/../../.. |
12 | 21 |
|
13 | | -set -mveuo pipefail |
| 22 | +if [ -f .github/workflows/scripts/pre_before_install.sh ]; then |
| 23 | + source .github/workflows/scripts/pre_before_install.sh |
| 24 | +fi |
14 | 25 |
|
15 | | -if [ "${GITHUB_REF##refs/heads/}" = "${GITHUB_REF}" ] |
16 | | -then |
17 | | - BRANCH_BUILD=0 |
18 | | -else |
19 | | - BRANCH_BUILD=1 |
20 | | - BRANCH="${GITHUB_REF##refs/heads/}" |
| 26 | +COMPONENT_VERSION="$(bump-my-version show current_version | tail -n -1 | python -c 'from packaging.version import Version; print(Version(input()))')" |
| 27 | +COMPONENT_SOURCE="./pulpcore/dist/pulpcore-${COMPONENT_VERSION}-py3-none-any.whl" |
| 28 | +if [ "$TEST" = "s3" ]; then |
| 29 | + COMPONENT_SOURCE="${COMPONENT_SOURCE}[s3]" |
21 | 30 | fi |
22 | | -if [ "${GITHUB_REF##refs/tags/}" = "${GITHUB_REF}" ] |
23 | | -then |
24 | | - TAG_BUILD=0 |
25 | | -else |
26 | | - TAG_BUILD=1 |
27 | | - BRANCH="${GITHUB_REF##refs/tags/}" |
| 31 | +if [ "$TEST" = "azure" ]; then |
| 32 | + COMPONENT_SOURCE="${COMPONENT_SOURCE}[azure]" |
28 | 33 | fi |
29 | 34 |
|
30 | | -COMMIT_MSG=$(git log --format=%B --no-merges -1) |
31 | | -export COMMIT_MSG |
| 35 | +if [[ "$TEST" = "pulp" ]]; then |
| 36 | + python3 .ci/scripts/calc_constraints.py -u requirements.txt > upperbounds_constraints.txt |
| 37 | +fi |
| 38 | +if [[ "$TEST" = "lowerbounds" ]]; then |
| 39 | + python3 .ci/scripts/calc_constraints.py requirements.txt > lowerbounds_constraints.txt |
| 40 | +fi |
| 41 | +export PULP_API_ROOT=$(test "${TEST}" = "s3" && echo "/rerouted/djnd/" || echo "/pulp/") |
32 | 42 |
|
33 | | -COMPONENT_VERSION=$(sed -ne "s/\s*version.*=.*['\"]\(.*\)['\"][\s,]*/\1/p" setup.py) |
| 43 | +echo "PULP_API_ROOT=${PULP_API_ROOT}" >> "$GITHUB_ENV" |
34 | 44 |
|
35 | | -mkdir .ci/ansible/vars || true |
36 | | -echo "---" > .ci/ansible/vars/main.yaml |
37 | | -echo "legacy_component_name: pulpcore" >> .ci/ansible/vars/main.yaml |
38 | | -echo "component_name: core" >> .ci/ansible/vars/main.yaml |
39 | | -echo "component_version: '${COMPONENT_VERSION}'" >> .ci/ansible/vars/main.yaml |
| 45 | +# Compose the scenario definition. |
| 46 | +mkdir -p .ci/ansible/vars |
40 | 47 |
|
41 | | -export PRE_BEFORE_INSTALL=$PWD/.github/workflows/scripts/pre_before_install.sh |
42 | | -export POST_BEFORE_INSTALL=$PWD/.github/workflows/scripts/post_before_install.sh |
| 48 | +cat > .ci/ansible/vars/main.yaml << VARSYAML |
| 49 | +--- |
| 50 | +scenario: "${TEST}" |
| 51 | +legacy_component_name: "pulpcore" |
| 52 | +component_name: "core" |
| 53 | +component_version: "${COMPONENT_VERSION}" |
| 54 | +pulp_env: {"PULP_CA_BUNDLE": "/etc/pulp/certs/pulp_webserver.crt"} |
| 55 | +pulp_settings: {"allowed_export_paths": ["/tmp"], "allowed_import_paths": ["/tmp"], "content_path_prefix": "/somewhere/else/", "orphan_protection_time": 0, "task_protection_time": 10, "tmpfile_protection_time": 10, "upload_protection_time": 10} |
| 56 | +pulp_scheme: "https" |
| 57 | +pulp_default_container: "ghcr.io/pulp/pulp-ci-centos9:latest" |
| 58 | +api_root: "${PULP_API_ROOT}" |
| 59 | +image: |
| 60 | + name: "pulp" |
| 61 | + tag: "ci_build" |
| 62 | +plugins: |
| 63 | + - name: "pulpcore" |
| 64 | + source: "${COMPONENT_SOURCE}" |
| 65 | + ci_requirements: $(test -f ci_requirements.txt && echo -n true || echo -n false) |
| 66 | + upperbounds: $(test "${TEST}" = "pulp" && echo -n true || echo -n false) |
| 67 | + lowerounds: $(test "${TEST}" = "lowerbounds" && echo -n true || echo -n false) |
| 68 | +services: |
| 69 | + - name: "pulp" |
| 70 | + image: "pulp:ci_build" |
| 71 | + volumes: |
| 72 | + - "./settings:/etc/pulp" |
| 73 | + - "./ssh:/keys/" |
| 74 | + - "~/.config:/var/lib/pulp/.config" |
| 75 | + - "../../../pulp-openapi-generator:/root/pulp-openapi-generator" |
| 76 | + env: |
| 77 | + PULP_WORKERS: "4" |
| 78 | + PULP_HTTPS: "true" |
| 79 | + - name: "pulp-fixtures" |
| 80 | + image: "docker.io/pulp/pulp-fixtures:latest" |
| 81 | + env: |
| 82 | + BASE_URL: "http://pulp-fixtures:8080" |
| 83 | +VARSYAML |
43 | 84 |
|
44 | | -if [ -f $PRE_BEFORE_INSTALL ]; then |
45 | | - source $PRE_BEFORE_INSTALL |
| 85 | +if [ "$TEST" = "s3" ]; then |
| 86 | + MINIO_ACCESS_KEY=AKIAIT2Z5TDYPX3ARJBA |
| 87 | + MINIO_SECRET_KEY=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 |
| 88 | + cat >> .ci/ansible/vars/main.yaml << VARSYAML |
| 89 | + - name: "minio" |
| 90 | + image: "minio/minio" |
| 91 | + env: |
| 92 | + MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY}" |
| 93 | + MINIO_SECRET_KEY: "${MINIO_SECRET_KEY}" |
| 94 | + command: "server /data" |
| 95 | +s3_test: true |
| 96 | +minio_access_key: "${MINIO_ACCESS_KEY}" |
| 97 | +minio_secret_key: "${MINIO_SECRET_KEY}" |
| 98 | +pulp_scenario_settings: {"DISABLED_authentication_backends": "@merge django.contrib.auth.backends.RemoteUserBackend", "DISABLED_authentication_json_header": "HTTP_X_RH_IDENTITY", "DISABLED_authentication_json_header_jq_filter": ".identity.user.username", "DISABLED_authentication_json_header_openapi_security_scheme": {"description": "External OAuth integration", "flows": {"clientCredentials": {"scopes": {"api.console": "grant_access_to_pulp"}, "tokenUrl": "https://your-identity-provider/token/issuer"}}, "type": "oauth2"}, "DISABLED_rest_framework__default_authentication_classes": "@merge pulpcore.app.authentication.JSONHeaderRemoteAuthentication", "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, "hide_guarded_distributions": true} |
| 99 | +pulp_scenario_env: {} |
| 100 | +VARSYAML |
46 | 101 | fi |
47 | 102 |
|
48 | | -if [ "$GITHUB_EVENT_NAME" = "pull_request" ] || [ "${BRANCH_BUILD}" = "1" -a "${BRANCH}" != "main" ] |
49 | | -then |
50 | | - echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p' >> .ci/ansible/vars/main.yaml |
| 103 | +if [ "$TEST" = "azure" ]; then |
| 104 | + cat >> .ci/ansible/vars/main.yaml << VARSYAML |
| 105 | + - name: "ci-azurite" |
| 106 | + image: "mcr.microsoft.com/azure-storage/azurite" |
| 107 | + command: "azurite-blob --skipApiVersionCheck --blobHost 0.0.0.0" |
| 108 | +azure_test: true |
| 109 | +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"}}, "api_root_rewrite_header": "X-API-Root", "domain_enabled": true} |
| 110 | +pulp_scenario_env: {} |
| 111 | +VARSYAML |
51 | 112 | fi |
52 | 113 |
|
53 | | -for i in {1..3} |
54 | | -do |
55 | | - ansible-galaxy collection install "amazon.aws:8.1.0" && s=0 && break || s=$? && sleep 3 |
56 | | -done |
57 | | -if [[ $s -gt 0 ]] |
58 | | -then |
59 | | - echo "Failed to install amazon.aws" |
60 | | - exit $s |
| 114 | +if [ "$TEST" = "gcp" ]; then |
| 115 | + cat >> .ci/ansible/vars/main.yaml << VARSYAML |
| 116 | + - name: "ci-gcp" |
| 117 | + image: "fsouza/fake-gcs-server" |
| 118 | + volumes: |
| 119 | + - "storage_data:/etc/pulp" |
| 120 | + command: " -scheme http" |
| 121 | +gcp_test: true |
| 122 | +pulp_scenario_settings: null |
| 123 | +pulp_scenario_env: {} |
| 124 | +VARSYAML |
61 | 125 | fi |
62 | 126 |
|
63 | | -if [[ "$TEST" = "pulp" ]]; then |
64 | | - python3 .ci/scripts/calc_constraints.py -u requirements.txt > upperbounds_constraints.txt |
65 | | -fi |
66 | | -if [[ "$TEST" = "lowerbounds" ]]; then |
67 | | - python3 .ci/scripts/calc_constraints.py requirements.txt > lowerbounds_constraints.txt |
68 | | -fi |
| 127 | +cat >> .ci/ansible/vars/main.yaml << VARSYAML |
| 128 | +... |
| 129 | +VARSYAML |
| 130 | +cat .ci/ansible/vars/main.yaml |
69 | 131 |
|
70 | | -if [ -f $POST_BEFORE_INSTALL ]; then |
71 | | - source $POST_BEFORE_INSTALL |
| 132 | +if [ -f .github/workflows/scripts/post_before_install.sh ]; then |
| 133 | + source .github/workflows/scripts/post_before_install.sh |
72 | 134 | fi |
0 commit comments