diff --git a/.travis.yml b/.travis.yml index 081c3b18..84e98f2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,10 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + sudo: required # https://docs.travis-ci.com/user/trusty-ci-environment/ dist: xenial @@ -7,33 +14,66 @@ python: - "3.6" - "3.7" env: - - DB=postgres -addons: - # postgres versions provided by el7 RHSCL (lowest supportable version) - postgresql: "9.6" + matrix: + - DB=postgres TEST=pulp + - DB=postgres TEST=docs + + +matrix: + exclude: + + - python: '3.6' + env: DB=postgres TEST=docs + fast_finish: true services: - postgresql - redis-server -install: source .travis/install.sh -before_script: source .travis/before_script.sh -script: source .travis/script.sh +addons: + apt: + packages: + - httpie + - jq + # postgres versions provided by el7 RHSCL (lowest supportable version) + postgresql: '9.6' +before_install: .travis/before_install.sh +install: .travis/install.sh +before_script: .travis/before_script.sh +script: .travis/script.sh after_failure: - sh -c "cat ~/django_runserver.log" - sh -c "cat ~/resource_manager.log" - sh -c "cat ~/reserved_workers-1.log" -stages: -- name: test -- name: deploy - if: tag =~ ^3.0.0* jobs: include: - - stage: deploy - script: skip - deploy: - provider: pypi - distributions: sdist bdist_wheel - user: pulp - password: - secure: O/1r6kCPWggV5sjmFACgGeml1dgMy8w46ku3atUiXyK5gJIVexbTMIXgLkpfTSu58ODBGoaW+ML6SQmC1K+82Vjq1OMURfrhvzolgSBhREMfM9lNjA52SoKCLzq4ldP31pOy/z3Z9T76vAJOWF7uI80jd2QJ2p+p6h101REl1dk= - on: - tags: true + - stage: deploy-plugin-to-pypi + script: bash .travis/publish_plugin_pypi.sh + if: tag IS present + + - stage: publish-daily-client-gem + script: bash .travis/publish_client_gem.sh + env: + - DB=postgres + - TEST=bindings + if: type = cron + - stage: publish-daily-client-pypi + script: bash .travis/publish_client_pypi.sh + env: + - DB=postgres + - TEST=bindings + if: type = cron + - stage: publish-client-gem + script: bash .travis/publish_client_gem.sh + env: + - DB=postgres + - TEST=bindings + if: tag IS present + - stage: publish-client-pypi + script: bash .travis/publish_client_pypi.sh + env: + - DB=postgres + - TEST=bindings + if: tag IS present + +notifications: None + + diff --git a/.travis/before_install.sh b/.travis/before_install.sh new file mode 100755 index 00000000..0886f37e --- /dev/null +++ b/.travis/before_install.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +set -mveuo pipefail + +export PRE_BEFORE_INSTALL=$TRAVIS_BUILD_DIR/.travis/pre_before_install.sh +export POST_BEFORE_INSTALL=$TRAVIS_BUILD_DIR/.travis/post_before_install.sh + +COMMIT_MSG=$(git log --format=%B --no-merges -1) +export COMMIT_MSG + +if [ -x $PRE_BEFORE_INSTALL ]; then + $PRE_BEFORE_INSTALL +fi + +export PULP_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulpcore\/pull\/(\d+)' | awk -F'/' '{print $7}') +export PULP_PLUGIN_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulpcore-plugin\/pull\/(\d+)' | awk -F'/' '{print $7}') +export PULP_SMASH_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/PulpQE\/pulp-smash\/pull\/(\d+)' | awk -F'/' '{print $7}') +export PULP_ROLES_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/ansible-pulp\/pull\/(\d+)' | awk -F'/' '{print $7}') +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}') + +# dev_requirements should not be needed for testing; don't install them to make sure +pip install -r test_requirements.txt + +# check the commit message +./.travis/check_commit.sh + + + +# Lint code. +flake8 --config flake8.cfg + +cd .. +git clone --depth=1 https://github.com/pulp/ansible-pulp.git +if [ -n "$PULP_ROLES_PR_NUMBER" ]; then + cd ansible-pulp + git fetch --depth=1 origin +refs/pull/$PULP_ROLES_PR_NUMBER/merge + git checkout FETCH_HEAD + cd .. +fi + +git clone --depth=1 https://github.com/pulp/pulpcore.git + +if [ -n "$PULP_PR_NUMBER" ]; then + cd pulpcore + git fetch --depth=1 origin +refs/pull/$PULP_PR_NUMBER/merge + git checkout FETCH_HEAD + cd .. +fi + + +git clone --depth=1 https://github.com/pulp/pulpcore-plugin.git + +if [ -n "$PULP_PLUGIN_PR_NUMBER" ]; then + cd pulpcore-plugin + git fetch --depth=1 origin +refs/pull/$PULP_PLUGIN_PR_NUMBER/merge + git checkout FETCH_HEAD + cd .. +fi + + +if [ -n "$PULP_SMASH_PR_NUMBER" ]; then + git clone --depth=1 https://github.com/PulpQE/pulp-smash.git + cd pulp-smash + git fetch --depth=1 origin +refs/pull/$PULP_SMASH_PR_NUMBER/merge + git checkout FETCH_HEAD + cd .. +fi + +psql -c 'CREATE DATABASE pulp OWNER travis;' + +pip install ansible +cp pulp_python/.travis/playbook.yml ansible-pulp/playbook.yml +cp pulp_python/.travis/postgres.yml ansible-pulp/postgres.yml + +cd pulp_python + +if [ -x $POST_BEFORE_INSTALL ]; then + $POST_BEFORE_INSTALL +fi diff --git a/.travis/before_script.sh b/.travis/before_script.sh old mode 100644 new mode 100755 index ed867e2c..662b5406 --- a/.travis/before_script.sh +++ b/.travis/before_script.sh @@ -1,14 +1,26 @@ #!/usr/bin/env sh + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + set -v -psql -U postgres -c 'CREATE USER pulp WITH SUPERUSER LOGIN;' -psql -U postgres -c 'CREATE DATABASE pulp OWNER pulp;' +export PRE_BEFORE_SCRIPT=$TRAVIS_BUILD_DIR/.travis/pre_before_script.sh +export POST_BEFORE_SCRIPT=$TRAVIS_BUILD_DIR/.travis/post_before_script.sh + +if [ -f $PRE_BEFORE_SCRIPT ]; then + $PRE_BEFORE_SCRIPT +fi + mkdir -p ~/.config/pulp_smash cp ../pulpcore/.travis/pulp-smash-config.json ~/.config/pulp_smash/settings.json -sudo mkdir -p /var/lib/pulp/tmp -sudo mkdir /etc/pulp/ -sudo chown -R travis:travis /var/lib/pulp -echo "SECRET_KEY: \"$(cat /dev/urandom | tr -dc 'a-z0-9!@#$%^&*(\-_=+)' | head -c 50)\"" | sudo tee -a /etc/pulp/settings.py +if [ -f $POST_BEFORE_SCRIPT ]; then + $POST_BEFORE_SCRIPT +fi diff --git a/.travis/check_commit.sh b/.travis/check_commit.sh new file mode 100755 index 00000000..86e6407c --- /dev/null +++ b/.travis/check_commit.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +# skip this check for everything but PRs +if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then + exit 0 +fi + +if [ "$TRAVIS_COMMIT_RANGE" != "" ]; then + RANGE=$TRAVIS_COMMIT_RANGE +elif [ "$TRAVIS_COMMIT" != "" ]; then + RANGE=$TRAVIS_COMMIT +fi + +# Travis sends the ranges with 3 dots. Git only wants one. +if [[ "$RANGE" == *...* ]]; then + RANGE=`echo $TRAVIS_COMMIT_RANGE | sed 's/\.\.\./../'` +else + RANGE="$RANGE~..$RANGE" +fi + +for sha in `git log --format=oneline --no-merges "$RANGE" | cut '-d ' -f1` +do + python .travis/validate_commit_message.py $sha + VALUE=$? + + if [ "$VALUE" -gt 0 ]; then + exit $VALUE + fi +done diff --git a/.travis/install.sh b/.travis/install.sh old mode 100644 new mode 100755 index ebad610a..e1f6b1bd --- a/.travis/install.sh +++ b/.travis/install.sh @@ -1,44 +1,24 @@ #!/usr/bin/env sh -set -v - -export COMMIT_MSG=$(git show HEAD^2 -s) -export PULP_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulpcore\/pull\/(\d+)' | awk -F'/' '{print $7}') -export PULP_PLUGIN_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulpcore-plugin\/pull\/(\d+)' | awk -F'/' '{print $7}') -export PULP_SMASH_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/PulpQE\/pulp-smash\/pull\/(\d+)' | awk -F'/' '{print $7}') - -pip install -r test_requirements.txt - -cd .. && git clone https://github.com/pulp/pulpcore.git -if [ -n "$PULP_PR_NUMBER" ]; then - pushd pulpcore - git fetch origin +refs/pull/$PULP_PR_NUMBER/merge - git checkout FETCH_HEAD - popd -fi - -pip install -e ./pulpcore[postgres] +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template -git clone https://github.com/pulp/pulpcore-plugin.git +set -v -if [ -n "$PULP_PLUGIN_PR_NUMBER" ]; then - pushd pulpcore-plugin - git fetch origin +refs/pull/$PULP_PLUGIN_PR_NUMBER/merge - git checkout FETCH_HEAD - popd +if [ "$TEST" = 'docs' ]; then + pip3 install -r doc_requirements.txt fi -pip install -e ./pulpcore-plugin +pip install -r test_requirements.txt -if [ -n "$PULP_SMASH_PR_NUMBER" ]; then - pip uninstall -y pulp-smash - git clone https://github.com/PulpQE/pulp-smash.git - pushd pulp-smash - git fetch origin +refs/pull/$PULP_SMASH_PR_NUMBER/merge - git checkout FETCH_HEAD - popd - pip install -e ./pulp-smash -fi +# Run Ansible playbook +cd ../ansible-pulp +ansible-galaxy install -r requirements.yml -cd pulp_python -pip install -e . +ansible-playbook --connection=local --inventory 127.0.0.1, playbook.yml --extra-vars \ + "pulp_python_interpreter=$VIRTUAL_ENV/bin/python, pulp_install_dir=$VIRTUAL_ENV \ + pulp_db_type=$DB" diff --git a/.travis/mariadb.yml b/.travis/mariadb.yml new file mode 100644 index 00000000..b26bda83 --- /dev/null +++ b/.travis/mariadb.yml @@ -0,0 +1,9 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +--- +pulp_db_backend: django.db.backends.mysql diff --git a/.travis/playbook.yml b/.travis/playbook.yml new file mode 100644 index 00000000..09559e4d --- /dev/null +++ b/.travis/playbook.yml @@ -0,0 +1,41 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +--- +- hosts: all + pre_tasks: + - name: Load DB variables + include_vars: '{{ pulp_db_type }}.yml' + vars: + pulp_default_admin_password: admin + pulp_source_dir: '{{ ansible_env.TRAVIS_BUILD_DIR | dirname }}/pulpcore/' + pulp_plugin_source_dir: "{{ ansible_env.TRAVIS_BUILD_DIR | dirname }}/pulpcore-plugin" + pulp_install_plugins: + pulp-python: + app_label: "python" + source_dir: "$TRAVIS_BUILD_DIR" + ansible_python_interpreter: '/opt/pyenv/shims/python3' + pulp_user: 'travis' + developer_user: 'travis' + pulp_install_db: false + pulp_preq_packages: [] + pulp_settings: + content_host: 'localhost:24816' + secret_key: 'secret' + databases: + default: + ENGINE: "{{ pulp_db_backend }}" + USER: 'travis' + PASSWORD: '' + environment: + DJANGO_SETTINGS_MODULE: pulpcore.app.settings + roles: + - pulp-database + - pulp-workers + - pulp-resource-manager + - pulp-webserver + - pulp-content diff --git a/.travis/postgres.yml b/.travis/postgres.yml new file mode 100644 index 00000000..295bd570 --- /dev/null +++ b/.travis/postgres.yml @@ -0,0 +1,9 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +--- +pulp_db_backend: django.db.backends.postgresql_psycopg2 diff --git a/.travis/publish_client_gem.sh b/.travis/publish_client_gem.sh new file mode 100755 index 00000000..d35bafd5 --- /dev/null +++ b/.travis/publish_client_gem.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +echo "--- +:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials +sudo chmod 600 ~/.gem/credentials + +django-admin runserver 24817 >> ~/django_runserver.log 2>&1 & +sleep 5 + +cd $TRAVIS_BUILD_DIR +export REPORTED_VERSION=$(http :24817/pulp/api/v3/status/ | jq --arg plugin pulp_python -r '.versions[] | select(.component == $plugin) | .version') +export DESCRIPTION="$(git describe --all --exact-match `git rev-parse HEAD`)" +if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then + export VERSION=${REPORTED_VERSION} +else + export EPOCH="$(date +%s)" + export VERSION=${REPORTED_VERSION}${EPOCH} +fi + +export response=$(curl --write-out %{http_code} --silent --output /dev/null https://rubygems.org/gems/pulp_python_client/versions/$VERSION) + +if [ "$response" == "200" ]; +then + exit +fi + +cd +git clone https://github.com/pulp/pulp-openapi-generator.git +cd pulp-openapi-generator + +./generate.sh pulp_python ruby $VERSION +cd pulp_python-client +gem build pulp_python_client +GEM_FILE="$(ls | grep pulp_python_client-)" +gem push ${GEM_FILE} diff --git a/.travis/publish_client_pypi.sh b/.travis/publish_client_pypi.sh new file mode 100755 index 00000000..97475284 --- /dev/null +++ b/.travis/publish_client_pypi.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +pip install twine + +django-admin runserver 24817 >> ~/django_runserver.log 2>&1 & +sleep 5 + +cd "${TRAVIS_BUILD_DIR}" +export REPORTED_VERSION=$(http :24817/pulp/api/v3/status/ | jq --arg plugin pulp_python -r '.versions[] | select(.component == $plugin) | .version') +export DESCRIPTION="$(git describe --all --exact-match `git rev-parse HEAD`)" +if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then + export VERSION=${REPORTED_VERSION} +else + export EPOCH="$(date +%s)" + export VERSION=${REPORTED_VERSION}${EPOCH} +fi + +export response=$(curl --write-out %{http_code} --silent --output /dev/null https://pypi.org/project/pulp-file-client/$VERSION/) + +if [ "$response" == "200" ]; +then + exit +fi + +cd +git clone https://github.com/pulp/pulp-openapi-generator.git +cd pulp-openapi-generator + +./generate.sh pulp_python python $VERSION +cd pulp_python-client +python setup.py sdist bdist_wheel --python-tag py3 +twine upload dist/* -u pulp -p $PYPI_PASSWORD +exit $? diff --git a/.travis/publish_plugin_pypi.sh b/.travis/publish_plugin_pypi.sh new file mode 100755 index 00000000..d2c52d6b --- /dev/null +++ b/.travis/publish_plugin_pypi.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +pip install twine + +python setup.py sdist bdist_wheel --python-tag py3 +twine upload dist/* -u pulp -p $PYPI_PASSWORD diff --git a/.travis/script.sh b/.travis/script.sh old mode 100644 new mode 100755 index dbbbf9b5..a624f4d7 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -1,43 +1,104 @@ #!/usr/bin/env bash # coding=utf-8 -set -veuo pipefail -# Lint code. -flake8 --config flake8.cfg || exit 1 +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +set -mveuo pipefail -# Run migrations. +export POST_SCRIPT=$TRAVIS_BUILD_DIR/.travis/post_script.sh +export POST_DOCS_TEST=$TRAVIS_BUILD_DIR/.travis/post_docs_test.sh + +# Needed for both starting the service and building the docs. +# Gets set in .travis/settings.yml, but doesn't seem to inherited by +# this script. export DJANGO_SETTINGS_MODULE=pulpcore.app.settings -export PULP_CONTENT_HOST=localhost:24816 -django-admin makemigrations python -django-admin migrate --noinput -# Run unit tests. -(cd ../pulpcore && coverage run manage.py test pulp_python.tests.unit) +wait_for_pulp() { + TIMEOUT=${1:-5} + while [ "$TIMEOUT" -gt 0 ] + do + echo -n . + sleep 1 + TIMEOUT=$(($TIMEOUT - 1)) + if [ "$(http :24817/pulp/api/v3/status/ 2>/dev/null | jq '.database_connection.connected and .redis_connection.connected')" = "true" ] + then + echo + return + fi + done + echo + return 1 +} + +if [ "$TEST" = 'docs' ]; then + sleep 5 + cd docs + make html + cd .. + + if [ -x $POST_DOCS_TEST ]; then + $POST_DOCS_TEST + fi + exit +fi + +if [ "$TEST" = 'bindings' ]; then + COMMIT_MSG=$(git log --format=%B --no-merges -1) + 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}') + + cd .. + git clone https://github.com/pulp/pulp-openapi-generator.git + cd pulp-openapi-generator -# Run functional tests. -django-admin reset-admin-password --password admin -django-admin runserver 24817 >> ~/django_runserver.log 2>&1 & -gunicorn pulpcore.content:server --bind 'localhost:24816' --worker-class 'aiohttp.GunicornWebWorker' -w 2 >> ~/content_app.log 2>&1 & -rq worker -n 'resource-manager@%h' -w 'pulpcore.tasking.worker.PulpWorker' >> ~/resource_manager.log 2>&1 & -rq worker -n 'reserved-resource-worker-1@%h' -w 'pulpcore.tasking.worker.PulpWorker' >> ~/reserved_worker-1.log 2>&1 & -sleep 8 + if [ -n "$PULP_BINDINGS_PR_NUMBER" ]; then + git fetch origin +refs/pull/$PULP_BINDINGS_PR_NUMBER/merge + git checkout FETCH_HEAD + fi + ./generate.sh pulpcore python + pip install ./pulpcore-client + ./generate.sh pulp_python python + pip install ./pulp_python-client + + python $TRAVIS_BUILD_DIR/.travis/test_bindings.py + exit +fi + +# Run unit tests. +coverage run $(which django-admin) test ./pulp_python/tests/unit/ + +# Run functional tests, and upload coverage report to codecov. show_logs_and_return_non_zero() { readonly local rc="$?" cat ~/django_runserver.log cat ~/content_app.log cat ~/resource_manager.log - cat ~/'reserved_worker-1.log' + cat ~/reserved_worker-1.log return "${rc}" } + +# Stop services started by ansible roles +sudo systemctl stop pulp-worker* pulp-resource-manager pulp-content-app pulp-api + +# Start services with logs and coverage +export PULP_CONTENT_HOST=localhost:24816 +rq worker -n 'resource-manager@%h' -w 'pulpcore.tasking.worker.PulpWorker' -c 'pulpcore.rqconfig' >> ~/resource_manager.log 2>&1 & +rq worker -n 'reserved-resource-worker-1@%h' -w 'pulpcore.tasking.worker.PulpWorker' -c 'pulpcore.rqconfig' >> ~/reserved_worker-1.log 2>&1 & +gunicorn pulpcore.tests.functional.content_with_coverage:server --bind 'localhost:24816' --worker-class 'aiohttp.GunicornWebWorker' -w 2 >> ~/content_app.log 2>&1 & +coverage run $(which django-admin) runserver 24817 --noreload >> ~/django_runserver.log 2>&1 & +wait_for_pulp 20 + +# Run functional tests +pytest -v -r sx --color=yes --pyargs pulpcore.tests.functional || show_logs_and_return_non_zero pytest -v -r sx --color=yes --pyargs pulp_python.tests.functional || show_logs_and_return_non_zero -# Travis' scripts use unbound variables. This is problematic, because the -# changes made to this script's environment appear to persist when Travis' -# scripts execute. Perhaps this script is sourced by Travis? Regardless of why, -# we need to reset the environment when this script finishes. -# -# We can't use `trap cleanup_function EXIT` or similar, because this script is -# apparently sourced, and such a trap won't execute until the (buggy!) calling -# script finishes. -set +euo pipefail + + +if [ -x $POST_SCRIPT ]; then + $POST_SCRIPT +fi diff --git a/.travis/validate_commit_message.py b/.travis/validate_commit_message.py new file mode 100644 index 00000000..b22fecc4 --- /dev/null +++ b/.travis/validate_commit_message.py @@ -0,0 +1,53 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by bootstrap.py. Please use +# bootstrap.py to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +import re +import requests +import subprocess +import sys + +KEYWORDS = ["fixes", "closes", "re", "ref"] +NO_ISSUE = "[noissue]" +STATUSES = ["NEW", "ASSIGNED", "POST"] + +sha = sys.argv[1] +message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode("utf-8") + + +def __check_status(issue): + response = requests.get("https://pulp.plan.io/issues/{}.json".format(issue)) + response.raise_for_status() + bug_json = response.json() + status = bug_json["issue"]["status"]["name"] + if status not in STATUSES: + sys.exit( + "Error: issue #{issue} has invalid status of {status}. Status must be one of " + "{statuses}.".format(issue=issue, status=status, statuses=", ".join(STATUSES)) + ) + + +print("Checking commit message for {sha}.".format(sha=sha[0:7])) + +# validate the issue attached to the commit +if NO_ISSUE in message: + print("Commit {sha} has no issue attached. Skipping issue check".format(sha=sha[0:7])) +else: + regex = r"(?:{keywords})[\s:]+#(\d+)".format(keywords=("|").join(KEYWORDS)) + pattern = re.compile(regex) + + issues = pattern.findall(message) + + if issues: + for issue in pattern.findall(message): + __check_status(issue) + else: + sys.exit( + "Error: no attached issues found for {sha}. If this was intentional, add " + " '{tag}' to the commit message.".format(sha=sha[0:7], tag=NO_ISSUE) + ) + +print("Commit message for {sha} passed.".format(sha=sha[0:7])) diff --git a/CHANGES/4990.feature b/CHANGES/4990.feature new file mode 100644 index 00000000..09591b2c --- /dev/null +++ b/CHANGES/4990.feature @@ -0,0 +1 @@ +Override the Remote's serializer to allow policy='on_demand' and policy='streamed'. \ No newline at end of file diff --git a/pulp_python/app/serializers.py b/pulp_python/app/serializers.py index 3df1ea1b..8522f1de 100644 --- a/pulp_python/app/serializers.py +++ b/pulp_python/app/serializers.py @@ -4,6 +4,7 @@ from packaging import specifiers from rest_framework import serializers +from pulpcore.plugin import models as core_models from pulpcore.plugin import serializers as core_serializers from pulp_python.app import models as python_models @@ -252,6 +253,12 @@ class PythonRemoteSerializer(core_serializers.RemoteSerializer): required=False, help_text=_('Whether or not to include pre-release packages in the sync.') ) + policy = serializers.ChoiceField( + help_text=_("The policy to use when downloading content. The possible values include: " + "'immediate', 'on_demand', and 'cache_only'. 'immediate' is the default."), + choices=core_models.Remote.POLICY_CHOICES, + default=core_models.Remote.IMMEDIATE + ) class Meta: fields = core_serializers.RemoteSerializer.Meta.fields + ( diff --git a/pulp_python/tests/functional/api/test_crud_remotes.py b/pulp_python/tests/functional/api/test_crud_remotes.py index efb06162..6f1e7f5d 100644 --- a/pulp_python/tests/functional/api/test_crud_remotes.py +++ b/pulp_python/tests/functional/api/test_crud_remotes.py @@ -3,6 +3,7 @@ from requests.exceptions import HTTPError from pulp_smash import api, config, utils +from pulp_smash.pulp3.constants import ON_DEMAND_DOWNLOAD_POLICIES from pulp_python.tests.functional.constants import ( PYTHON_REMOTE_PATH, @@ -150,8 +151,8 @@ def _gen_verbose_remote(): attrs = gen_python_remote() attrs.update({ 'password': utils.uuid4(), + 'policy': random.choice(ON_DEMAND_DOWNLOAD_POLICIES), 'username': utils.uuid4(), - 'validate': random.choice((False, True)), }) return attrs diff --git a/template_config.yml b/template_config.yml new file mode 100644 index 00000000..268be11b --- /dev/null +++ b/template_config.yml @@ -0,0 +1,27 @@ +# This config represents the latest values used when running the plugin-template. Any settings that +# were not present before running plugin-template have been added with their default values. + +plugin_name: pulp_python +plugin_app_label: python +plugin_snake: pulp_python +plugin_caps: PULP_PYTHON +plugin_caps_short: PYTHON +plugin_camel: PulpPython +plugin_camel_short: Python +plugin_dash: pulp-python +plugin_dash_short: python +black: False +check_commit_message: True +coverage: False +deploy_client_to_pypi: True +deploy_client_to_rubygems: True +deploy_daily_client_to_pypi: True +deploy_daily_client_to_rubygems: True +deploy_to_pypi: True +docs_test: True +pydocstyle: True +test_bindings: False +pypi_username: pulp +travis_notifications: None + + diff --git a/test_requirements.txt b/test_requirements.txt index 55b42827..031bfa99 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -6,4 +6,5 @@ flake8-tuple flake8-quotes mock git+https://github.com/PulpQE/pulp-smash.git#egg=pulp-smash +pydocstyle<4 pytest