Skip to content

Commit

Permalink
Account for multi-plugin repositories
Browse files Browse the repository at this point in the history
This adds a `plugin` list to the template config. For "usual" plugins
it's populated automatically.

[noissue]
  • Loading branch information
mdellweg committed Nov 21, 2023
1 parent 664ee4a commit 60e9b64
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 161 deletions.
31 changes: 15 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
# For more info visit https://github.com/pulp/plugin_template

---
name: Build
name: "Build"
on:
workflow_call:

defaults:
run:
working-directory: "pulp_catdog"

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
working-directory: pulp_catdog
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v4
with:
path: plugin_template
path: "plugin_template"
# We need the full history for bootstrapping
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Bootstrap catdog plugin
working-directory: plugin_template
- name: "Bootstrap catdog plugin"
working-directory: "plugin_template"
run: |
.ci/bootstrap_catdog.sh
Expand All @@ -39,13 +39,12 @@ jobs:
echo ::group::PYDEPS
pip install packaging wheel
echo ::endgroup::
- name: Build package
run: python3 setup.py sdist bdist_wheel --python-tag py3
- name: "Build package"
run: "python3 setup.py sdist bdist_wheel --python-tag py3"
- name: 'Upload Package whl'
uses: actions/upload-artifact@v3
uses: "actions/upload-artifact@v3"
with:
name: plugin_package
# Careful this is boostrapped in a subdirectory
path: pulp_catdog/dist/
if-no-files-found: error
name: "plugin_package"
path: "pulp_catdog/dist/"
if-no-files-found: "error"
retention-days: 5
21 changes: 10 additions & 11 deletions .github/workflows/bootstrap.yaml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true

defaults:
run:
working-directory: "pulp_catdog"

jobs:

ready-to-ship:
runs-on: ubuntu-latest
defaults:
run:
working-directory: pulp_catdog

steps:
- uses: actions/checkout@v4
with:
path: plugin_template
path: "plugin_template"
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Bootstrap catdog plugin
working-directory: plugin_template
- name: "Bootstrap catdog plugin"
working-directory: "plugin_template"
run: |
.ci/bootstrap_catdog.sh
Expand All @@ -39,10 +39,6 @@ jobs:
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
GITHUB_BRANCH: ${{ github.head_ref }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }}
run: sh .github/workflows/scripts/check_commit.sh
Expand All @@ -60,6 +56,9 @@ jobs:
needs: build
uses: "./.github/workflows/test.yml"
deprecations:
defaults:
run:
working-directory: "."
runs-on: ubuntu-latest
if: github.base_ref == 'main'
needs: test
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
schedule:
- cron: '37 1 * * 6'

concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@
# For more info visit https://github.com/pulp/plugin_template

---
name: Lint
name: "Lint"
on:
workflow_call:

defaults:
run:
working-directory: "pulp_catdog"

jobs:
lint:
runs-on: ubuntu-latest

defaults:
run:
working-directory: pulp_catdog

steps:
- uses: actions/checkout@v4
with:
path: plugin_template
path: "plugin_template"
# We need the full history for bootstrapping
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Lint plugin_template
working-directory: plugin_template
- name: "Lint plugin_template"
working-directory: "plugin_template"
run: |
pip3 install black flake8
black --version
black --check --diff plugin-template utils.py
flake8 plugin-template utils.py
- name: Bootstrap catdog plugin
working-directory: plugin_template
- name: "Bootstrap catdog plugin"
working-directory: "plugin_template"
run: |
.ci/bootstrap_catdog.sh
Expand Down
92 changes: 59 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
# For more info visit https://github.com/pulp/plugin_template

---
name: Test
name: "Test"
on:
workflow_call:

defaults:
run:
working-directory: "pulp_catdog"

jobs:
test:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
Expand All @@ -29,14 +33,10 @@ jobs:
deprecations-s3: ${{ steps.deprecations.outputs.deprecations-s3 }}
deprecations-lowerbounds: ${{ steps.deprecations.outputs.deprecations-lowerbounds }}

defaults:
run:
working-directory: pulp_catdog

steps:
- uses: actions/checkout@v4
with:
path: plugin_template
path: "plugin_template"
# We need the full history for bootstrapping
fetch-depth: 0

Expand All @@ -51,18 +51,23 @@ jobs:
# Below this line we include the steps of the ci workflow of the generated plugin

- uses: actions/download-artifact@v3
- uses: actions/checkout@v4
with:
name: plugin_package
# Careful this is boostrapped in a subdirectory
path: pulp_catdog/dist/
fetch-depth: 1
repository: "pulp/pulp-openapi-generator"
path: "pulp-openapi-generator"

- uses: "actions/download-artifact@v3"
with:
name: "plugin_package"
path: "pulp_catdog/dist/"

- name: Install httpie
run: |
echo ::group::HTTPIE
pip install httpie
echo ::endgroup::
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/.ci/assets/httpie/" >> $GITHUB_ENV
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_catdog/.ci/assets/httpie/" >> $GITHUB_ENV
- name: Set environment variables
run: |
Expand All @@ -74,23 +79,19 @@ jobs:
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
GITHUB_BRANCH: ${{ github.head_ref }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }}
- uses: ruby/setup-ruby@v1
if: ${{ env.TEST == 'pulp' }}
with:
ruby-version: "2.6"

- name: Install
run: .github/workflows/scripts/install.sh
shell: bash
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
GITHUB_BRANCH: ${{ github.head_ref }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }}

Expand All @@ -100,36 +101,61 @@ jobs:
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
GITHUB_BRANCH: ${{ github.head_ref }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }}
REDIS_DISABLED: ${{ contains('s3', matrix.env.TEST) }}

- name: Setting secrets
if: github.event_name != 'pull_request'
run: python3 .github/workflows/scripts/secrets.py "$SECRETS_CONTEXT"
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
- name: Install Python client
run: .github/workflows/scripts/install_python_client.sh
shell: bash
- name: Install Ruby client
if: ${{ env.TEST == 'pulp' }}
run: .github/workflows/scripts/install_ruby_client.sh
shell: bash

- name: Script
run: .github/workflows/scripts/script.sh
shell: bash
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
GITHUB_BRANCH: ${{ github.head_ref }}
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }}

- name: Extract Deprecations from Logs
id: deprecations
run: echo deprecations-${{ matrix.env.TEST }}=$(docker logs pulp 2>&1 | grep -i pulpcore.deprecation | base64 -w 0) >> $GITHUB_OUTPUT
- name: Upload python client packages
if: ${{ env.TEST == 'pulp' }}
uses: actions/upload-artifact@v3
with:
name: "python-client.tar"
path: "pulp_catdog/catdog-python-client.tar"
if-no-files-found: "error"
retention-days: 5

- name: Upload python client docs
if: ${{ env.TEST == 'pulp' }}
uses: actions/upload-artifact@v3
with:
name: "python-client-docs.tar"
path: "pulp_catdog/catdog-python-client-docs.tar"
if-no-files-found: "error"
retention-days: 5
- name: Upload Ruby client
if: ${{ env.TEST == 'pulp' }}
uses: actions/upload-artifact@v3
with:
name: "ruby-client.tar"
path: "pulp_catdog/catdog-ruby-client.tar"
if-no-files-found: "error"
retention-days: 5
- name: Upload built docs
if: ${{ env.TEST == 'docs' }}
uses: actions/upload-artifact@v3
with:
name: "docs.tar"
path: "pulp_catdog/docs/docs.tar"

- name: Logs
if: always()
Expand Down
6 changes: 6 additions & 0 deletions plugin-template
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ DEFAULT_SETTINGS = {
"plugin_app_label": None,
"plugin_default_branch": "main",
"plugin_name": None,
"plugins": None,
"post_job_template": None,
"pre_job_template": None,
"publish_docs_to_pulpprojectdotorg": False,
Expand Down Expand Up @@ -249,6 +250,10 @@ def main():
for key in set(config.keys()) - set(DEFAULT_SETTINGS.keys()):
config.pop(key)
write_new_config = True
if config["plugins"] is None:
config["plugins"] = [
{"name": config["plugin_name"], "app_label": config["plugin_app_label"]}
]
print(
"\nLoaded plugin template config from "
"{path}/template_config.yml.\n".format(path=plugin_root_dir)
Expand Down Expand Up @@ -470,6 +475,7 @@ def generate_config(plugin_name, plugin_app_label):
config = DEFAULT_SETTINGS.copy()
config["plugin_name"] = plugin_name
config["plugin_app_label"] = plugin_app_label
config["plugins"] = [{"name": plugin_name, "app_label": plugin_app_label}]
return config


Expand Down
9 changes: 8 additions & 1 deletion templates/github/.github/workflows/ci.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ concurrency:
group: {{ '${{ github.ref_name }}-${{ github.workflow }}' }}
cancel-in-progress: true

defaults:
run:
working-directory: "{{ plugin_name }}"

jobs:
{% if pre_job_template -%}{{ " " | indent }}{% include pre_job_template.path %}{%- endif %}

{%- if check_commit_message or lint_requirements %}
ready-to-ship:
runs-on: ubuntu-latest
steps:
{{ checkout(0) | indent(6) }}
{{ checkout(depth=0, path=plugin_name) | indent(6) }}
{{ setup_python() | indent(6) }}
{% if check_commit_message -%}
- name: Install requirements
Expand Down Expand Up @@ -55,6 +59,9 @@ jobs:

{%- if test_deprecations %}
deprecations:
defaults:
run:
working-directory: "."
runs-on: ubuntu-latest
if: github.base_ref == '{{ plugin_default_branch }}'
needs: test
Expand Down
Loading

0 comments on commit 60e9b64

Please sign in to comment.