Skip to content

Commit

Permalink
Updating CI based on plugin-template (#676)
Browse files Browse the repository at this point in the history
No-Issue
  • Loading branch information
fao89 authored Mar 11, 2021
1 parent a2846c0 commit cc7f213
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 33 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ sudo: required
dist: bionic
language: python
python:
# Fedora has 3.6 available (python36.x86_64), but pulp container images
# with it are not being built or published yet.
# - "3.6"
- "3.7"
- "3.6"
env:
global:
# generate manifests parameters
Expand Down
34 changes: 20 additions & 14 deletions .travis/Containerfile.j2
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
FROM {{ ci_base | default("pulp/pulp-ci:latest") }}

{% if s3_test | default(false) %}
# Hacking botocore (https://github.com/boto/botocore/pull/1990)
RUN pip3 install django-storages[boto3]
RUN pip3 install git+https://github.com/fabricio-aguiar/botocore.git@fix-100-continue
{% endif %}
FROM {{ ci_base | default("pulp/pulp-ci-centos:latest") }}

# Add source directories to container
{% for item in plugins %}

# Install {{ item.name }} from {{ item.source }}
{% if item.name == "pulp-certguard" %}
RUN pip3 install python-dateutil rhsm
{% endif %}
{% if item.source.startswith("./") %}
ADD {{ item.source }} {{ item.source }}
{% endif %}
RUN pip3 install {{ item.source }}
{% endfor %}

# Install python packages
# Hacking botocore (https://github.com/boto/botocore/pull/1990)

RUN pip3 install \
{%- if s3_test | default(false) -%}
{{ " " }}django-storages[boto3] git+https://github.com/fabricio-aguiar/botocore.git@fix-100-continue
{%- endif -%}
{%- for item in plugins -%}
{%- if item.name == "pulp-certguard" -%}
{{ " " }}python-dateutil rhsm
{%- endif -%}
{{ " " }}"{{ item.source }}"
{%- endfor %}

RUN mkdir -p /etc/nginx/pulp/
RUN ln /usr/local/lib/python3.7/site-packages/{{ item.name }}/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf || true
{% for item in plugins %}
RUN ln /usr/local/lib/python3.6/site-packages/{{ item.name }}/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf || true
{% endfor %}

ENTRYPOINT ["/init"]
14 changes: 7 additions & 7 deletions .travis/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@

set -mveuo pipefail

COMPONENT_VERSION=$(cat galaxy_ng/app/VERSION)
mkdir .travis/vars || true
echo "---" > .travis/vars/main.yaml
echo "legacy_component_name: galaxy_ng" >> .travis/vars/main.yaml
echo "component_name: galaxy" >> .travis/vars/main.yaml
echo "component_version: '${COMPONENT_VERSION}'" >> .travis/vars/main.yaml

export PRE_BEFORE_INSTALL=$TRAVIS_BUILD_DIR/.travis/pre_before_install.sh
export POST_BEFORE_INSTALL=$TRAVIS_BUILD_DIR/.travis/post_before_install.sh
Expand Down Expand Up @@ -71,7 +75,7 @@ sed -i -e 's/localhost:24817/pulp/g' generate.sh
sed -i -e 's/:24817/pulp/g' generate.sh
cd ..

git clone --depth=1 https://github.com/pulp/pulpcore.git --branch master
git clone --depth=1 https://github.com/pulp/pulpcore.git --branch 3.10

cd pulpcore
if [ -n "$PULPCORE_PR_NUMBER" ]; then
Expand Down Expand Up @@ -110,13 +114,9 @@ if [ -n "$PULP_ANSIBLE_PR_NUMBER" ]; then
fi

# Intall requirements for ansible playbooks
pip install docker netaddr boto3
pip install docker netaddr boto3 ansible

# Install ansible with the boto3 tags to dict fix
# There is a PR for this issue:
# https://github.com/ansible-collections/amazon.aws/pull/37
# Be aware, that the code will have moved to that collection with upcoming releases of ansible
pip install git+https://github.com/mdellweg/ansible.git@fix_boto3_tags_dict
ansible-galaxy collection install amazon.aws

cd galaxy_ng

Expand Down
10 changes: 8 additions & 2 deletions .travis/filter/repr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import, division, print_function
from packaging.version import parse as parse_version

__metaclass__ = type

Expand All @@ -14,12 +15,17 @@ def _repr_filter(value):
return repr(value)


def _canonical_semver_filter(value):
return str(parse_version(value))


# ---- Ansible filters ----
class FilterModule(object):
"""repr filter"""
"""Repr filter."""

def filters(self):
"""Filter associations"""
"""Filter associations."""
return {
"repr": _repr_filter,
"canonical_semver": _canonical_semver_filter,
}
5 changes: 4 additions & 1 deletion .travis/settings.py.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
CONTENT_ORIGIN = "http://pulp:80"
ANSIBLE_API_HOSTNAME = "http://pulp:80"
ANSIBLE_CONTENT_HOSTNAME = "http://pulp:80/pulp/content"
TOKEN_AUTH_DISABLED = True
PRIVATE_KEY_PATH = "/etc/pulp/certs/token_private_key.pem"
PUBLIC_KEY_PATH = "/etc/pulp/certs/token_public_key.pem"
TOKEN_SERVER = "http://pulp:80/token"
TOKEN_SIGNATURE_ALGORITHM = "ES256"

{% if pulp_settings %}
{% for key, value in pulp_settings.items() %}
Expand Down
29 changes: 27 additions & 2 deletions .travis/start_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
become: true

- name: "Create Pulp Bucket"
s3_bucket:
amazon.aws.s3_bucket:
aws_access_key: "{{ minio_access_key }}"
aws_secret_key: "{{ minio_secret_key }}"
s3_url: "http://minio:9000"
Expand All @@ -74,13 +74,38 @@
follow_redirects: none
register: result
until: result.status == 200
retries: 6
retries: 12
delay: 5
rescue:
- name: "Output pulp container log"
command: "docker logs pulp"
failed_when: true

- block:
- name: "Check version of component being tested"
assert:
that:
- (result.json.versions | items2dict(key_name="component", value_name="version"))[component_name] | canonical_semver == (component_version | canonical_semver)
fail_msg: |
Component {{ component_name }} was expected to be installed in version {{ component_version }}.
Instead it is reported as version {{ (result.json.versions | items2dict(key_name="component", value_name="version"))[component_name] }}.
rescue:
- name: "Check version of component being tested (legacy)"
assert:
that:
- (result.json.versions | items2dict(key_name="component", value_name="version"))[legacy_component_name] | canonical_semver == (component_version | canonical_semver)
fail_msg: |
Component {{ legacy_component_name }} was expected to be installed in version {{ component_version }}.
Instead it is reported as version {{ (result.json.versions | items2dict(key_name="component", value_name="version"))[legacy_component_name] }}.
- name: "Set pulp password in .netrc"
copy:
dest: "~/.netrc"
content: |
machine pulp
login admin
password password
- hosts: pulp
gather_facts: false
tasks:
Expand Down
6 changes: 3 additions & 3 deletions .travis/utils.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# This file is meant to be sourced by ci-scripts

PULP_CONTAINER=pulp
PULP_CI_CONTAINER=pulp

# Run a command
cmd_prefix() {
docker exec "$PULP_CONTAINER" "$@"
docker exec "$PULP_CI_CONTAINER" "$@"
}

# Run a command, and pass STDIN
cmd_stdin_prefix() {
docker exec -i "$PULP_CONTAINER" "$@"
docker exec -i "$PULP_CI_CONTAINER" "$@"
}

0 comments on commit cc7f213

Please sign in to comment.