From bad6dacfe206a79f22c319c9a99b50d8fb0a81d4 Mon Sep 17 00:00:00 2001 From: "Reed, Joshua" Date: Mon, 11 Dec 2023 12:45:59 -0700 Subject: [PATCH] Add Tox Metadata Verification Check. This change adds a new Zuul Job/Check to verify the app metadata.yaml file in this repo. The check is performed by a console script belonging to the sysinv/config repo. The existing metadata.yaml used the at '@' symbol to serve as a template for logic in the Rules file to find and replace for debian packaging purposes. This needed to be changed so the verification software could read the file without throwing an error. Test Plan: PASS - Verify that the appropriate Zuul Job has run and passes. Story: 2010929 Task: 49230 Change-Id: I0b53dda13ed92eee66f0e71d609fbc6b5e563bd6 Signed-off-by: Reed, Joshua --- .gitignore | 3 ++- .zuul.yaml | 21 +++++++++++++++++++ .../k8sapp_dell_storage/.stestr.conf | 1 - .../k8sapp_dell_storage/tox.ini | 11 +++++++++- stx-dell-storage-helm/debian/deb_folder/rules | 6 +++--- .../stx-dell-storage-helm/files/metadata.yaml | 6 +++--- tox.ini | 4 ++++ 7 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 84d28ed..f51ee66 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.tox \ No newline at end of file +.tox +venv/ \ No newline at end of file diff --git a/.zuul.yaml b/.zuul.yaml index 2ac5d40..4cbc0b0 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -5,11 +5,13 @@ - openstack-tox-linters - k8sapp-dell-storage-tox-py39 - k8sapp-dell-storage-tox-pylint + - k8sapp-dell-storage-tox-metadata gate: jobs: - openstack-tox-linters - k8sapp-dell-storage-tox-py39 - k8sapp-dell-storage-tox-pylint + - k8sapp-dell-storage-tox-metadata - job: name: k8sapp-dell-storage-tox-py39 @@ -29,6 +31,25 @@ tox_extra_args: -c python3-k8sapp-dell-storage/k8sapp_dell_storage/tox.ini tox_constraints_file: '{{ ansible_user_dir }}/src/opendev.org/starlingx/root/build-tools/requirements/debian/upper-constraints.txt' +- job: + name: k8sapp-dell-storage-tox-metadata + parent: tox + description: | + Run metadata test for k8sapp_dell_storage + nodeset: debian-bullseye + required-projects: + - starlingx/config + - starlingx/fault + - starlingx/update + - starlingx/utilities + - starlingx/root + files: + - python3-k8sapp-dell-storage/* + vars: + tox_envlist: metadata + tox_extra_args: -c python3-k8sapp-dell-storage/k8sapp_dell_storage/tox.ini + tox_constraints_file: '{{ ansible_user_dir }}/src/opendev.org/starlingx/root/build-tools/requirements/debian/upper-constraints.txt' + - job: name: k8sapp-dell-storage-tox-pylint parent: tox diff --git a/python3-k8sapp-dell-storage/k8sapp_dell_storage/.stestr.conf b/python3-k8sapp-dell-storage/k8sapp_dell_storage/.stestr.conf index bdb59e2..95a8823 100644 --- a/python3-k8sapp-dell-storage/k8sapp_dell_storage/.stestr.conf +++ b/python3-k8sapp-dell-storage/k8sapp_dell_storage/.stestr.conf @@ -1,4 +1,3 @@ [DEFAULT] test_path=./k8sapp_dell_storage/tests top_dir=./k8sapp_dell_storage -#parallel_class=True diff --git a/python3-k8sapp-dell-storage/k8sapp_dell_storage/tox.ini b/python3-k8sapp-dell-storage/k8sapp_dell_storage/tox.ini index 0354034..b105515 100644 --- a/python3-k8sapp-dell-storage/k8sapp_dell_storage/tox.ini +++ b/python3-k8sapp-dell-storage/k8sapp_dell_storage/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = flake8,py39,pylint +envlist = flake8,py39,pylint,metadata minversion = 1.6 skipsdist = True @@ -16,6 +16,7 @@ usedevelop = True # tox is silly... these need to be separated by a newline.... allowlist_externals = bash find + echo install_command = pip install -v -v -v \ -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \ @@ -179,3 +180,11 @@ commands = deps = pip_missing_reqs -rrequirements.txt commands=pip-missing-reqs -d --ignore-file=/k8sapp_dell_storage/tests k8sapp_dell_storage + +[testenv:metadata] +install_command = pip install -v -v -v \ + -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \ + {opts} {packages} +# Pass top level app folder to 'sysinv-app tox' command. +commands = + bash -c "echo $(dirname $(dirname $(pwd))) | xargs -n 1 sysinv-app tox" \ No newline at end of file diff --git a/stx-dell-storage-helm/debian/deb_folder/rules b/stx-dell-storage-helm/debian/deb_folder/rules index e201ec4..2aeca40 100644 --- a/stx-dell-storage-helm/debian/deb_folder/rules +++ b/stx-dell-storage-helm/debian/deb_folder/rules @@ -27,9 +27,9 @@ override_dh_auto_build: cp $(HELM_FOLDER)/*.tgz $(STAGING)/charts # Populate metadata. - sed -i 's/@APP_NAME@/$(APP_NAME)/g' $(STAGING)/metadata.yaml - sed -i 's/@APP_VERSION@/$(APP_VERSION)/g' $(STAGING)/metadata.yaml - sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING)/metadata.yaml + sed -i 's/APP_REPLACE_NAME/$(APP_NAME)/g' $(STAGING)/metadata.yaml + sed -i 's/APP_REPLACE_VERSION/$(APP_VERSION)/g' $(STAGING)/metadata.yaml + sed -i 's/HELM_REPLACE_REPO/$(HELM_REPO)/g' $(STAGING)/metadata.yaml # Copy the plugins: installed in the buildroot mkdir -p $(STAGING)/plugins diff --git a/stx-dell-storage-helm/stx-dell-storage-helm/files/metadata.yaml b/stx-dell-storage-helm/stx-dell-storage-helm/files/metadata.yaml index 317981e..2f4dec1 100644 --- a/stx-dell-storage-helm/stx-dell-storage-helm/files/metadata.yaml +++ b/stx-dell-storage-helm/stx-dell-storage-helm/files/metadata.yaml @@ -1,6 +1,6 @@ -app_name: @APP_NAME@ -app_version: @APP_VERSION@ -helm_repo: @HELM_REPO@ +app_name: APP_REPLACE_NAME +app_version: APP_REPLACE_VERSION +helm_repo: HELM_REPLACE_REPO maintain_user_overrides: true maintain_attributes: true diff --git a/tox.ini b/tox.ini index 2442671..64a2a28 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,10 @@ description = Dummy environment to allow flake8 to be run in subdir tox basepython = python3 description = Dummy environment to allow pylint to be run in subdir tox +[testenv:metadata] +basepython = python3 +description = Dummy environment to allow pylint to be run in subdir tox + [testenv:bandit] basepython = python3 description = Dummy environment to allow bandit to be run in subdir tox