Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for multi-plugin repositories #800

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Loading