From 7f69c6fb2ebac2b642d6cc0a72483c2f4a4cd752 Mon Sep 17 00:00:00 2001 From: Dennis Kliban Date: Sat, 3 Aug 2019 21:47:27 -0400 Subject: [PATCH] Problem: plugin is out of date Solution: use plugin-template to update travis config The code is now also formatted with black. Migrations are committed. closes: #5217 https://pulp.plan.io/issues/5217 --- .travis.yml | 19 ++- .travis/before_install.sh | 74 +++++++----- .travis/before_script.sh | 21 ++++ .travis/check_commit.sh | 7 ++ .travis/install.sh | 14 +++ .travis/mariadb.yml | 7 ++ .travis/playbook.yml | 22 +++- .travis/postgres.yml | 7 ++ .travis/publish_client_gem.sh | 12 +- .travis/publish_client_pypi.sh | 14 ++- .travis/publish_plugin_pypi.sh | 9 +- .travis/script.sh | 76 ++++++++++-- .travis/validate_commit_message.py | 40 ++++-- docs/conf.py | 114 +++++++++--------- docs/workflows/cache.rst | 47 ++++++++ docs/workflows/index.rst | 4 +- docs/workflows/publish.rst | 57 --------- docs/workflows/sync.rst | 91 -------------- docs/workflows/upload.rst | 55 --------- pulp_maven/__init__.py | 4 +- pulp_maven/app/__init__.py | 4 +- pulp_maven/app/migrations/0001_initial.py | 74 ++++++++++++ pulp_maven/app/migrations/__init__.py | 0 pulp_maven/app/models.py | 23 ++-- pulp_maven/app/serializers.py | 25 ++-- pulp_maven/app/viewsets.py | 10 +- .../tests/functional/api/test_crud_remotes.py | 57 ++++----- .../functional/api/test_download_content.py | 36 +++--- pulp_maven/tests/functional/constants.py | 18 ++- pulp_maven/tests/functional/utils.py | 25 ++-- setup.py | 46 +++---- template_config.yml | 27 +++++ test_requirements.txt | 1 + 33 files changed, 564 insertions(+), 476 deletions(-) create mode 100644 docs/workflows/cache.rst delete mode 100644 docs/workflows/publish.rst delete mode 100644 docs/workflows/sync.rst delete mode 100644 docs/workflows/upload.rst create mode 100644 pulp_maven/app/migrations/0001_initial.py create mode 100644 pulp_maven/app/migrations/__init__.py create mode 100644 template_config.yml diff --git a/.travis.yml b/.travis.yml index 3d3518a..84e98f2 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 @@ -10,19 +17,17 @@ env: matrix: - DB=postgres TEST=pulp - DB=postgres TEST=docs - - DB=mariadb TEST=pulp matrix: exclude: - - python: '3.6' - env: DB=mariadb TEST=pulp + - python: '3.6' + env: DB=postgres TEST=docs fast_finish: true services: - postgresql - redis-server - - mariadb addons: apt: packages: @@ -30,7 +35,6 @@ addons: - jq # postgres versions provided by el7 RHSCL (lowest supportable version) postgresql: '9.6' - mariadb: '10.3' before_install: .travis/before_install.sh install: .travis/install.sh before_script: .travis/before_script.sh @@ -44,6 +48,7 @@ jobs: - 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: @@ -68,3 +73,7 @@ jobs: - DB=postgres - TEST=bindings if: tag IS present + +notifications: None + + diff --git a/.travis/before_install.sh b/.travis/before_install.sh index e2688a9..7f2c963 100755 --- a/.travis/before_install.sh +++ b/.travis/before_install.sh @@ -1,12 +1,29 @@ -#!/usr/bin/env sh -set -v +#!/usr/bin/env bash -COMMIT_MSG=$(git show HEAD^2 -s) +# 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 [ -f $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 @@ -14,60 +31,57 @@ pip install -r test_requirements.txt # check the commit message ./.travis/check_commit.sh +# run black separately from flake8 to get a diff +black --check --diff . + # Lint code. -flake8 --config flake8.cfg || exit 1 +flake8 --config flake8.cfg cd .. -git clone https://github.com/pulp/ansible-pulp.git +git clone --depth=1 https://github.com/pulp/ansible-pulp.git if [ -n "$PULP_ROLES_PR_NUMBER" ]; then - pushd ansible-pulp - git fetch origin +refs/pull/$PULP_ROLES_PR_NUMBER/merge + cd ansible-pulp + git fetch --depth=1 origin +refs/pull/$PULP_ROLES_PR_NUMBER/merge git checkout FETCH_HEAD - popd + cd .. fi -git clone https://github.com/pulp/pulpcore.git +git clone --depth=1 https://github.com/pulp/pulpcore.git if [ -n "$PULP_PR_NUMBER" ]; then - pushd pulpcore - git fetch origin +refs/pull/$PULP_PR_NUMBER/merge + cd pulpcore + git fetch --depth=1 origin +refs/pull/$PULP_PR_NUMBER/merge git checkout FETCH_HEAD - popd + cd .. fi -git clone https://github.com/pulp/pulpcore-plugin.git +git clone --depth=1 https://github.com/pulp/pulpcore-plugin.git if [ -n "$PULP_PLUGIN_PR_NUMBER" ]; then - pushd pulpcore-plugin - git fetch origin +refs/pull/$PULP_PLUGIN_PR_NUMBER/merge + cd pulpcore-plugin + git fetch --depth=1 origin +refs/pull/$PULP_PLUGIN_PR_NUMBER/merge git checkout FETCH_HEAD - popd + cd .. fi if [ -n "$PULP_SMASH_PR_NUMBER" ]; then - git clone https://github.com/PulpQE/pulp-smash.git - pushd pulp-smash - git fetch origin +refs/pull/$PULP_SMASH_PR_NUMBER/merge + 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 - popd + cd .. fi -if [ "$DB" = 'mariadb' ]; then - # working around https://travis-ci.community/t/mariadb-build-error-with-xenial/3160 - mysql -u root -e "DROP USER IF EXISTS 'travis'@'%';" - mysql -u root -e "CREATE USER 'travis'@'%';" - mysql -u root -e "CREATE DATABASE pulp;" - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'travis'@'%';"; -else - psql -c 'CREATE DATABASE pulp OWNER travis;' -fi +psql -c 'CREATE DATABASE pulp OWNER travis;' pip install ansible cp pulp_maven/.travis/playbook.yml ansible-pulp/playbook.yml cp pulp_maven/.travis/postgres.yml ansible-pulp/postgres.yml -cp pulp_maven/.travis/mariadb.yml ansible-pulp/mariadb.yml cd pulp_maven +if [ -f $POST_BEFORE_INSTALL ]; then + $POST_BEFORE_INSTALL +fi diff --git a/.travis/before_script.sh b/.travis/before_script.sh index 31d599a..662b540 100755 --- a/.travis/before_script.sh +++ b/.travis/before_script.sh @@ -1,5 +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 +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 + + +if [ -f $POST_BEFORE_SCRIPT ]; then + $POST_BEFORE_SCRIPT +fi diff --git a/.travis/check_commit.sh b/.travis/check_commit.sh index 55aa551..86e6407 100755 --- a/.travis/check_commit.sh +++ b/.travis/check_commit.sh @@ -1,5 +1,12 @@ #!/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 diff --git a/.travis/install.sh b/.travis/install.sh index 1cbcdaa..e1f6b1b 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -1,6 +1,20 @@ #!/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 +if [ "$TEST" = 'docs' ]; then + pip3 install -r doc_requirements.txt +fi + +pip install -r test_requirements.txt + # Run Ansible playbook cd ../ansible-pulp ansible-galaxy install -r requirements.yml diff --git a/.travis/mariadb.yml b/.travis/mariadb.yml index 053a1d4..b26bda8 100644 --- a/.travis/mariadb.yml +++ b/.travis/mariadb.yml @@ -1,2 +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 index 70060bb..491ea55 100644 --- a/.travis/playbook.yml +++ b/.travis/playbook.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 + --- - hosts: all pre_tasks: @@ -5,9 +12,8 @@ include_vars: '{{ pulp_db_type }}.yml' vars: pulp_default_admin_password: admin - pulp_secret_key: secret - pulp_source_dir: '/home/travis/build/pulp/pulpcore/' - pulp_plugin_source_dir: "/home/travis/build/pulp/pulpcore-plugin" + 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-maven: app_label: "maven" @@ -16,9 +22,15 @@ pulp_user: 'travis' developer_user: 'travis' pulp_install_db: false - pulp_db_user: 'travis' - pulp_db_password: '' 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: diff --git a/.travis/postgres.yml b/.travis/postgres.yml index 158be40..295bd57 100644 --- a/.travis/postgres.yml +++ b/.travis/postgres.yml @@ -1,2 +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 index aa34ba6..a578eb5 100755 --- a/.travis/publish_client_gem.sh +++ b/.travis/publish_client_gem.sh @@ -1,5 +1,12 @@ #!/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 @@ -14,7 +21,7 @@ if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then export VERSION=${REPORTED_VERSION} else export EPOCH="$(date +%s)" - export VERSION=${REPORTED_VERSION}.${EPOCH} + export VERSION=${REPORTED_VERSION}${EPOCH} fi export response=$(curl --write-out %{http_code} --silent --output /dev/null https://rubygems.org/gems/pulp_maven_client/versions/$VERSION) @@ -28,8 +35,7 @@ cd git clone https://github.com/pulp/pulp-openapi-generator.git cd pulp-openapi-generator -sudo ./generate.sh pulp_maven ruby $VERSION -sudo chown -R travis:travis pulp_maven-client +./generate.sh pulp_maven ruby $VERSION cd pulp_maven-client gem build pulp_maven_client GEM_FILE="$(ls | grep pulp_maven_client-)" diff --git a/.travis/publish_client_pypi.sh b/.travis/publish_client_pypi.sh index 3b4223b..578d732 100755 --- a/.travis/publish_client_pypi.sh +++ b/.travis/publish_client_pypi.sh @@ -1,18 +1,25 @@ #!/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 /home/travis/build/pulp/pulp_maven/ +cd "${TRAVIS_BUILD_DIR}" export REPORTED_VERSION=$(http :24817/pulp/api/v3/status/ | jq --arg plugin pulp_maven -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} + 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/) @@ -26,8 +33,7 @@ cd git clone https://github.com/pulp/pulp-openapi-generator.git cd pulp-openapi-generator -sudo ./generate.sh pulp_maven python $VERSION -sudo chown -R travis:travis pulp_maven-client +./generate.sh pulp_maven python $VERSION cd pulp_maven-client python setup.py sdist bdist_wheel --python-tag py3 twine upload dist/* -u pulp -p $PYPI_PASSWORD diff --git a/.travis/publish_plugin_pypi.sh b/.travis/publish_plugin_pypi.sh index 9027cf3..7567f22 100755 --- a/.travis/publish_plugin_pypi.sh +++ b/.travis/publish_plugin_pypi.sh @@ -1,6 +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 +twine upload dist/* -u None -p $PYPI_PASSWORD diff --git a/.travis/script.sh b/.travis/script.sh index 1fafb9e..5321c75 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -1,8 +1,19 @@ #!/usr/bin/env bash # coding=utf-8 +# 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 POST_SCRIPT=$TRAVIS_BUILD_DIR/.travis/post_script.sh +export POST_DOCS_TEST=$TRAVIS_BUILD_DIR/.travis/post_docs_test.sh +export FUNC_TEST_SCRIPT=$TRAVIS_BUILD_DIR/.travis/func_test_script.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. @@ -15,7 +26,7 @@ wait_for_pulp() { echo -n . sleep 1 TIMEOUT=$(($TIMEOUT - 1)) - if [ $(http :24817/pulp/api/v3/status/ | jq '.database_connection.connected and .redis_connection.connected') = 'true' ] + if [ "$(http :24817/pulp/api/v3/status/ 2>/dev/null | jq '.database_connection.connected and .redis_connection.connected')" = "true" ] then echo return @@ -25,29 +36,66 @@ wait_for_pulp() { return 1 } +if [ "$TEST" = 'docs' ]; then + sleep 5 + cd docs + make html + cd .. + + if [ -f $POST_DOCS_TEST ]; then + $POST_DOCS_TEST + fi + exit +fi + if [ "$TEST" = 'bindings' ]; then - COMMIT_MSG=$(git show HEAD^2 -s) - export PULP_BINDINGS_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/pulp-swagger-codegen\/pull\/(\d+)' | awk -F'/' '{print $7}') + 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-swagger-codegen.git - cd pulp-swagger-codegen + git clone https://github.com/pulp/pulp-openapi-generator.git + cd pulp-openapi-generator if [ -n "$PULP_BINDINGS_PR_NUMBER" ]; then git fetch origin +refs/pull/$PULP_BINDINGS_PR_NUMBER/merge git checkout FETCH_HEAD fi - sudo ./generate.sh pulpcore python - sudo ./generate.sh pulp_maven python + ./generate.sh pulpcore python pip install ./pulpcore-client + ./generate.sh pulp_maven python pip install ./pulp_maven-client + python $TRAVIS_BUILD_DIR/.travis/test_bindings.py + + if [ ! -f $TRAVIS_BUILD_DIR/.travis/test_bindings.rb ] + then + exit + fi + + rm -rf ./pulpcore-client + + ./generate.sh pulpcore ruby + cd pulpcore-client + gem build pulpcore_client + gem install --both ./pulpcore_client-0.gem + cd .. + + rm -rf ./pulp_maven-client + + ./generate.sh pulp_maven ruby + + cd pulp_maven-client + gem build pulp_maven_client + gem install --both ./pulp_maven_client-0.gem + cd .. + + ruby $TRAVIS_BUILD_DIR/.travis/test_bindings.rb exit fi # Run unit tests. -django-admin test ./pulp_maven/tests/unit/ +coverage run $(which django-admin) test ./pulp_maven/tests/unit/ # Run functional tests, and upload coverage report to codecov. show_logs_and_return_non_zero() { @@ -71,5 +119,13 @@ coverage run $(which django-admin) runserver 24817 --noreload >> ~/django_runser 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_maven.tests.functional || show_logs_and_return_non_zero +if [ -f $FUNC_TEST_SCRIPT ]; then + $FUNC_TEST_SCRIPT +else + pytest -v -r sx --color=yes --pyargs pulp_maven.tests.functional || show_logs_and_return_non_zero +fi + + +if [ -f $POST_SCRIPT ]; then + $POST_SCRIPT +fi diff --git a/.travis/validate_commit_message.py b/.travis/validate_commit_message.py index 6b1f392..120fb1a 100644 --- a/.travis/validate_commit_message.py +++ b/.travis/validate_commit_message.py @@ -1,24 +1,39 @@ +# 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 glob import re import requests import subprocess import sys -KEYWORDS = ['fixes', 'closes', 're', 'ref'] -NO_ISSUE = '[noissue]' -STATUSES = ['NEW', 'ASSIGNED', 'POST'] +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') +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 = requests.get("https://pulp.plan.io/issues/{}.json".format(issue)) response.raise_for_status() bug_json = response.json() - status = bug_json['issue']['status']['name'] + 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))) + sys.exit( + "Error: issue #{issue} has invalid status of {status}. Status must be one of " + "{statuses}.".format(issue=issue, status=status, statuses=", ".join(STATUSES)) + ) + + +def __check_changelog(issue): + if len(glob.glob(f"CHANGES/{issue}.*")) < 1: + sys.exit(f"Could not find changelog entry in CHANGES/ for {issue}.") print("Checking commit message for {sha}.".format(sha=sha[0:7])) @@ -27,7 +42,7 @@ def __check_status(issue): 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)) + regex = r"(?:{keywords})[\s:]+#(\d+)".format(keywords=("|").join(KEYWORDS)) pattern = re.compile(regex) issues = pattern.findall(message) @@ -35,8 +50,11 @@ def __check_status(issue): if issues: for issue in pattern.findall(message): __check_status(issue) + __check_changelog(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)) + 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/docs/conf.py b/docs/conf.py index 26fbdd7..4c0d252 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,106 +19,106 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.extlinks'] +extensions = ["sphinx.ext.extlinks"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Pulp maven Support' -copyright = u'' +project = u"Pulp maven Support" +copyright = u"" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '2.0a1' +version = "2.0a1" # The full version, including alpha/beta/rc tags. -release = '2.0a1' +release = "2.0a1" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'sphinx_rtd_theme' if sphinx_rtd_theme else 'default' +html_theme = "sphinx_rtd_theme" if sphinx_rtd_theme else "default" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -127,87 +127,85 @@ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' diff --git a/docs/workflows/cache.rst b/docs/workflows/cache.rst new file mode 100644 index 0000000..4a60d3d --- /dev/null +++ b/docs/workflows/cache.rst @@ -0,0 +1,47 @@ +Cache Maven Repository +======================= + +Users can populate their repositories with content from an external sources by syncing +their repository. + +Create a new Maven remote ``bar`` +--------------------------------- + +``$ http POST http://localhost:24817/pulp/api/v3/remotes/maven/maven/ name='bar' url='https://repo1.maven.org/maven2/'`` + +.. code:: json + + { + "_href": "/pulp/api/v3/remotes/maven/maven/2668a20c-3908-4767-b134-531e5145d7b7/" + } + +``$ export REMOTE_HREF=$(http :24817/pulp/api/v3/remotes/maven/maven/ | jq -r '.results[] | select(.name == "bar") | ._href')`` + +Create a Maven Distribution for the Maven Remote +------------------------------------------------ + +``$ http POST http://localhost:24817/pulp/api/v3/distributions/maven/maven/ name='baz' base_path='my/local/maven' remote=$REMOTE_HREF`` + + +.. code:: json + + { + "_href": "/pulp/api/v3/distributions/67baa17e-0a9f-4302-b04a-dbf324d139de/" + } + + +Add Pulp as mirror for Maven +---------------------------- + +.. code:: xml + + + + + pulp-maven-central + Local Maven Central mirror + http://localhost:24816/pulp/content/my/local/maven + central + + + diff --git a/docs/workflows/index.rst b/docs/workflows/index.rst index 966f22f..3f20233 100644 --- a/docs/workflows/index.rst +++ b/docs/workflows/index.rst @@ -28,6 +28,4 @@ set is the hostname and port:: .. toctree:: :maxdepth: 2 - sync - upload - publish-host + cache diff --git a/docs/workflows/publish.rst b/docs/workflows/publish.rst deleted file mode 100644 index 379a482..0000000 --- a/docs/workflows/publish.rst +++ /dev/null @@ -1,57 +0,0 @@ -Publish and Host -================ - -This section assumes that you have a repository with content in it. To do this, see the -:doc:`sync` or :doc:`upload` documentation. - -Create a Publisher ------------------- - -Publishers contain extra settings for how to publish. You can use a maven publisher on any -repository that contains maven content:: - -$ http POST $BASE_ADDR/pulp/api/v3/publishers/maven/ name=bar - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/repositories/foo/publishers/maven/bar/", - ... - } - - -Publish a repository with a publisher -------------------------------------- - -Use the remote object to kick off a publish task by specifying the repository version to publish. -Alternatively, you can specify repository, which will publish the latest version. - -The result of a publish is a publication, which contains all the information needed for a external package manager -like ``pip`` or ``apt-get`` to use. Publications are not consumable until they are hosted by a distribution:: - -$ http POST $BASE_ADDR/pulp/api/v3/publishers/maven/1/publish/ repository=$BASE_ADDR/pulp/api/v3/repositories/1/ - -Response:: - - [ - { - "_href": "http://localhost:24817/pulp/api/v3/tasks/fd4cbecd-6c6a-4197-9cbe-4e45b0516309/", - "task_id": "fd4cbecd-6c6a-4197-9cbe-4e45b0516309" - } - ] - -Host a Publication (Create a Distribution) --------------------------------------------- - -To host a publication, (which makes it consumable by a package manager), users create a distribution which -will serve the associated publication at ``/pulp/content/``:: - -$ http POST $BASE_ADDR/pulp/api/v3/distributions/ name='baz' base_path='foo' publication=$BASE_ADDR/publications/1/ - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/distributions/1/", - ... - } - diff --git a/docs/workflows/sync.rst b/docs/workflows/sync.rst deleted file mode 100644 index 29941db..0000000 --- a/docs/workflows/sync.rst +++ /dev/null @@ -1,91 +0,0 @@ -Synchronize a Repository -======================== - -Users can populate their repositories with content from an external sources by syncing -their repository. - -Create a Repository -------------------- - -Start by creating a new repository named "foo":: - - $ http POST $BASE_ADDR/pulp/api/v3/repositories/ name=foo - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/repositories/1/", - ... - } - - -Create a Remote ---------------- - -Creating a remote object informs Pulp about an external content source. - -``$ http POST $BASE_ADDR/pulp/pulp/api/v3/remotes/maven/ name='bar' url='http://some.url/somewhere/'`` - -.. code:: json - - { - "_href": "http://localhost:24817/pulp/pulp/api/v3/remotes/maven/1/", - ... - } - - -Sync repository foo with remote -------------------------------- - -Use the remote object to kick off a synchronize task by specifying the repository to -sync with. You are telling pulp to fetch content from the remote and add to the repository:: - - $ http POST $BASE_ADDR/pulp/pulp/api/v3/remotes/maven/1/sync/' repository=http://localhost:24817/pulp/api/v3/repositories/1/ - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/tasks/3896447a-2799-4818-a3e5-df8552aeb903/", - "task_id": "3896447a-2799-4818-a3e5-df8552aeb903" - } - -You can follow the progress of the task with a GET request to the task href. Notice that when the -synchroinze task completes, it creates a new version, which is specified in ``created_resources``:: - - $ http GET $BASE_ADDR/pulp/api/v3/tasks/3896447a-2799-4818-a3e5-df8552aeb903/ - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/tasks/3896447a-2799-4818-a3e5-df8552aeb903/", - "_created": "2018-05-01T17:17:46.558997Z", - "created_resources": [ - "http://localhost:24817/pulp/api/v3/repositories/593e2fa9-af64-4d4b-aa7b-7078c96f2443/versions/6/" - ], - "error": null, - "finished_at": "2018-05-01T17:17:47.149123Z", - "non_fatal_errors": [], - "parent": null, - "progress_reports": [ - { - "done": 0, - "message": "Add Content", - "state": "completed", - "suffix": "", - "task": "http://localhost:24817/pulp/api/v3/tasks/3896447a-2799-4818-a3e5-df8552aeb903/", - "total": 0 - }, - { - "done": 0, - "message": "Remove Content", - "state": "completed", - "suffix": "", - "task": "http://localhost:24817/pulp/api/v3/tasks/3896447a-2799-4818-a3e5-df8552aeb903/", - "total": 0 - } - ], - "spawned_tasks": [], - "started_at": "2018-05-01T17:17:46.644801Z", - "state": "completed", - "worker": "http://localhost:24817/pulp/api/v3/workers/eaffe1be-111a-421d-a127-0b8fa7077cf7/" - } diff --git a/docs/workflows/upload.rst b/docs/workflows/upload.rst deleted file mode 100644 index eef1b94..0000000 --- a/docs/workflows/upload.rst +++ /dev/null @@ -1,55 +0,0 @@ -Upload and Manage Content -========================= - -Create a repository -------------------- - -If you don't already have a repository, create one:: - - $ http POST $BASE_ADDR/pulp/api/v3/repositories/ name=foo - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/repositories/1/", - ... - } - - -Upload a file to Pulp ---------------------- - -Each artifact in Pulp represents a file. They can be created during sync or created manually by uploading a file:: - - $ http --form POST $BASE_ADDR/pulp/api/v3/artifacts/ file@./my_content - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/artifacts/1/", - ... - } - - -Create content from an artifact -------------------------------- - -Now that Pulp has the content, its time to make it into a unit of content. - - $ http POST $BASE_ADDR/pulp/api/v3/content/maven/ artifact=http://localhost:24817/pulp/api/v3/artifacts/1/ filename=my_content - -Response:: - - { - "_href": "http://localhost:24817/pulp/api/v3/content/maven/1/", - "_artifact": "http://localhost:24817/pulp/api/v3/artifacts/1/", - "digest": "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c", - "filename": "my-content", - } - -Add content to a repository ---------------------------- - -Once there is a content unit, it can be added and removed and from to repositories:: - -$ http POST $REPO_HREF/pulp/api/v3/repositories/1/versions/ add_content_units:="[\"http://localhost:24817/pulp/api/v3/content/maven/1/\"]" diff --git a/pulp_maven/__init__.py b/pulp_maven/__init__.py index 968806e..dd1221d 100644 --- a/pulp_maven/__init__.py +++ b/pulp_maven/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.1.0b3.dev' +__version__ = "0.1.0b3.dev" -default_app_config = 'pulp_maven.app.PulpMavenPluginAppConfig' +default_app_config = "pulp_maven.app.PulpMavenPluginAppConfig" diff --git a/pulp_maven/app/__init__.py b/pulp_maven/app/__init__.py index 897c616..7ba4a1c 100644 --- a/pulp_maven/app/__init__.py +++ b/pulp_maven/app/__init__.py @@ -4,5 +4,5 @@ class PulpMavenPluginAppConfig(PulpPluginAppConfig): """Entry point for the maven plugin.""" - name = 'pulp_maven.app' - label = 'maven' + name = "pulp_maven.app" + label = "maven" diff --git a/pulp_maven/app/migrations/0001_initial.py b/pulp_maven/app/migrations/0001_initial.py new file mode 100644 index 0000000..8125f9a --- /dev/null +++ b/pulp_maven/app/migrations/0001_initial.py @@ -0,0 +1,74 @@ +# Generated by Django 2.2.3 on 2019-08-04 01:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [("core", "0003_remove_upload_completed")] + + operations = [ + migrations.CreateModel( + name="MavenDistribution", + fields=[ + ( + "basedistribution_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="core.BaseDistribution", + ), + ) + ], + options={"abstract": False}, + bases=("core.basedistribution",), + ), + migrations.CreateModel( + name="MavenRemote", + fields=[ + ( + "remote_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="core.Remote", + ), + ) + ], + options={"abstract": False}, + bases=("core.remote",), + ), + migrations.CreateModel( + name="MavenArtifact", + fields=[ + ( + "content_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="core.Content", + ), + ), + ("group_id", models.CharField(max_length=255)), + ("artifact_id", models.CharField(max_length=255)), + ("version", models.CharField(max_length=255)), + ("filename", models.CharField(max_length=255)), + ], + options={ + "unique_together": {("group_id", "artifact_id", "version", "filename")} + }, + bases=("core.content",), + ), + ] diff --git a/pulp_maven/app/migrations/__init__.py b/pulp_maven/app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pulp_maven/app/models.py b/pulp_maven/app/models.py index dc1696d..1f6e670 100644 --- a/pulp_maven/app/models.py +++ b/pulp_maven/app/models.py @@ -16,7 +16,7 @@ class MavenArtifact(Content): This content type represents a single file in a Maven repository. """ - TYPE = 'artifact' + TYPE = "artifact" group_id = models.CharField(max_length=255, null=False) artifact_id = models.CharField(max_length=255, null=False) @@ -24,7 +24,7 @@ class MavenArtifact(Content): filename = models.CharField(max_length=255, null=False) class Meta: - unique_together = ('group_id', 'artifact_id', 'version', 'filename') + unique_together = ("group_id", "artifact_id", "version", "filename") @staticmethod def init_from_artifact_and_relative_path(artifact, relative_path): @@ -34,17 +34,18 @@ def init_from_artifact_and_relative_path(artifact, relative_path): Args: artifact (:class:`~pulpcore.plugin.models.Artifact`): An instance of an Artifact relative_path (str): Relative path for the artifact in the Project + """ if path.isabs(relative_path): raise ValueError(_("Relative path can't start with '/'.")) - group_id, artifact_id, version, filename =\ - MavenArtifact._get_group_artifact_version_filename(relative_path) + group_id, artifact_id, versn, f_name = MavenArtifact._get_group_artifact_version_filename( + relative_path + ) - return MavenArtifact(group_id=group_id, - artifact_id=artifact_id, - version=version, - filename=filename) + return MavenArtifact( + group_id=group_id, artifact_id=artifact_id, version=versn, filename=f_name + ) @staticmethod def _get_group_artifact_version_filename(relative_path): @@ -61,7 +62,7 @@ def _get_group_artifact_version_filename(relative_path): sub_path, filename = path.split(relative_path) sub_path, version = path.split(sub_path) sub_path, artifact_id = path.split(sub_path) - group_id = sub_path.replace('/', '.') + group_id = sub_path.replace("/", ".") return group_id, artifact_id, version, filename @@ -73,7 +74,7 @@ class MavenRemote(Remote): Define any additional fields for your new importer if needed. """ - TYPE = 'maven' + TYPE = "maven" @staticmethod def get_remote_artifact_content_type(relative_path=None): @@ -88,4 +89,4 @@ class MavenDistribution(BaseDistribution): Distribution for 'maven' content. """ - TYPE = 'maven' + TYPE = "maven" diff --git a/pulp_maven/app/serializers.py b/pulp_maven/app/serializers.py index 46c4192..d7445ef 100644 --- a/pulp_maven/app/serializers.py +++ b/pulp_maven/app/serializers.py @@ -13,25 +13,22 @@ class MavenArtifactSerializer(platform.SingleArtifactContentSerializer): """ group_id = serializers.CharField( - help_text=_("Group Id of the artifact's package."), - read_only=True, + help_text=_("Group Id of the artifact's package."), read_only=True ) artifact_id = serializers.CharField( - help_text=_("Artifact Id of the artifact's package."), - read_only=True, + help_text=_("Artifact Id of the artifact's package."), read_only=True ) version = serializers.CharField( - help_text=_("Version of the artifact's package."), - read_only=True, - ) - filename = serializers.CharField( - help_text=_("Filename of the artifact."), - read_only=True, + help_text=_("Version of the artifact's package."), read_only=True ) + filename = serializers.CharField(help_text=_("Filename of the artifact."), read_only=True) class Meta: fields = platform.SingleArtifactContentSerializer.Meta.fields + ( - 'group_id', 'artifact_id', 'version', 'filename' + "group_id", + "artifact_id", + "version", + "filename", ) model = models.MavenArtifact @@ -62,11 +59,11 @@ class MavenDistributionSerializer(platform.BaseDistributionSerializer): remote = platform.DetailRelatedField( required=False, - help_text=_('Remote that can be used to fetch content when using pull-through caching.'), + help_text=_("Remote that can be used to fetch content when using pull-through caching."), queryset=models.MavenRemote.objects.all(), - allow_null=True + allow_null=True, ) class Meta: - fields = platform.BaseDistributionSerializer.Meta.fields + ('remote',) + fields = platform.BaseDistributionSerializer.Meta.fields + ("remote",) model = models.MavenDistribution diff --git a/pulp_maven/app/viewsets.py b/pulp_maven/app/viewsets.py index 533d9e9..6706050 100644 --- a/pulp_maven/app/viewsets.py +++ b/pulp_maven/app/viewsets.py @@ -10,9 +10,7 @@ class MavenArtifactFilter(core.ContentFilter): class Meta: model = models.MavenArtifact - fields = [ - 'group_id', 'artifact_id', 'version', 'filename' - ] + fields = ["group_id", "artifact_id", "version", "filename"] class MavenArtifactViewSet(core.ContentViewSet): @@ -20,7 +18,7 @@ class MavenArtifactViewSet(core.ContentViewSet): A ViewSet for MavenArtifact. """ - endpoint_name = 'artifact' + endpoint_name = "artifact" queryset = models.MavenArtifact.objects.all() serializer_class = serializers.MavenArtifactSerializer filterset_class = MavenArtifactFilter @@ -31,7 +29,7 @@ class MavenRemoteViewSet(core.RemoteViewSet): A ViewSet for MavenRemote. """ - endpoint_name = 'maven' + endpoint_name = "maven" queryset = models.MavenRemote.objects.all() serializer_class = serializers.MavenRemoteSerializer @@ -41,6 +39,6 @@ class MavenDistributionViewSet(core.BaseDistributionViewSet): ViewSet for Maven Distributions. """ - endpoint_name = 'maven' + endpoint_name = "maven" queryset = models.MavenDistribution.objects.all() serializer_class = serializers.MavenDistributionSerializer diff --git a/pulp_maven/tests/functional/api/test_crud_remotes.py b/pulp_maven/tests/functional/api/test_crud_remotes.py index 0825860..0f35643 100644 --- a/pulp_maven/tests/functional/api/test_crud_remotes.py +++ b/pulp_maven/tests/functional/api/test_crud_remotes.py @@ -1,16 +1,12 @@ # coding=utf-8 """Tests that CRUD maven remotes.""" -from random import choice import unittest from requests.exceptions import HTTPError from pulp_smash import api, config, utils -from pulp_maven.tests.functional.constants import ( - DOWNLOAD_POLICIES, - MAVEN_REMOTE_PATH -) +from pulp_maven.tests.functional.constants import MAVEN_REMOTE_PATH from pulp_maven.tests.functional.utils import skip_if, gen_maven_remote from pulp_maven.tests.functional.utils import set_up_module as setUpModule # noqa:F401 @@ -28,13 +24,13 @@ def test_01_create_remote(self): """Create a remote.""" body = _gen_verbose_remote() type(self).remote = self.client.post(MAVEN_REMOTE_PATH, body) - for key in ('username', 'password'): + for key in ("username", "password"): del body[key] for key, val in body.items(): with self.subTest(key=key): self.assertEqual(self.remote[key], val) - @skip_if(bool, 'remote', False) + @skip_if(bool, "remote", False) def test_02_create_same_name(self): """Try to create a second remote with an identical name. @@ -42,59 +38,57 @@ def test_02_create_same_name(self): `_. """ body = gen_maven_remote() - body['name'] = self.remote['name'] + body["name"] = self.remote["name"] with self.assertRaises(HTTPError): self.client.post(MAVEN_REMOTE_PATH, body) - @skip_if(bool, 'remote', False) + @skip_if(bool, "remote", False) def test_02_read_remote(self): """Read a remote by its href.""" - remote = self.client.get(self.remote['_href']) + remote = self.client.get(self.remote["_href"]) for key, val in self.remote.items(): with self.subTest(key=key): self.assertEqual(remote[key], val) - @skip_if(bool, 'remote', False) + @skip_if(bool, "remote", False) def test_02_read_remotes(self): """Read a remote by its name.""" - page = self.client.get(MAVEN_REMOTE_PATH, params={ - 'name': self.remote['name'] - }) - self.assertEqual(len(page['results']), 1) + page = self.client.get(MAVEN_REMOTE_PATH, params={"name": self.remote["name"]}) + self.assertEqual(len(page["results"]), 1) for key, val in self.remote.items(): with self.subTest(key=key): - self.assertEqual(page['results'][0][key], val) + self.assertEqual(page["results"][0][key], val) - @skip_if(bool, 'remote', False) + @skip_if(bool, "remote", False) def test_03_partially_update(self): """Update a remote using HTTP PATCH.""" body = _gen_verbose_remote() - self.client.patch(self.remote['_href'], body) - for key in ('username', 'password'): + self.client.patch(self.remote["_href"], body) + for key in ("username", "password"): del body[key] - type(self).remote = self.client.get(self.remote['_href']) + type(self).remote = self.client.get(self.remote["_href"]) for key, val in body.items(): with self.subTest(key=key): self.assertEqual(self.remote[key], val) - @skip_if(bool, 'remote', False) + @skip_if(bool, "remote", False) def test_04_fully_update(self): """Update a remote using HTTP PUT.""" body = _gen_verbose_remote() - self.client.put(self.remote['_href'], body) - for key in ('username', 'password'): + self.client.put(self.remote["_href"], body) + for key in ("username", "password"): del body[key] - type(self).remote = self.client.get(self.remote['_href']) + type(self).remote = self.client.get(self.remote["_href"]) for key, val in body.items(): with self.subTest(key=key): self.assertEqual(self.remote[key], val) - @skip_if(bool, 'remote', False) + @skip_if(bool, "remote", False) def test_05_delete(self): """Delete a remote.""" - self.client.delete(self.remote['_href']) + self.client.delete(self.remote["_href"]) with self.assertRaises(HTTPError): - self.client.get(self.remote['_href']) + self.client.get(self.remote["_href"]) class CreateRemoteNoURLTestCase(unittest.TestCase): @@ -109,7 +103,7 @@ def test_all(self): * `Pulp Smash #984 `_ """ body = gen_maven_remote() - del body['url'] + del body["url"] with self.assertRaises(HTTPError): api.Client(config.get_config()).post(MAVEN_REMOTE_PATH, body) @@ -125,10 +119,5 @@ def _gen_verbose_remote(): Note that 'username' and 'password' are write-only attributes. """ attrs = gen_maven_remote() - attrs.update({ - 'password': utils.uuid4(), - 'username': utils.uuid4(), - 'policy': choice(DOWNLOAD_POLICIES), - 'validate': choice((False, True)), - }) + attrs.update({"password": utils.uuid4(), "username": utils.uuid4()}) return attrs diff --git a/pulp_maven/tests/functional/api/test_download_content.py b/pulp_maven/tests/functional/api/test_download_content.py index b47b98f..08fd613 100644 --- a/pulp_maven/tests/functional/api/test_download_content.py +++ b/pulp_maven/tests/functional/api/test_download_content.py @@ -7,24 +7,18 @@ from pulp_smash import api, config, utils from pulp_smash.pulp3.constants import BASE_DISTRIBUTION_PATH, REPO_PATH -from pulp_smash.pulp3.utils import ( - gen_distribution, - gen_repo -) +from pulp_smash.pulp3.utils import gen_distribution, gen_repo -from pulp_maven.tests.functional.utils import ( - gen_maven_remote, - get_maven_content_paths -) +from pulp_maven.tests.functional.utils import gen_maven_remote, get_maven_content_paths from pulp_maven.tests.functional.constants import ( MAVEN_CONTENT_PATH, MAVEN_FIXTURE_URL, - MAVEN_REMOTE_PATH + MAVEN_REMOTE_PATH, ) from pulp_maven.tests.functional.utils import set_up_module as setUpModule # noqa:F401 -MAVEN_DISTRIBUTION_PATH = urljoin(BASE_DISTRIBUTION_PATH, 'maven/maven/') +MAVEN_DISTRIBUTION_PATH = urljoin(BASE_DISTRIBUTION_PATH, "maven/maven/") class DownloadContentTestCase(unittest.TestCase): @@ -54,22 +48,22 @@ def test_all(self): client = api.Client(cfg, api.json_handler) repo = client.post(REPO_PATH, gen_repo()) - self.addCleanup(client.delete, repo['_href']) + self.addCleanup(client.delete, repo["_href"]) body = gen_maven_remote() remote = client.post(MAVEN_REMOTE_PATH, body) - self.addCleanup(client.delete, remote['_href']) + self.addCleanup(client.delete, remote["_href"]) - repo = client.get(repo['_href']) + repo = client.get(repo["_href"]) # Create a distribution. body = gen_distribution() - body['remote'] = remote['_href'] + body["remote"] = remote["_href"] response_dict = client.post(MAVEN_DISTRIBUTION_PATH, body) - dist_task = client.get(response_dict['task']) - distribution_href = dist_task['created_resources'][0] + dist_task = client.get(response_dict["task"]) + distribution_href = dist_task["created_resources"][0] distribution = client.get(distribution_href) - self.addCleanup(client.delete, distribution['_href']) + self.addCleanup(client.delete, distribution["_href"]) # Pick a content unit, and download it from both Pulp Fixtures… unit_path = choice(get_maven_content_paths(repo)) @@ -80,14 +74,14 @@ def test_all(self): # …and Pulp. client.response_handler = api.safe_handler - unit_url = cfg.get_hosts('api')[0].roles['api']['scheme'] - unit_url += '://' + distribution['base_url'] + '/' + unit_url = cfg.get_hosts("content")[0].roles["content"]["scheme"] + unit_url += "://" + distribution["base_url"] + "/" unit_url = urljoin(unit_url, unit_path) pulp_hash = hashlib.sha256(client.get(unit_url).content).hexdigest() self.assertEqual(fixtures_hash, pulp_hash) # Check that Pulp created a MavenArtifact - content_filter_url = MAVEN_CONTENT_PATH + '?filename=custommatcher-1.0-javadoc.jar.sha1' + content_filter_url = MAVEN_CONTENT_PATH + "?filename=custommatcher-1.0-javadoc.jar.sha1" content_unit = client.get(content_filter_url) - self.assertEqual(1, content_unit.json()['count']) + self.assertEqual(1, content_unit.json()["count"]) diff --git a/pulp_maven/tests/functional/constants.py b/pulp_maven/tests/functional/constants.py index 8520a7f..06c5e6e 100644 --- a/pulp_maven/tests/functional/constants.py +++ b/pulp_maven/tests/functional/constants.py @@ -1,20 +1,16 @@ # coding=utf-8 from urllib.parse import urljoin -from pulp_smash.pulp3.constants import ( - BASE_PUBLISHER_PATH, - BASE_REMOTE_PATH, - CONTENT_PATH -) +from pulp_smash.pulp3.constants import BASE_PUBLISHER_PATH, BASE_REMOTE_PATH, CONTENT_PATH -DOWNLOAD_POLICIES = ['on_demand'] +DOWNLOAD_POLICIES = ["on_demand"] -MAVEN_CONTENT_NAME = 'maven.artifact' +MAVEN_CONTENT_NAME = "maven.artifact" -MAVEN_CONTENT_PATH = urljoin(CONTENT_PATH, 'maven/artifact/') +MAVEN_CONTENT_PATH = urljoin(CONTENT_PATH, "maven/artifact/") -MAVEN_REMOTE_PATH = urljoin(BASE_REMOTE_PATH, 'maven/maven/') +MAVEN_REMOTE_PATH = urljoin(BASE_REMOTE_PATH, "maven/maven/") -MAVEN_PUBLISHER_PATH = urljoin(BASE_PUBLISHER_PATH, 'maven/maven/') +MAVEN_PUBLISHER_PATH = urljoin(BASE_PUBLISHER_PATH, "maven/maven/") -MAVEN_FIXTURE_URL = 'https://repo1.maven.org/maven2/' +MAVEN_FIXTURE_URL = "https://repo1.maven.org/maven2/" diff --git a/pulp_maven/tests/functional/utils.py b/pulp_maven/tests/functional/utils.py index 9645e59..c99df6d 100644 --- a/pulp_maven/tests/functional/utils.py +++ b/pulp_maven/tests/functional/utils.py @@ -4,16 +4,14 @@ from unittest import SkipTest from pulp_smash import api, selectors -from pulp_smash.pulp3.constants import ( - REPO_PATH -) +from pulp_smash.pulp3.constants import REPO_PATH from pulp_smash.pulp3.utils import ( gen_remote, gen_repo, get_content, require_pulp_3, require_pulp_plugins, - sync + sync, ) from pulp_maven.tests.functional.constants import ( @@ -27,7 +25,7 @@ def set_up_module(): """Skip tests Pulp 3 isn't under test or if pulp_maven isn't installed.""" require_pulp_3(SkipTest) - require_pulp_plugins({'pulp_maven'}, SkipTest) + require_pulp_plugins({"pulp_maven"}, SkipTest) def gen_maven_remote(**kwargs): @@ -36,9 +34,7 @@ def gen_maven_remote(**kwargs): :param url: The URL of an external content source. """ remote = gen_remote(MAVEN_FIXTURE_URL) - maven_extra_fields = { - **kwargs - } + maven_extra_fields = {**kwargs} remote.update(**maven_extra_fields) return remote @@ -59,10 +55,7 @@ def get_maven_content_unit_paths(repo): # FIXME: The "relative_path" is actually a file path and name # It's just an example -- this needs to be replaced with an implementation that works # for repositories of this content type. - return [ - content_unit['relative_path'] - for content_unit in get_content(repo)[MAVEN_CONTENT_NAME] - ] + return [content_unit["relative_path"] for content_unit in get_content(repo)[MAVEN_CONTENT_NAME]] def gen_maven_content_attrs(artifact): @@ -72,7 +65,7 @@ def gen_maven_content_attrs(artifact): :returns: A semi-random dict for use in creating a content unit. """ # FIXME: Add content specific metadata here. - return {'_artifact': artifact['_href']} + return {"_artifact": artifact["_href"]} def populate_pulp(cfg, url=MAVEN_FIXTURE_URL): @@ -92,10 +85,10 @@ def populate_pulp(cfg, url=MAVEN_FIXTURE_URL): sync(cfg, remote, repo) finally: if remote: - client.delete(remote['_href']) + client.delete(remote["_href"]) if repo: - client.delete(repo['_href']) - return client.get(MAVEN_CONTENT_PATH)['results'] + client.delete(repo["_href"]) + return client.get(MAVEN_CONTENT_PATH)["results"] skip_if = partial(selectors.skip_if, exc=SkipTest) diff --git a/setup.py b/setup.py index 8abe523..1450761 100644 --- a/setup.py +++ b/setup.py @@ -2,39 +2,33 @@ from setuptools import find_packages, setup -requirements = [ - 'pulpcore-plugin~=0.1rc2', -] +requirements = ["pulpcore-plugin~=0.1rc4"] -with open('README.rst') as f: +with open("README.rst") as f: long_description = f.read() setup( - name='pulp-maven', - version='0.1.0b3.dev', - description='pulp-maven plugin for the Pulp Project', + name="pulp-maven", + version="0.1.0b3.dev", + description="pulp-maven plugin for the Pulp Project", long_description=long_description, - license='GPLv2+', - author='Pulp Project Developers', - author_email='pulp-dev@redhat.com', - url='http://www.pulpproject.org/', - python_requires='>=3.6', + license="GPLv2+", + author="Pulp Project Developers", + author_email="pulp-dev@redhat.com", + url="http://www.pulpproject.org/", + python_requires=">=3.6", install_requires=requirements, include_package_data=True, - packages=find_packages(exclude=['pulp_maven.tests']), + packages=find_packages(exclude=["pulp_maven.tests"]), classifiers=( - 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)', - 'Operating System :: POSIX :: Linux', - 'Development Status :: 4 - Beta', - 'Framework :: Django', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: POSIX :: Linux", + "Development Status :: 4 - Beta", + "Framework :: Django", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ), - entry_points={ - 'pulpcore.plugin': [ - 'pulp_maven = pulp_maven:default_app_config', - ] - } + entry_points={"pulpcore.plugin": ["pulp_maven = pulp_maven:default_app_config"]}, ) diff --git a/template_config.yml b/template_config.yml new file mode 100644 index 0000000..7778455 --- /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_maven +plugin_app_label: maven +plugin_snake: pulp_maven +plugin_caps: PULP_MAVEN +plugin_caps_short: MAVEN +plugin_camel: PulpMaven +plugin_camel_short: Maven +plugin_dash: pulp-maven +plugin_dash_short: maven +black: True +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: None +travis_notifications: None + + diff --git a/test_requirements.txt b/test_requirements.txt index de42e81..2f87aa6 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,3 +1,4 @@ +black coverage flake8 flake8-docstrings