Skip to content

Commit

Permalink
Output differences of api spec for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg authored and lubosmj committed Jun 27, 2024
1 parent 6f2bebb commit c4a2504
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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::
Expand Down
17 changes: 15 additions & 2 deletions templates/github/.github/workflows/scripts/script.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
###########################

Expand Down Expand Up @@ -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 %}
Expand Down
14 changes: 11 additions & 3 deletions templates/github/.github/workflows/test.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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) }}

Expand Down

0 comments on commit c4a2504

Please sign in to comment.