|
1 | | -#!/usr/bin/env sh |
| 1 | +#!/usr/bin/env bash |
2 | 2 |
|
3 | 3 | # WARNING: DO NOT EDIT! |
4 | 4 | # |
|
10 | 10 | set -euv |
11 | 11 |
|
12 | 12 | if [ "$TEST" = 'docs' ]; then |
13 | | - pip3 install -r doc_requirements.txt |
| 13 | + |
| 14 | + pip install -r ../pulpcore/doc_requirements.txt |
| 15 | + |
| 16 | + pip install -r doc_requirements.txt |
14 | 17 | fi |
15 | 18 |
|
16 | 19 | pip install -r test_requirements.txt |
17 | 20 |
|
18 | | -# Run Ansible playbook |
19 | | -cd ../ansible-pulp |
20 | | -ansible-galaxy install -r requirements.yml |
| 21 | +cd $TRAVIS_BUILD_DIR/../pulpcore/containers/ |
| 22 | + |
| 23 | +# Although the tag name is not used outside of this script, we might use it |
| 24 | +# later. And it is nice to have a friendly identifier for it. |
| 25 | +# So we use the branch preferably, but need to replace the "/" with the valid |
| 26 | +# character "_" . |
| 27 | +# |
| 28 | +# Note that there are lots of other valid git branch name special characters |
| 29 | +# that are invalid in image tag names. To try to convert them, this would be a |
| 30 | +# starting point: |
| 31 | +# https://stackoverflow.com/a/50687120 |
| 32 | +# |
| 33 | +# If we are on a PR |
| 34 | +if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ]; then |
| 35 | + TAG=$(echo $TRAVIS_PULL_REQUEST_BRANCH | tr / _) |
| 36 | +# For push builds, tag builds, and hopefully cron builds |
| 37 | +elif [ -n "$TRAVIS_BRANCH" ]; then |
| 38 | + TAG=$(echo $TRAVIS_BRANCH | tr / _) |
| 39 | + if [ "$TAG" = "master" ]; then |
| 40 | + TAG=latest |
| 41 | + fi |
| 42 | +else |
| 43 | + # Fallback |
| 44 | + TAG=$(git rev-parse --abbrev-ref HEAD | tr / _) |
| 45 | +fi |
| 46 | + |
| 47 | + |
| 48 | +PLUGIN=pulp_python |
| 49 | + |
| 50 | + |
| 51 | +# For pulpcore, and any other repo that might check out a pulp-certguard PR |
| 52 | +if [ -e $TRAVIS_BUILD_DIR/../pulp-certguard ]; then |
| 53 | + PULP_CERTGUARD=./pulp-certguard |
| 54 | +else |
| 55 | + # Otherwise, master branch release |
| 56 | + PULP_CERTGUARD=git+https://github.com/pulp/pulp-certguard.git |
| 57 | +fi |
| 58 | + |
| 59 | +cat > vars/vars.yaml << VARSYAML |
| 60 | +--- |
| 61 | +images: |
| 62 | + - ${PLUGIN}-${TAG}: |
| 63 | + image_name: $PLUGIN |
| 64 | + tag: $TAG |
| 65 | + pulpcore: ./pulpcore |
| 66 | + pulpcore_plugin: ./pulpcore-plugin |
| 67 | + plugins: |
| 68 | + - $PULP_CERTGUARD |
| 69 | + - ./$PLUGIN |
| 70 | +VARSYAML |
| 71 | + |
| 72 | +ansible-playbook build.yaml |
| 73 | + |
| 74 | +cd $TRAVIS_BUILD_DIR/../pulp-operator |
| 75 | +# Tell pulp-perator to deploy our image |
| 76 | +cat > deploy/crds/pulpproject_v1alpha1_pulp_cr.yaml << CRYAML |
| 77 | +apiVersion: pulpproject.org/v1alpha1 |
| 78 | +kind: Pulp |
| 79 | +metadata: |
| 80 | + name: example-pulp |
| 81 | +spec: |
| 82 | + pulp_file_storage: |
| 83 | + # k3s local-path requires this |
| 84 | + access_mode: "ReadWriteOnce" |
| 85 | + # We have a little over 40GB free on Travis VMs/instances |
| 86 | + size: "40Gi" |
| 87 | + image: $PLUGIN |
| 88 | + tag: $TAG |
| 89 | + database_connection: |
| 90 | + username: pulp |
| 91 | + password: pulp |
| 92 | + admin_password: pulp |
| 93 | + content_host: $(hostname):24816 |
| 94 | +CRYAML |
| 95 | + |
| 96 | +# Install k3s, lightweight Kubernetes |
| 97 | +.travis/k3s-install.sh |
| 98 | +# Deploy pulp-operator, with the pulp containers, according to CRYAML |
| 99 | +sudo ./up.sh |
| 100 | + |
| 101 | +# Needed for the script below |
| 102 | +# Since it is being run during install rather than actual tests (unlike in |
| 103 | +# pulp-operator), and therefore does not trigger the equivalent after_failure |
| 104 | +# travis commands. |
| 105 | +show_logs_and_return_non_zero() { |
| 106 | + readonly local rc="$?" |
| 107 | + |
| 108 | + for containerlog in "pulp-api" "pulp-content" "pulp-resource-manager" "pulp-worker" |
| 109 | + do |
| 110 | + echo -en "travis_fold:start:$containerlog"'\\r' |
| 111 | + sudo kubectl logs -l app=$containerlog --tail=10000 |
| 112 | + echo -en "travis_fold:end:$containerlog"'\\r' |
| 113 | + done |
21 | 114 |
|
22 | | -ansible-playbook --connection=local --inventory 127.0.0.1, playbook.yml --extra-vars \ |
23 | | - "pulp_python_interpreter=$VIRTUAL_ENV/bin/python, pulp_install_dir=$VIRTUAL_ENV" |
| 115 | + return "${rc}" |
| 116 | +} |
| 117 | +.travis/pulp-operator-check-and-wait.sh || show_logs_and_return_non_zero |
0 commit comments