Skip to content

Commit 49b1249

Browse files
committed
Merge branch 'master' of github.com:pulp/pulp_python
2 parents b60f1ea + 51fcf3c commit 49b1249

10 files changed

Lines changed: 88 additions & 52 deletions

File tree

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# WARNING: DO NOT EDIT!
2+
#
3+
# This file was generated by plugin_template, and is managed by bootstrap.py. Please use
4+
# bootstrap.py to update this file.
5+
#
6+
# For more info visit https://github.com/pulp/plugin_template
7+
18
sudo: required
29
# https://docs.travis-ci.com/user/trusty-ci-environment/
310
dist: xenial
@@ -10,29 +17,23 @@ env:
1017
matrix:
1118
- DB=postgres TEST=pulp
1219
- DB=postgres TEST=docs
13-
- DB=mariadb TEST=pulp
1420

1521

1622
matrix:
1723
exclude:
18-
- python: '3.6'
19-
env: DB=mariadb TEST=pulp
20-
2124
- python: '3.6'
2225
env: DB=postgres TEST=docs
2326
fast_finish: true
2427
services:
2528
- postgresql
2629
- redis-server
27-
- mariadb
2830
addons:
2931
apt:
3032
packages:
3133
- httpie
3234
- jq
3335
# postgres versions provided by el7 RHSCL (lowest supportable version)
3436
postgresql: '9.6'
35-
mariadb: '10.3'
3637
before_install: .travis/before_install.sh
3738
install: .travis/install.sh
3839
before_script: .travis/before_script.sh
@@ -71,3 +72,6 @@ jobs:
7172
- DB=postgres
7273
- TEST=bindings
7374
if: tag IS present
75+
76+
notifications: None
77+

.travis/before_install.sh

Lines changed: 22 additions & 30 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
#
@@ -7,7 +7,7 @@
77
#
88
# For more info visit https://github.com/pulp/plugin_template
99

10-
set -v
10+
set -mveuo pipefail
1111

1212
export PRE_BEFORE_INSTALL=$TRAVIS_BUILD_DIR/.travis/pre_before_install.sh
1313
export POST_BEFORE_INSTALL=$TRAVIS_BUILD_DIR/.travis/post_before_install.sh
@@ -31,61 +31,53 @@ pip install -r test_requirements.txt
3131
# check the commit message
3232
./.travis/check_commit.sh
3333

34+
35+
3436
# Lint code.
35-
flake8 --config flake8.cfg || exit 1
37+
flake8 --config flake8.cfg
3638

3739
cd ..
38-
git clone https://github.com/pulp/ansible-pulp.git
40+
git clone --depth=1 https://github.com/pulp/ansible-pulp.git
3941
if [ -n "$PULP_ROLES_PR_NUMBER" ]; then
40-
pushd ansible-pulp
41-
git fetch origin +refs/pull/$PULP_ROLES_PR_NUMBER/merge
42+
cd ansible-pulp
43+
git fetch --depth=1 origin +refs/pull/$PULP_ROLES_PR_NUMBER/merge
4244
git checkout FETCH_HEAD
43-
popd
45+
cd ..
4446
fi
4547

46-
git clone https://github.com/pulp/pulpcore.git
48+
git clone --depth=1 https://github.com/pulp/pulpcore.git
4749

4850
if [ -n "$PULP_PR_NUMBER" ]; then
49-
pushd pulpcore
50-
git fetch origin +refs/pull/$PULP_PR_NUMBER/merge
51+
cd pulpcore
52+
git fetch --depth=1 origin +refs/pull/$PULP_PR_NUMBER/merge
5153
git checkout FETCH_HEAD
52-
popd
54+
cd ..
5355
fi
5456

5557

56-
git clone https://github.com/pulp/pulpcore-plugin.git
58+
git clone --depth=1 https://github.com/pulp/pulpcore-plugin.git
5759

5860
if [ -n "$PULP_PLUGIN_PR_NUMBER" ]; then
59-
pushd pulpcore-plugin
60-
git fetch origin +refs/pull/$PULP_PLUGIN_PR_NUMBER/merge
61+
cd pulpcore-plugin
62+
git fetch --depth=1 origin +refs/pull/$PULP_PLUGIN_PR_NUMBER/merge
6163
git checkout FETCH_HEAD
62-
popd
64+
cd ..
6365
fi
6466

6567

6668
if [ -n "$PULP_SMASH_PR_NUMBER" ]; then
67-
git clone https://github.com/PulpQE/pulp-smash.git
68-
pushd pulp-smash
69-
git fetch origin +refs/pull/$PULP_SMASH_PR_NUMBER/merge
69+
git clone --depth=1 https://github.com/PulpQE/pulp-smash.git
70+
cd pulp-smash
71+
git fetch --depth=1 origin +refs/pull/$PULP_SMASH_PR_NUMBER/merge
7072
git checkout FETCH_HEAD
71-
popd
73+
cd ..
7274
fi
7375

74-
if [ "$DB" = 'mariadb' ]; then
75-
# working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160
76-
mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';"
77-
mysql -u root -e "CREATE USER 'travis'@'%';"
78-
mysql -u root -e "CREATE DATABASE pulp;"
79-
mysql -u root -e "ALTER DATABASE pulp CHARACTER SET utf8;"
80-
mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';";
81-
else
82-
psql -c 'CREATE DATABASE pulp OWNER travis;'
83-
fi
76+
psql -c 'CREATE DATABASE pulp OWNER travis;'
8477

8578
pip install ansible
8679
cp pulp_python/.travis/playbook.yml ansible-pulp/playbook.yml
8780
cp pulp_python/.travis/postgres.yml ansible-pulp/postgres.yml
88-
cp pulp_python/.travis/mariadb.yml ansible-pulp/mariadb.yml
8981

9082
cd pulp_python
9183

.travis/playbook.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
include_vars: '{{ pulp_db_type }}.yml'
1313
vars:
1414
pulp_default_admin_password: admin
15-
pulp_source_dir: '/home/travis/build/pulp/pulpcore/'
16-
pulp_plugin_source_dir: "/home/travis/build/pulp/pulpcore-plugin"
15+
pulp_source_dir: '{{ ansible_env.TRAVIS_BUILD_DIR | dirname }}/pulpcore/'
16+
pulp_plugin_source_dir: "{{ ansible_env.TRAVIS_BUILD_DIR | dirname }}/pulpcore-plugin"
1717
pulp_install_plugins:
1818
pulp-python:
1919
app_label: "python"

.travis/publish_client_pypi.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pip install twine
1212
django-admin runserver 24817 >> ~/django_runserver.log 2>&1 &
1313
sleep 5
1414

15-
cd /home/travis/build/pulp/pulp_python/
15+
cd "${TRAVIS_BUILD_DIR}"
1616
export REPORTED_VERSION=$(http :24817/pulp/api/v3/status/ | jq --arg plugin pulp_python -r '.versions[] | select(.component == $plugin) | .version')
1717
export DESCRIPTION="$(git describe --all --exact-match `git rev-parse HEAD`)"
1818
if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then

.travis/script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ wait_for_pulp() {
2525
echo -n .
2626
sleep 1
2727
TIMEOUT=$(($TIMEOUT - 1))
28-
if [ $(http :24817/pulp/api/v3/status/ | jq '.database_connection.connected and .redis_connection.connected') = 'true' ]
28+
if [ "$(http :24817/pulp/api/v3/status/ 2>/dev/null | jq '.database_connection.connected and .redis_connection.connected')" = "true" ]
2929
then
3030
echo
3131
return

.travis/validate_commit_message.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@
1010
import subprocess
1111
import sys
1212

13-
KEYWORDS = ['fixes', 'closes', 're', 'ref']
14-
NO_ISSUE = '[noissue]'
15-
STATUSES = ['NEW', 'ASSIGNED', 'POST']
13+
KEYWORDS = ["fixes", "closes", "re", "ref"]
14+
NO_ISSUE = "[noissue]"
15+
STATUSES = ["NEW", "ASSIGNED", "POST"]
1616

1717
sha = sys.argv[1]
18-
message = subprocess.check_output(['git', 'log', '--format=%B', '-n 1', sha]).decode('utf-8')
18+
message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode("utf-8")
1919

2020

2121
def __check_status(issue):
22-
response = requests.get('https://pulp.plan.io/issues/{}.json'.format(issue))
22+
response = requests.get("https://pulp.plan.io/issues/{}.json".format(issue))
2323
response.raise_for_status()
2424
bug_json = response.json()
25-
status = bug_json['issue']['status']['name']
25+
status = bug_json["issue"]["status"]["name"]
2626
if status not in STATUSES:
27-
sys.exit("Error: issue #{issue} has invalid status of {status}. Status must be one of "
28-
"{statuses}.".format(issue=issue, status=status, statuses=", ".join(STATUSES)))
27+
sys.exit(
28+
"Error: issue #{issue} has invalid status of {status}. Status must be one of "
29+
"{statuses}.".format(issue=issue, status=status, statuses=", ".join(STATUSES))
30+
)
2931

3032

3133
print("Checking commit message for {sha}.".format(sha=sha[0:7]))
@@ -34,7 +36,7 @@ def __check_status(issue):
3436
if NO_ISSUE in message:
3537
print("Commit {sha} has no issue attached. Skipping issue check".format(sha=sha[0:7]))
3638
else:
37-
regex = r'(?:{keywords})[\s:]+#(\d+)'.format(keywords=('|').join(KEYWORDS))
39+
regex = r"(?:{keywords})[\s:]+#(\d+)".format(keywords=("|").join(KEYWORDS))
3840
pattern = re.compile(regex)
3941

4042
issues = pattern.findall(message)
@@ -43,7 +45,9 @@ def __check_status(issue):
4345
for issue in pattern.findall(message):
4446
__check_status(issue)
4547
else:
46-
sys.exit("Error: no attached issues found for {sha}. If this was intentional, add "
47-
" '{tag}' to the commit message.".format(sha=sha[0:7], tag=NO_ISSUE))
48+
sys.exit(
49+
"Error: no attached issues found for {sha}. If this was intentional, add "
50+
" '{tag}' to the commit message.".format(sha=sha[0:7], tag=NO_ISSUE)
51+
)
4852

4953
print("Commit message for {sha} passed.".format(sha=sha[0:7]))

CHANGES/4990.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Override the Remote's serializer to allow policy='on_demand' and policy='streamed'.

pulp_python/app/serializers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from packaging import specifiers
55
from rest_framework import serializers
66

7+
from pulpcore.plugin import models as core_models
78
from pulpcore.plugin import serializers as core_serializers
89

910
from pulp_python.app import models as python_models
@@ -252,6 +253,12 @@ class PythonRemoteSerializer(core_serializers.RemoteSerializer):
252253
required=False,
253254
help_text=_('Whether or not to include pre-release packages in the sync.')
254255
)
256+
policy = serializers.ChoiceField(
257+
help_text=_("The policy to use when downloading content. The possible values include: "
258+
"'immediate', 'on_demand', and 'cache_only'. 'immediate' is the default."),
259+
choices=core_models.Remote.POLICY_CHOICES,
260+
default=core_models.Remote.IMMEDIATE
261+
)
255262

256263
class Meta:
257264
fields = core_serializers.RemoteSerializer.Meta.fields + (

pulp_python/tests/functional/api/test_crud_remotes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from requests.exceptions import HTTPError
55
from pulp_smash import api, config, utils
6+
from pulp_smash.pulp3.constants import ON_DEMAND_DOWNLOAD_POLICIES
67

78
from pulp_python.tests.functional.constants import (
89
PYTHON_REMOTE_PATH,
@@ -150,8 +151,8 @@ def _gen_verbose_remote():
150151
attrs = gen_python_remote()
151152
attrs.update({
152153
'password': utils.uuid4(),
154+
'policy': random.choice(ON_DEMAND_DOWNLOAD_POLICIES),
153155
'username': utils.uuid4(),
154-
'validate': random.choice((False, True)),
155156
})
156157
return attrs
157158

template_config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This config represents the latest values used when running the plugin-template. Any settings that
2+
# were not present before running plugin-template have been added with their default values.
3+
4+
plugin_name: pulp_python
5+
plugin_app_label: python
6+
plugin_snake: pulp_python
7+
plugin_caps: PULP_PYTHON
8+
plugin_caps_short: PYTHON
9+
plugin_camel: PulpPython
10+
plugin_camel_short: Python
11+
plugin_dash: pulp-python
12+
plugin_dash_short: python
13+
black: False
14+
check_commit_message: True
15+
coverage: False
16+
deploy_client_to_pypi: True
17+
deploy_client_to_rubygems: True
18+
deploy_daily_client_to_pypi: True
19+
deploy_daily_client_to_rubygems: True
20+
deploy_to_pypi: True
21+
docs_test: True
22+
pydocstyle: True
23+
test_bindings: False
24+
pypi_username: pulp
25+
travis_notifications: None
26+
27+

0 commit comments

Comments
 (0)