Skip to content

Commit

Permalink
Enable PR checkout from repos outside pulp org
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Apr 5, 2021
1 parent 849c004 commit cc3b8f5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES/8510.feature
@@ -0,0 +1 @@
Enable PR checkout from repos outside pulp org
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -47,9 +47,11 @@ You can edit them according to your needs to control subsequent calls to `plugin
The following settings are stored in `template_config.yml`.

```bash
additional_plugins A list with additional plugins to be installed on Github Actions.
additional_repos A list with additional repos to be installed on Github Actions.
Each item in the list is a dict with the following fields:
name: the name of the plugin
bindings (optional): boolean whether or not generate bindings
org (optional): github organization
branch: the git branch of the plugin. applies to non-tagged GHA jobs, such as PRs & cron jobs.
pip_version_specifier: A pip version specifier for when the gets installed from PyPI.
Applies to TAGGED (release) jobs.
Expand Down
2 changes: 1 addition & 1 deletion plugin-template
Expand Up @@ -16,7 +16,7 @@ from jinja2 import Environment, FileSystemLoader


DEFAULT_SETTINGS = {
'additional_plugins': [],
'additional_repos': [],
'black': True,
'check_commit_message': True,
'check_gettext': True,
Expand Down
Expand Up @@ -50,12 +50,15 @@ fi

if [ "$GITHUB_EVENT_NAME" = "pull_request" ] || [ "${BRANCH_BUILD}" = "1" -a "${BRANCH}" != "{{ plugin_default_branch }}" ]
then
{%- for repository in ["pulpcore", "pulp-smash", "pulp-openapi-generator", "pulp-cli"] + additional_plugins | map(attribute="name") | list %}
{%- for repository in ["pulpcore", "pulp-smash", "pulp-openapi-generator", "pulp-cli"] %}
export {{ repository | upper | replace("-", "_") }}_PR_NUMBER=$(echo $COMMIT_MSG | grep -oP 'Required\ PR:\ https\:\/\/github\.com\/pulp\/{{ repository }}\/pull\/(\d+)' | awk -F'/' '{print $7}')
{%- endfor %}
{%- 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
else
{%- for repository in ["pulpcore", "pulp-smash", "pulp-openapi-generator", "pulp-cli"] + additional_plugins | map(attribute="name") | list %}
{%- 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=
Expand Down Expand Up @@ -115,7 +118,7 @@ fi
pip install --upgrade --force-reinstall ./pulp-smash
{% endif %}

{%- for plugin in additional_plugins %}
{%- for plugin in additional_repos %}

git clone --depth=1 https://github.com/{{plugin.org | default("pulp")}}/{{ plugin.name }}.git --branch {{ plugin.branch }}
if [ -n "${{ plugin.name | upper | replace("-", "_") }}_PR_NUMBER" ]; then
Expand Down
8 changes: 4 additions & 4 deletions templates/github/.github/workflows/scripts/install.sh.j2
Expand Up @@ -33,7 +33,7 @@ cd .ci/ansible/
TAG=ci_build

{#- For pulpcore, and any other repo that might check out some plugin PR #}
{%- for item in additional_plugins %}
{%- for item in additional_repos %}

if [ -e $REPO_ROOT/../{{ item.name }} ]; then
{{ item.name | upper | replace("-", "_") }}=./{{ item.name }}
Expand All @@ -60,7 +60,7 @@ plugins:
source: pulpcore{{ pulpcore_pip_version_specifier | default(omit, true) }}
- name: {{ plugin_name }}
source: "${PLUGIN_NAME}"
{%- for item in additional_plugins %}
{%- for item in additional_repos %}
- name: {{ item.name }}
source: {{ item.name }}{{ item.pip_version_specifier | default(omit, true) }}
{%- endfor %}
Expand All @@ -78,7 +78,7 @@ image:
plugins:
- name: {{ plugin_name }}
source: "${PLUGIN_NAME}"
{%- for item in additional_plugins %}
{%- for item in additional_repos %}
- name: {{ item.name }}
source: ${{ item.name|upper| replace("-", "_") }}
{%- endfor %}
Expand All @@ -99,7 +99,7 @@ image:
plugins:
- name: pulpcore
source: ./pulpcore
{%- for item in additional_plugins %}
{%- for item in additional_repos %}
- name: {{ item.name }}
source: ${{ item.name|upper| replace("-", "_") }}
{%- endfor %}
Expand Down
2 changes: 1 addition & 1 deletion templates/github/.github/workflows/scripts/script.sh.j2
Expand Up @@ -50,7 +50,7 @@ pip install ./pulpcore-client
./generate.sh {{ plugin_snake }} python
pip install ./{{ plugin_snake }}-client
{%- endif %}
{%- for item in additional_plugins %}
{%- for item in additional_repos if item.bindings | default(true) %}
./generate.sh {{ item.name | replace("-", "_") }} python
pip install ./{{ item.name | replace("-", "_") }}-client
{%- endfor %}
Expand Down

0 comments on commit cc3b8f5

Please sign in to comment.