From 16a91e92be7ec0d6e9c8b9136666aaef8bce0c49 Mon Sep 17 00:00:00 2001 From: David Davis Date: Fri, 23 Jul 2021 15:07:08 -0400 Subject: [PATCH] Allow plugins to configure python_version fixes #457 --- CHANGES/457.feature | 1 + README.md | 2 ++ plugin-template | 1 + templates/github/.ci/ansible/Containerfile.j2.copy | 3 ++- templates/github/.github/workflows/ci.yml.j2 | 6 +++--- templates/github/.github/workflows/nightly.yml.j2 | 6 +++--- templates/github/.github/workflows/release.yml.j2 | 2 +- templates/github/.github/workflows/scripts/install.sh.j2 | 4 ++++ templates/github/.github/workflows/scripts/script.sh.j2 | 2 +- 9 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 CHANGES/457.feature diff --git a/CHANGES/457.feature b/CHANGES/457.feature new file mode 100644 index 00000000..fb56cbb6 --- /dev/null +++ b/CHANGES/457.feature @@ -0,0 +1 @@ +Added python_version option. diff --git a/README.md b/README.md index 3462dea0..bba84f20 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/plugin-template b/plugin-template index 9de1ba2d..900ac2ec 100755 --- a/plugin-template +++ b/plugin-template @@ -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, diff --git a/templates/github/.ci/ansible/Containerfile.j2.copy b/templates/github/.ci/ansible/Containerfile.j2.copy index aa0f608b..de47e4da 100644 --- a/templates/github/.ci/ansible/Containerfile.j2.copy +++ b/templates/github/.ci/ansible/Containerfile.j2.copy @@ -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 plugin_path="$(pip show {{ item.name }} | sed -n -e "s/Location: //p")/{{ item.name }}" +RUN ln "$plugin_path/app/webserver_snippets/nginx.conf /etc/nginx/pulp/{{ item.name }}.conf" || true {% endfor %} ENTRYPOINT ["/init"] diff --git a/templates/github/.github/workflows/ci.yml.j2 b/templates/github/.github/workflows/ci.yml.j2 index 384566a2..8b251c4f 100644 --- a/templates/github/.github/workflows/ci.yml.j2 +++ b/templates/github/.github/workflows/ci.yml.j2 @@ -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 @@ -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 @@ -185,7 +185,7 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "{{ python_version }}" - name: Install httpie run: | diff --git a/templates/github/.github/workflows/nightly.yml.j2 b/templates/github/.github/workflows/nightly.yml.j2 index 339f617e..629c5729 100644 --- a/templates/github/.github/workflows/nightly.yml.j2 +++ b/templates/github/.github/workflows/nightly.yml.j2 @@ -40,7 +40,7 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "{{ python_version }}" - name: Install httpie run: | @@ -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: @@ -263,7 +263,7 @@ jobs: - uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "{{ python_version }}" - name: Install httpie run: | diff --git a/templates/github/.github/workflows/release.yml.j2 b/templates/github/.github/workflows/release.yml.j2 index 7b5b6d6a..bd9d929f 100644 --- a/templates/github/.github/workflows/release.yml.j2 +++ b/templates/github/.github/workflows/release.yml.j2 @@ -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 diff --git a/templates/github/.github/workflows/scripts/install.sh.j2 b/templates/github/.github/workflows/scripts/install.sh.j2 index 54263069..3ea6ce3a 100755 --- a/templates/github/.github/workflows/scripts/install.sh.j2 +++ b/templates/github/.github/workflows/scripts/install.sh.j2 @@ -114,7 +114,11 @@ VARSYAML cat >> vars/main.yaml << VARSYAML pulp_settings: {{ pulp_settings | tojson }} pulp_scheme: {{ pulp_scheme }} +{%- if python_version == "3.6" -%} +pulp_container_tag: python36 +{%- else -%} pulp_container_tag: {{ 'https' if pulp_scheme == 'https' else 'latest' }} +{%- endif -%} VARSYAML {%- if docker_fixtures %} diff --git a/templates/github/.github/workflows/scripts/script.sh.j2 b/templates/github/.github/workflows/scripts/script.sh.j2 index b59426bd..b2e641d8 100755 --- a/templates/github/.github/workflows/scripts/script.sh.j2 +++ b/templates/github/.github/workflows/scripts/script.sh.j2 @@ -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' %}