Skip to content

Commit e89fd0d

Browse files
authored
Merge pull request #253 from pulp/commit-migrations
Commit migrations and update travis (get Travis passing)
2 parents bc06c9a + 565ae2b commit e89fd0d

File tree

8 files changed

+302
-102
lines changed

8 files changed

+302
-102
lines changed

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,3 @@ target/
5959

6060
# PyCharm
6161
.idea
62-
63-
# Django migrations
64-
# Ignored during early development to prevent accidental commits;
65-
# we'll want these to not be ignored when releasing pulp 3.0
66-
pulp_python/app/migrations

.travis.yml

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,29 @@
44
# bootstrap.py to update this file.
55
#
66
# For more info visit https://github.com/pulp/plugin_template
7-
7+
---
88
sudo: required
99
# https://docs.travis-ci.com/user/trusty-ci-environment/
1010
dist: xenial
1111
language: python
1212
python:
13-
# python versions used in el7 SCL & supported fedora
14-
- "3.6"
15-
- "3.7"
13+
# Fedora has 3.6 available (python36.x86_64), but pulp container images
14+
# with it are not being built or published yet.
15+
# - "3.6"
16+
- "3.7"
1617
env:
1718
matrix:
1819
- DB=postgres TEST=pulp
1920
- DB=postgres TEST=docs
20-
21-
2221
matrix:
2322
exclude:
24-
2523
- python: '3.6'
2624
env: DB=postgres TEST=docs
2725
fast_finish: true
2826
services:
29-
- postgresql
30-
- redis-server
27+
- postgresql
28+
- redis-server
29+
- docker
3130
addons:
3231
apt:
3332
packages:
@@ -40,40 +39,43 @@ install: .travis/install.sh
4039
before_script: .travis/before_script.sh
4140
script: .travis/script.sh
4241
after_failure:
43-
- sh -c "cat ~/django_runserver.log"
44-
- sh -c "cat ~/resource_manager.log"
45-
- sh -c "cat ~/reserved_workers-1.log"
42+
- http --timeout 30 --check-status --pretty format --print hb http://localhost:24817/pulp/api/v3/status/
43+
- sudo docker images
44+
- sudo kubectl logs -l name=pulp-operator -c ansible --tail=10000
45+
- sudo kubectl logs -l name=pulp-operator -c operator --tail=10000
46+
- sudo kubectl logs -l app=pulp-api --tail=50000
47+
- sudo kubectl logs -l app=pulp-content --tail=10000
48+
- sudo kubectl logs -l app=pulp-resource-manager --tail=10000
49+
- sudo kubectl logs -l app=pulp-worker --tail=10000
4650
jobs:
4751
include:
48-
- stage: deploy-plugin-to-pypi
49-
script: bash .travis/publish_plugin_pypi.sh
50-
if: tag IS present
51-
52-
- stage: publish-daily-client-gem
53-
script: bash .travis/publish_client_gem.sh
54-
env:
55-
- DB=postgres
56-
- TEST=bindings
57-
if: type = cron
58-
- stage: publish-daily-client-pypi
59-
script: bash .travis/publish_client_pypi.sh
60-
env:
61-
- DB=postgres
62-
- TEST=bindings
63-
if: type = cron
64-
- stage: publish-client-gem
65-
script: bash .travis/publish_client_gem.sh
66-
env:
67-
- DB=postgres
68-
- TEST=bindings
69-
if: tag IS present
70-
- stage: publish-client-pypi
71-
script: bash .travis/publish_client_pypi.sh
72-
env:
73-
- DB=postgres
74-
- TEST=bindings
75-
if: tag IS present
76-
52+
- stage: deploy-plugin-to-pypi
53+
install: skip
54+
script: bash .travis/publish_plugin_pypi.sh
55+
if: tag IS present
56+
- stage: publish-daily-client-gem
57+
script: bash .travis/publish_client_gem.sh
58+
env:
59+
- DB=postgres
60+
- TEST=bindings
61+
if: type = cron
62+
- stage: publish-daily-client-pypi
63+
script: bash .travis/publish_client_pypi.sh
64+
env:
65+
- DB=postgres
66+
- TEST=bindings
67+
if: type = cron
68+
- stage: publish-client-gem
69+
script: bash .travis/publish_client_gem.sh
70+
env:
71+
- DB=postgres
72+
- TEST=bindings
73+
if: tag IS present
74+
- stage: publish-client-pypi
75+
script: bash .travis/publish_client_pypi.sh
76+
env:
77+
- DB=postgres
78+
- TEST=bindings
79+
if: tag IS present
7780
notifications: None
78-
79-
81+
...

.travis/before_install.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ export PULP_PLUGIN_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https
2424
export PULP_SMASH_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/PulpQE\/pulp-smash\/pull\/(\d+)' | awk -F'/' '{print $7}')
2525
export PULP_ROLES_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/ansible-pulp\/pull\/(\d+)' | awk -F'/' '{print $7}')
2626
export PULP_BINDINGS_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulp-openapi-generator\/pull\/(\d+)' | awk -F'/' '{print $7}')
27+
export PULP_OPERATOR_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulp-operator\/pull\/(\d+)' | awk -F'/' '{print $7}')
2728

28-
# dev_requirements should not be needed for testing; don't install them to make sure
29+
# test_requirements contains tools needed for flake8, etc.
30+
# So install them here rather than in install.sh
2931
pip install -r test_requirements.txt
3032

3133
# check the commit message
@@ -45,6 +47,16 @@ if [ -n "$PULP_ROLES_PR_NUMBER" ]; then
4547
cd ..
4648
fi
4749

50+
51+
git clone --depth=1 https://github.com/pulp/pulp-operator.git
52+
if [ -n "$PULP_OPERATOR_PR_NUMBER" ]; then
53+
cd pulp-operator
54+
git fetch --depth=1 origin +refs/pull/$PULP_OPERATOR_PR_NUMBER/merge
55+
git checkout FETCH_HEAD
56+
cd ..
57+
fi
58+
59+
4860
git clone --depth=1 https://github.com/pulp/pulpcore.git
4961

5062
if [ -n "$PULP_PR_NUMBER" ]; then
@@ -65,19 +77,19 @@ if [ -n "$PULP_PLUGIN_PR_NUMBER" ]; then
6577
fi
6678

6779

80+
git clone --depth=1 https://github.com/PulpQE/pulp-smash.git
81+
6882
if [ -n "$PULP_SMASH_PR_NUMBER" ]; then
69-
git clone --depth=1 https://github.com/PulpQE/pulp-smash.git
7083
cd pulp-smash
7184
git fetch --depth=1 origin +refs/pull/$PULP_SMASH_PR_NUMBER/merge
7285
git checkout FETCH_HEAD
7386
cd ..
7487
fi
7588

76-
psql -c 'CREATE DATABASE pulp OWNER travis;'
89+
# pulp-smash already got installed via test_requirements.txt
90+
pip install --upgrade --force-reinstall ./pulp-smash
7791

7892
pip install ansible
79-
cp pulp_python/.travis/playbook.yml ansible-pulp/playbook.yml
80-
cp pulp_python/.travis/postgres.yml ansible-pulp/postgres.yml
8193

8294
cd pulp_python
8395

.travis/before_script.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ fi
1818

1919

2020
mkdir -p ~/.config/pulp_smash
21-
cp ../pulpcore/.travis/pulp-smash-config.json ~/.config/pulp_smash/settings.json
21+
22+
if [ -f .travis/pulp-smash-config.json ]; then
23+
sed "s/localhost/$(hostname)/g" .travis/pulp-smash-config.json > ~/.config/pulp_smash/settings.json
24+
else
25+
sed "s/localhost/$(hostname)/g" ../pulpcore/.travis/pulp-smash-config.json > ~/.config/pulp_smash/settings.json
26+
fi
2227

2328

2429
if [ -f $POST_BEFORE_SCRIPT ]; then

.travis/install.sh

Lines changed: 101 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
# WARNING: DO NOT EDIT!
44
#
@@ -10,14 +10,108 @@
1010
set -euv
1111

1212
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
1417
fi
1518

1619
pip install -r test_requirements.txt
1720

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
21114

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

Comments
 (0)