From c4a2504fa021a4f9cdf7c3765518817f4320fce4 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Thu, 27 Jun 2024 12:24:49 +0200 Subject: [PATCH] Output differences of api spec for debugging --- .github/workflows/test.yml | 14 +++++++++++--- .../.github/workflows/scripts/script.sh.j2 | 17 +++++++++++++++-- templates/github/.github/workflows/test.yml.j2 | 14 +++++++++++--- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 708cf98a..4f20b0c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,12 +52,20 @@ jobs: repository: "pulp/pulp-openapi-generator" path: "pulp-openapi-generator" - - uses: "actions/download-artifact@v4" + - name: "Download plugin package" + uses: "actions/download-artifact@v4" with: name: "plugin_package" path: "pulp_catdog/dist/" - - uses: "actions/download-artifact@v4" + - name: "Download API specs" + uses: "actions/download-artifact@v4" + with: + name: "api_spec" + path: "pulp_catdog/" + + - name: "Download client packages" + uses: "actions/download-artifact@v4" with: name: "python-client.tar" path: "pulp_catdog" @@ -73,7 +81,7 @@ jobs: - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs + pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs jq jsonpatch echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_catdog/.ci/assets/httpie/" >> $GITHUB_ENV echo ::endgroup:: diff --git a/templates/github/.github/workflows/scripts/script.sh.j2 b/templates/github/.github/workflows/scripts/script.sh.j2 index 4ee74604..a4b09700 100755 --- a/templates/github/.github/workflows/scripts/script.sh.j2 +++ b/templates/github/.github/workflows/scripts/script.sh.j2 @@ -56,6 +56,8 @@ cmd_prefix bash -c "chmod 600 ~pulp/.netrc" # Generate bindings ################### +echo "::group::Generate bindings" + touch bindings_requirements.txt pushd ../pulp-openapi-generator # Use app_label to generate api.json and package to produce the proper package name. @@ -78,10 +80,10 @@ pushd ../pulp-openapi-generator # there, because we did not merge plugins into pulpcore back then. MODULE="$(jq -r '.module // (.package|gsub("-"; "_"))' <<<"${ITEM}")" PACKAGE="${MODULE%%.*}" + cmd_prefix pulpcore-manager openapi --bindings --component "${COMPONENT}" > "${COMPONENT}-api.json" if [[ ! " ${BUILT_CLIENTS} " =~ "${COMPONENT}" ]] then rm -rf "./${PACKAGE}-client" - cmd_prefix pulpcore-manager openapi --bindings --component "${COMPONENT}" > "${COMPONENT}-api.json" ./gen-client.sh "${COMPONENT}-api.json" "${COMPONENT}" python "${PACKAGE}" pushd "${PACKAGE}-client" python setup.py sdist bdist_wheel --python-tag py3 @@ -99,6 +101,17 @@ pushd ../pulp-openapi-generator done popd +echo "::endgroup::" + +echo "::group::Debug bindings diffs" +{% for plugin in plugins %} +# Bindings diff for {{ plugin.app_label }} +jq '(.paths[][].parameters|select(.)) |= sort_by(.name)' < "{{ plugin.app_label }}-api.json" > "build-api.json" +jq '(.paths[][].parameters|select(.)) |= sort_by(.name)' < "../pulp-openapi-generator/{{ plugin.app_label }}-api.json" > "test-api.json" +jsondiff --indent 2 build-api.json test-api.json || true +{%- endfor %} +echo "::endgroup::" + # Install test requirements ########################### @@ -153,7 +166,7 @@ else cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs {{ plugin.name | snake }}.tests.functional -m parallel -n {{ parallel_test_workers }}" cmd_user_prefix bash -c "pytest -v -r sx --color=yes --suppress-no-test-exit-code --pyargs {{ plugin.name | snake }}.tests.functional -m 'not parallel'" {%- endfor %} - fi + fi fi {%- if test_cli %} diff --git a/templates/github/.github/workflows/test.yml.j2 b/templates/github/.github/workflows/test.yml.j2 index 6665f34e..028cddec 100644 --- a/templates/github/.github/workflows/test.yml.j2 +++ b/templates/github/.github/workflows/test.yml.j2 @@ -48,12 +48,20 @@ jobs: {{ setup_python() | indent(6) }} - - uses: "actions/download-artifact@v4" + - name: "Download plugin package" + uses: "actions/download-artifact@v4" with: name: "plugin_package" path: "{{ plugin_name }}/dist/" - - uses: "actions/download-artifact@v4" + - name: "Download API specs" + uses: "actions/download-artifact@v4" + with: + name: "api_spec" + path: "{{ plugin_name }}/" + + - name: "Download client packages" + uses: "actions/download-artifact@v4" with: name: "python-client.tar" path: "{{ plugin_name }}" @@ -68,7 +76,7 @@ jobs: popd {%- endfor %} - {{ install_python_deps(["towncrier", "twine", "wheel", "httpie", "docker", "netaddr", "boto3", "ansible", "mkdocs"]) | indent(6) }} + {{ install_python_deps(["towncrier", "twine", "wheel", "httpie", "docker", "netaddr", "boto3", "ansible", "mkdocs", "jq", "jsonpatch"]) | indent(6) }} {{ setup_env() | indent(6) }}