Skip to content

Commit

Permalink
update plugin template files (ansible#2087)
Browse files Browse the repository at this point in the history
* Update plugin template files.
* Debug?
* Debug?
* Fix commit check task.
* Fix yamllint errors on some workflow files.
* Fix more workflow files.
* This is the only way to make this work.
* Twine insists on having a long_description now.
* Add new required file?
* Need to cd to the parent first.
* Fix tdd script indexerror.

No-Issue


Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner authored Feb 29, 2024
1 parent 8d6fce2 commit 9ca7aa4
Show file tree
Hide file tree
Showing 49 changed files with 1,011 additions and 1,005 deletions.
21 changes: 21 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[bumpversion]
current_version = 4.10.0dev
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+))?
serialize =
{major}.{minor}.{patch}.{release}
{major}.{minor}.{patch}

[bumpversion:part:release]
optional_value = prod
first_value = dev
values =
dev
prod

[bumpversion:file:./galaxy_ng/app/__init__.py]

[bumpversion:file:./setup.py]

# [bumpversion:file:./docs/conf.py]
22 changes: 8 additions & 14 deletions .ci/ansible/Containerfile.j2
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
FROM {{ ci_base | default("ghcr.io/pulp/pulp-ci-centos:" + pulp_container_tag) }}
FROM {{ ci_base | default(pulp_default_container) }}

# Add source directories to container
{% for item in plugins %}
{% if item.source.startswith("./") or item.ci_requirements | default(false) %}
ADD ./{{ item.name }} ./{{ item.name }}
{% endif %}
{% endfor %}

# Install python packages
# S3 botocore needs to be patched to handle responses from minio during 0-byte uploads
# Hacking botocore (https://github.com/boto/botocore/pull/1990)

RUN pip3 install
{%- for item in plugins -%}
{%- if item.name == "pulp-certguard" -%}
{{ " " }}python-dateutil rhsm
{%- endif -%}
{{ " " }}{{ item.source }}
{%- if item.name == "pulpcore" -%}
{%- if s3_test | default(false) -%}
[s3]
{%- elif azure_test | default(false) -%}
[azure]
{%- elif gcp_test | default(false) -%}
[google]
{{ " " }}git+https://github.com/gerrod3/botocore.git@fix-100-continue
{%- endif -%}
{%- for item in plugins -%}
{{ " " }}{{ item.source }}
{%- if item.lowerbounds | default(false) -%}
{{ " " }}-c ./{{ item.name }}/lowerbounds_constraints.txt
{%- endif -%}
{%- if item.ci_requirements | default(false) -%}
{{ " " }}-r ./{{ item.name }}/ci_requirements.txt
Expand Down
13 changes: 8 additions & 5 deletions .ci/scripts/check_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main():
"--branches",
default="supported",
help="A comma separated list of branches to check for releases. Can also use keyword: "
"'supported'. Defaults to 'supported', see `ci_update_branches` in "
"'supported'. Defaults to 'supported', see `supported_release_branches` in "
"`plugin_template.yml`.",
)
opts = parser.parse_args()
Expand All @@ -46,12 +46,15 @@ def main():
if branches == "supported":
with open(f"{d}/template_config.yml", mode="r") as f:
tc = yaml.safe_load(f)
branches = tc["ci_update_branches"]
branches.append(DEFAULT_BRANCH)
branches = set(tc["supported_release_branches"])
latest_release_branch = tc["latest_release_branch"]
if latest_release_branch is not None:
branches.add(latest_release_branch)
branches.add(DEFAULT_BRANCH)
else:
branches = branches.split(",")
branches = set(branches.split(","))

if diff := set(branches) - set(available_branches):
if diff := branches - set(available_branches):
print(f"Supplied branches contains non-existent branches! {diff}")
exit(1)

Expand Down
8 changes: 5 additions & 3 deletions .ci/scripts/collect_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
CHANGELOG_FILE = tc_settings.get("filename", "NEWS.rst")
START_STRING = tc_settings.get(
"start_string",
"<!-- towncrier release notes start -->\n"
if CHANGELOG_FILE.endswith(".md")
else ".. towncrier release notes start\n",
(
"<!-- towncrier release notes start -->\n"
if CHANGELOG_FILE.endswith(".md")
else ".. towncrier release notes start\n"
),
)
TITLE_FORMAT = tc_settings.get("title_format", "{name} {version} ({project_date})")

Expand Down
7 changes: 4 additions & 3 deletions .github/post-job-template.yml.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

update_manifest:
update_manifest:
runs-on: ubuntu-latest
needs: test
steps:
Expand All @@ -15,5 +14,7 @@
env:
GITHUB_PULL_REQUEST: {{ "${{ github.event.number }}" }}
MANIFEST_PASSPHRASE: {{ "${{ secrets.MANIFEST_PASSPHRASE }}" }}
run: .github/workflows/scripts/update_manifest.sh
shell: bash
run: |
cd ..
.github/workflows/scripts/update_manifest.sh
2 changes: 2 additions & 0 deletions .github/pre-job-template.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ check_commit:
START_COMMIT: {{ "${{ github.event.before }}" }}
END_COMMIT: {{ "${{ github.event.after }}" }}
run: |
cd ..
python .ci/scripts/validate_commit_message_custom.py

lint_po:
Expand All @@ -24,5 +25,6 @@ check_commit:
uses: actions/checkout@v2

- run: |
cd ..
pip install lint-po
lint-po ./galaxy_ng/locale/*/LC_MESSAGES/*.po
2 changes: 1 addition & 1 deletion .github/template_gitref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021.08.26-251-g45d399d
2021.08.26-316-g69ef1f6
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github galaxy_ng' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

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

defaults:
run:
working-directory: "galaxy_ng"

jobs:
build:
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v4"
with:
fetch-depth: 1
path: "galaxy_ng"
- uses: "actions/setup-python@v4"
with:
python-version: "3.11"
- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install packaging twine wheel
echo ::endgroup::
- name: "Build package"
run: |
python3 setup.py sdist bdist_wheel --python-tag py3
twine check dist/*
- name: "Upload Package whl"
uses: "actions/upload-artifact@v3"
with:
name: "plugin_package"
path: "galaxy_ng/dist/"
if-no-files-found: "error"
retention-days: 5
126 changes: 63 additions & 63 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,66 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4

- name: Get galaxy_ng package version
shell: bash
run: echo "galaxy_ng_version=$(python3 setup.py --version)" >> $GITHUB_ENV

- name: Validate tag and galaxy_ng version match
shell: bash
if: env.galaxy_ng_version != github.ref_name
run: |
echo "::error::Tag ${{ github.ref_name }} and galaxy_ng version ${{ env.galaxy_ng_version }} doesn't match."
exit 1
- name: Update apt
run: sudo apt -y update

- name: Install LDAP requirements
run: sudo apt-get install -y libsasl2-dev libldap2-dev libssl-dev build-essential gettext python-setuptools

- name: Upgrade pip
run: pip install pip --upgrade

- name: Install galaxy_ng editable
run: pip install -e .

# set variable for the next step, so only versions higher than 4.4 gets translated
# 4.2 and 4.3 don't support translations
- name: Check galaxy_ng version for translations
shell: bash
id: version_check
run: |
is_translatable=$(python -c 'from pkg_resources import parse_version; cmp_res = parse_version("${{ env.galaxy_ng_version }}") >= parse_version("4.4"); print(cmp_res)')
echo "is_translatable=$is_translatable" >> $GITHUB_OUTPUT
- name: Build API translations
shell: bash
run: "django-admin compilemessages"
if: steps.version_check.outputs.is_translatable == 'True'

- name: Check if UI has corresponding tag
shell: bash
run: |
status_code=$(curl -LI https://api.github.com/repos/ansible/ansible-hub-ui/releases/tags/${{ env.galaxy_ng_version }} -o /dev/null -w '%{http_code}\n' -s)
if [ $status_code == "404" ]
then
echo "::error::Corresponding tag ${{ env.galaxy_ng_version }} for ansible-hub-ui not found."
exit 1
fi
- name: Build galaxy_ng python packages
run: "python3 setup.py sdist bdist_wheel"

- name: Install twine
run: "pip install twine"

- name: Publish galaxy_ng to PyPI
run: "python3 -m twine upload dist/*"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_RELEASE_TOKEN }}
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4

- name: Get galaxy_ng package version
shell: bash
run: echo "galaxy_ng_version=$(python3 setup.py --version)" >> $GITHUB_ENV

- name: Validate tag and galaxy_ng version match
shell: bash
if: env.galaxy_ng_version != github.ref_name
run: |
echo "::error::Tag ${{ github.ref_name }} and galaxy_ng version ${{ env.galaxy_ng_version }} doesn't match."
exit 1
- name: Update apt
run: sudo apt -y update

- name: Install LDAP requirements
run: sudo apt-get install -y libsasl2-dev libldap2-dev libssl-dev build-essential gettext python-setuptools

- name: Upgrade pip
run: pip install pip --upgrade

- name: Install galaxy_ng editable
run: pip install -e .

# set variable for the next step, so only versions higher than 4.4 gets translated
# 4.2 and 4.3 don't support translations
- name: Check galaxy_ng version for translations
shell: bash
id: version_check
run: |
is_translatable=$(python -c 'from pkg_resources import parse_version; cmp_res = parse_version("${{ env.galaxy_ng_version }}") >= parse_version("4.4"); print(cmp_res)')
echo "is_translatable=$is_translatable" >> $GITHUB_OUTPUT
- name: Build API translations
shell: bash
run: "django-admin compilemessages"
if: steps.version_check.outputs.is_translatable == 'True'

- name: Check if UI has corresponding tag
shell: bash
run: |
status_code=$(curl -LI https://api.github.com/repos/ansible/ansible-hub-ui/releases/tags/${{ env.galaxy_ng_version }} -o /dev/null -w '%{http_code}\n' -s)
if [ $status_code == "404" ]
then
echo "::error::Corresponding tag ${{ env.galaxy_ng_version }} for ansible-hub-ui not found."
exit 1
fi
- name: Build galaxy_ng python packages
run: "python3 setup.py sdist bdist_wheel"

- name: Install twine
run: "pip install twine"

- name: Publish galaxy_ng to PyPI
run: "python3 -m twine upload dist/*"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_RELEASE_TOKEN }}
32 changes: 16 additions & 16 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,53 @@
# For more info visit https://github.com/pulp/plugin_template

---
name: Galaxy changelog update
name: "Galaxy changelog update"
on:
push:
branches:
- master
- "master"
paths:
- CHANGES.rst
- CHANGES.md
- "CHANGES.rst"
- "CHANGES.md"
workflow_dispatch:

jobs:

update-changelog:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: "actions/checkout@v4"
with:
fetch-depth: 1

- uses: actions/setup-python@v4
- uses: "actions/setup-python@v4"
with:
python-version: "3.9"
python-version: "3.11"

- name: Install python dependencies
- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install -r doc_requirements.txt
echo ::endgroup::
- name: Fake api schema
- name: "Fake api schema"
run: |
mkdir -p docs/_build/html
echo "{}" > docs/_build/html/api.json
mkdir -p docs/_static
echo "{}" > docs/_static/api.json
- name:
- name: "Build Docs"
run: |
pip install "Jinja2<3.1"
make diagrams html
working-directory: ./docs
working-directory: "./docs"
env:
PULP_CONTENT_ORIGIN: "http://localhost/"

- name: Publish changlog to pulpproject.org
run: .github/workflows/scripts/publish_docs.sh changelog ${GITHUB_REF##*/}
- name: "Publish changlog to pulpproject.org"
run: |
.github/workflows/scripts/publish_docs.sh changelog ${GITHUB_REF##*/}
env:
PULP_DOCS_KEY: ${{ secrets.PULP_DOCS_KEY }}
PULP_DOCS_KEY: "${{ secrets.PULP_DOCS_KEY }}"
Loading

0 comments on commit 9ca7aa4

Please sign in to comment.