Skip to content

Commit

Permalink
Allow plugins to configure python_version
Browse files Browse the repository at this point in the history
fixes pulp#457
  • Loading branch information
David Davis committed Jul 23, 2021
1 parent 72ba7e7 commit 3271e88
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES/457.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added python_version option.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ The following settings are stored in `template_config.yml`.
is required unless deploy_client_to_pypi and deploy_daily_client_to_pypi
and deploy_to_pypi are specified.

python_version Python version to use in the CI. Currently only 3.6 and 3.8 are supported.

redmine_project A string that corresponds to the redmine identifier for the repo's project.
This is used during commit validation to make sure the commit is attached to
an issue in the correct project.
Expand Down
1 change: 1 addition & 0 deletions plugin-template
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ DEFAULT_SETTINGS = {
'pulpprojectdotorg_key_id': None,
'pydocstyle': True,
'pypi_username': None,
'python_version': "3.8",
'redmine_project': None,
'release_user': 'pulpbot',
'sync_ci': True,
Expand Down
3 changes: 2 additions & 1 deletion templates/github/.ci/ansible/Containerfile.j2.copy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ RUN pip3 install \

RUN mkdir -p /etc/nginx/pulp/
{% for item in plugins %}
RUN ln /usr/local/lib/python3.8/site-packages/{{ item.name }}/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf || true
RUN export {{ item.name }}_PATH="$(pip show {{ item.name }} | sed -n -e "s/Location: //p")/{{ item.name }}"
RUN ln ${{ item.name }}_PATH/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf || true
{% endfor %}

ENTRYPOINT ["/init"]
6 changes: 3 additions & 3 deletions templates/github/.github/workflows/ci.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

# dev_requirements contains tools needed for flake8, etc.
- name: Install requirements
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

{%- if test_bindings %}
- uses: actions/setup-ruby@v1
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

- name: Install httpie
run: |
Expand Down
6 changes: 3 additions & 3 deletions templates/github/.github/workflows/nightly.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

- name: Install httpie
run: |
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

- uses: actions/setup-ruby@v1
with:
Expand Down Expand Up @@ -263,7 +263,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

- name: Install httpie
run: |
Expand Down
6 changes: 3 additions & 3 deletions templates/github/.github/workflows/release.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

- name: Install python dependencies
run: |
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

{%- if test_bindings or deploy_client_to_rubygems %}
- uses: actions/setup-ruby@v1
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "{{ python_version }}"

- uses: actions/setup-ruby@v1
with:
Expand Down
11 changes: 9 additions & 2 deletions templates/github/.github/workflows/scripts/before_install.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ echo "legacy_component_name: {{ plugin_snake }}" >> .ci/ansible/vars/main.yaml
echo "component_name: {{ plugin_app_label }}" >> .ci/ansible/vars/main.yaml
echo "component_version: '${COMPONENT_VERSION}'" >> .ci/ansible/vars/main.yaml

{% if python_version == '3.6' %}
echo "ci_base: pulp/pulp-ci-centos:python36" >> .ci/ansible/vars/main.yaml
{% endif %}

export PRE_BEFORE_INSTALL=$PWD/.github/workflows/scripts/pre_before_install.sh
export POST_BEFORE_INSTALL=$PWD/.github/workflows/scripts/post_before_install.sh

Expand All @@ -68,12 +72,15 @@ then
{%- for item in additional_repos %}
export {{ item.name | upper | replace("-", "_") }}_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/{{item.org | default("pulp")}}\/{{ item.name }}\/pull\/(\d+)' | awk -F'/' '{print $7}')
{%- endfor %}
echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p' >> .ci/ansible/vars/main.yaml
export CI_BASE_IMAGE=$(echo $COMMIT_MSG | sed -n -e 's/.*CI Base Image:\s*\([-_/[:alnum:]]*:[-_[:alnum:]]*\).*/ci_base: "\1"/p')
if [[ ! -z "$CI_BASE_IMAGE" ]]; then
sed -i '/ci_base:/d' .ci/ansible/vars/main.yml
echo $CI_BASE_IMAGE >> .ci/ansible/vars/main.yaml
fi
else
{%- for repository in ["pulpcore", "pulp-smash", "pulp-openapi-generator", "pulp-cli"] + additional_repos | map(attribute="name") | list %}
export {{ repository | upper | replace("-", "_") }}_PR_NUMBER=
{%- endfor %}
export CI_BASE_IMAGE=
fi


Expand Down
2 changes: 1 addition & 1 deletion templates/github/.github/workflows/scripts/script.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ echo "Checking for uncommitted migrations..."
cmd_prefix bash -c "django-admin makemigrations --check --dry-run"

# Run unit tests.
cmd_prefix bash -c "PULP_DATABASES__default__USER=postgres django-admin test --noinput /usr/local/lib/python3.8/site-packages/{{ plugin_snake }}/tests/unit/"
cmd_prefix bash -c "PULP_DATABASES__default__USER=postgres django-admin test --noinput /usr/local/lib/python{{ python_version }}/site-packages/{{ plugin_snake }}/tests/unit/"

# Run functional tests
{%- if plugin_name == 'pulpcore' %}
Expand Down

0 comments on commit 3271e88

Please sign in to comment.