From f3a30b3f239e165ff4e8db88e2461ff633d453a1 Mon Sep 17 00:00:00 2001 From: pulpbot Date: Tue, 25 Jun 2024 14:15:56 +0000 Subject: [PATCH 1/3] Update CI files [noissue] --- .ci/ansible/Containerfile.j2 | 1 + .ci/assets/ci_constraints.txt | 7 ++ .github/template_gitref | 2 +- .github/workflows/build.yml | 70 +++++++++++- .../workflows/scripts/build_python_client.sh | 56 ++++++++++ .../workflows/scripts/build_ruby_client.sh | 35 ++++++ .github/workflows/scripts/script.sh | 101 ++++++++---------- .github/workflows/test.yml | 52 +++------ docs/template_gitref | 2 +- 9 files changed, 228 insertions(+), 98 deletions(-) create mode 100644 .ci/assets/ci_constraints.txt create mode 100755 .github/workflows/scripts/build_python_client.sh create mode 100755 .github/workflows/scripts/build_ruby_client.sh diff --git a/.ci/ansible/Containerfile.j2 b/.ci/ansible/Containerfile.j2 index 338ff697..bad75f3b 100644 --- a/.ci/ansible/Containerfile.j2 +++ b/.ci/ansible/Containerfile.j2 @@ -22,6 +22,7 @@ RUN pip3 install {{ " " }}-r ./{{ item.name }}/ci_requirements.txt {%- endif -%} {%- endfor %} +{{ " " }}-c ./{{ plugins[0].name }}/.ci/assets/ci_constraints.txt {% if pulp_env is defined and pulp_env %} {% for key, value in pulp_env.items() %} diff --git a/.ci/assets/ci_constraints.txt b/.ci/assets/ci_constraints.txt new file mode 100644 index 00000000..2617a408 --- /dev/null +++ b/.ci/assets/ci_constraints.txt @@ -0,0 +1,7 @@ +# Pulpcore versions without the openapi command do no longer work in the CI +pulpcore>=3.21.30,!=3.23.*,!=3.24.*,!=3.25.*,!=3.26.*,!=3.27.*,!=3.29.*,!=3.30.*,!=3.31.*,!=3.32.*,!=3.33.*,!=3.34.*,!=3.35.*,!=3.36.*,!=3.37.*,!=3.38.*,!=3.40.*,!=3.41.*,!=3.42.*,!=3.43.*,!=3.44.*,!=3.45.*,!=3.46.*,!=3.47.*,!=3.48.*,!=3.50.*,!=3.51.*,!=3.52.*,!=3.53.*,!=3.54.* + + + +tablib!=3.6.0 +# 3.6.0: This release introduced a regression removing the "html" optional dependency. diff --git a/.github/template_gitref b/.github/template_gitref index 1d4100e7..7150dcb4 100644 --- a/.github/template_gitref +++ b/.github/template_gitref @@ -1 +1 @@ -2021.08.26-341-g5cb6e90 +2021.08.26-345-g747bcf8 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f035a017..cbb13657 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,18 +23,30 @@ jobs: with: fetch-depth: 1 path: "pulp_ostree" + - uses: "actions/checkout@v4" + with: + fetch-depth: 1 + repository: "pulp/pulp-openapi-generator" + path: "pulp-openapi-generator" - uses: "actions/setup-python@v5" with: python-version: "3.11" - name: "Install python dependencies" run: | echo ::group::PYDEPS - pip install packaging twine wheel + pip install packaging twine wheel mkdocs jq echo ::endgroup:: - name: "Build package" run: | python3 setup.py sdist bdist_wheel --python-tag py3 twine check dist/* + - name: "Install built packages" + run: | + pip install dist/pulp_ostree-*-py3-none-any.whl -c .ci/assets/ci_constraints.txt + - name: "Generate api specs" + run: | + pulpcore-manager openapi --file "api.json" + pulpcore-manager openapi --bindings --component "ostree" --file "ostree-api.json" - name: "Upload Package whl" uses: "actions/upload-artifact@v4" with: @@ -43,3 +55,59 @@ jobs: if-no-files-found: "error" retention-days: 5 overwrite: true + - name: "Upload API specs" + uses: "actions/upload-artifact@v4" + with: + name: "api_spec" + path: | + pulp_ostree/api.json + pulp_ostree/ostree-api.json + if-no-files-found: "error" + retention-days: 5 + overwrite: true + - name: "Build Python bindings packages" + run: | + .github/workflows/scripts/build_python_client.sh + shell: "bash" + env: + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" + - name: "Upload python client packages" + uses: "actions/upload-artifact@v4" + with: + name: "python-client.tar" + path: | + pulp_ostree/ostree-python-client.tar + if-no-files-found: "error" + retention-days: 5 + overwrite: true + - name: "Upload python client docs" + uses: "actions/upload-artifact@v4" + with: + name: "python-client-docs.tar" + path: | + pulp_ostree/ostree-python-client-docs.tar + if-no-files-found: "error" + retention-days: 5 + overwrite: true + - name: "Build Ruby bindings packages" + run: | + .github/workflows/scripts/build_ruby_client.sh + shell: "bash" + env: + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" + - name: "Upload Ruby client" + uses: "actions/upload-artifact@v4" + with: + name: "ruby-client.tar" + path: | + pulp_ostree/ostree-ruby-client.tar + if-no-files-found: "error" + retention-days: 5 + overwrite: true +... diff --git a/.github/workflows/scripts/build_python_client.sh b/.github/workflows/scripts/build_python_client.sh new file mode 100755 index 00000000..9fcf2ffb --- /dev/null +++ b/.github/workflows/scripts/build_python_client.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# This script expects all -api.json files to exist in the plugins root directory. +# It produces a -python-client.tar and -python-client-docs.tar file in the plugins root directory. + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by it. Please use +# './plugin-template --github pulp_ostree' to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +set -mveuo pipefail + +# make sure this script runs at the repo root +cd "$(dirname "$(realpath -e "$0")")"/../../.. + +pushd ../pulp-openapi-generator +rm -rf "pulp_ostree-client" + +# We need to copy that over to be visible in the container. +cp "../pulp_ostree/ostree-api.json" . +./gen-client.sh "ostree-api.json" "ostree" python "pulp_ostree" + +pushd pulp_ostree-client +python setup.py sdist bdist_wheel --python-tag py3 + +twine check "dist/pulp_ostree_client-"*"-py3-none-any.whl" +twine check "dist/pulp_ostree-client-"*".tar.gz" + +tar cvf "../../pulp_ostree/ostree-python-client.tar" ./dist + +find ./docs/* -exec sed -i 's/Back to README/Back to HOME/g' {} \; +find ./docs/* -exec sed -i 's/README//g' {} \; +cp README.md docs/index.md +sed -i 's/docs\///g' docs/index.md +find ./docs/* -exec sed -i 's/\.md//g' {} \; + +cat >> mkdocs.yml << DOCSYAML +--- +site_name: PulpOstree Client +site_description: Ostree bindings +site_author: Pulp Team +site_url: https://docs.pulpproject.org/pulp_ostree_client/ +repo_name: pulp/pulp_ostree +repo_url: https://github.com/pulp/pulp_ostree +theme: readthedocs +DOCSYAML + +# Building the bindings docs +mkdocs build + +# Pack the built site. +tar cvf ../../pulp_ostree/ostree-python-client-docs.tar ./site +popd +popd diff --git a/.github/workflows/scripts/build_ruby_client.sh b/.github/workflows/scripts/build_ruby_client.sh new file mode 100755 index 00000000..18f7dd72 --- /dev/null +++ b/.github/workflows/scripts/build_ruby_client.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# This script expects all -api.json files to exist in the plugins root directory. +# It produces a -ruby-client.tar file in the plugins root directory. + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by it. Please use +# './plugin-template --github pulp_ostree' to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +set -mveuo pipefail + +# make sure this script runs at the repo root +cd "$(dirname "$(realpath -e "$0")")"/../../.. + +pushd ../pulp-openapi-generator +rm -rf "pulp_ostree-client" + +# We need to copy that over to be visible in the container. +#cp "../pulp_ostree/ostree-api.json" . +#./gen-client.sh "ostree-api.json" "ostree" ruby "pulp_ostree" + +# ------------- +# The generator still needs to have it called api.json at this time... +cp "../pulp_ostree/api.json" . +./gen-client.sh "api.json" "ostree" ruby "pulp_ostree" +# ------------- + +pushd pulp_ostree-client +gem build pulp_ostree_client +tar cvf "../../pulp_ostree/ostree-ruby-client.tar" "./pulp_ostree_client-"*".gem" +popd +popd diff --git a/.github/workflows/scripts/script.sh b/.github/workflows/scripts/script.sh index ae3e2f03..7b26aa7e 100755 --- a/.github/workflows/scripts/script.sh +++ b/.github/workflows/scripts/script.sh @@ -54,75 +54,62 @@ password password # Some commands like ansible-galaxy specifically require 600 cmd_prefix bash -c "chmod 600 ~pulp/.netrc" -# Generate and install binding +# Generate bindings +################### + +touch bindings_requirements.txt pushd ../pulp-openapi-generator -if pulp debug has-plugin --name "core" --specifier ">=3.44.0.dev" -then # Use app_label to generate api.json and package to produce the proper package name. - if [ "$(jq -r '.domain_enabled' <<<"$REPORTED_STATUS")" = "true" ] + # Workaround: Domains are not supported by the published bindings. + # Sadly: Different pulpcore-versions aren't either... + # So we exclude the prebuilt ones only for domains disabled. + if [ "$(jq -r '.domain_enabled' <<<"${REPORTED_STATUS}")" = "true" ] || [ "$(jq -r '.online_workers[0].pulp_href|startswith("/pulp/api/v3/")' <<< "${REPORTED_STATUS}")" = "false" ] then - # Workaround: Domains are not supported by the published bindings. - # Generate new bindings for all packages. - for item in $(jq -r '.versions[] | tojson' <<<"$REPORTED_STATUS") - do - echo $item - COMPONENT="$(jq -r '.component' <<<"$item")" - VERSION="$(jq -r '.version' <<<"$item")" - MODULE="$(jq -r '.module' <<<"$item")" - PACKAGE="${MODULE%%.*}" - curl --fail-with-body -k -o api.json "${PULP_URL}${PULP_API_ROOT}api/v3/docs/api.json?bindings&component=$COMPONENT" - USE_LOCAL_API_JSON=1 ./generate.sh "${PACKAGE}" python "${VERSION}" - cmd_prefix pip3 install "/root/pulp-openapi-generator/${PACKAGE}-client" - sudo rm -rf "./${PACKAGE}-client" - done + BUILT_CLIENTS="" else - # Sadly: Different pulpcore-versions aren't either... - for item in $(jq -r '.versions[]| select(.component!="ostree")| tojson' <<<"$REPORTED_STATUS") - do - echo $item - COMPONENT="$(jq -r '.component' <<<"$item")" - VERSION="$(jq -r '.version' <<<"$item")" - MODULE="$(jq -r '.module' <<<"$item")" - PACKAGE="${MODULE%%.*}" - curl --fail-with-body -k -o api.json "${PULP_URL}${PULP_API_ROOT}api/v3/docs/api.json?bindings&component=$COMPONENT" - USE_LOCAL_API_JSON=1 ./generate.sh "${PACKAGE}" python "${VERSION}" - cmd_prefix pip3 install "/root/pulp-openapi-generator/${PACKAGE}-client" - sudo rm -rf "./${PACKAGE}-client" - done + BUILT_CLIENTS=" ostree " fi -else - # Infer the client name from the package name by replacing "-" with "_". - # Use the component to infer the package name on older versions of pulpcore. - if [ "$(echo "$REPORTED_STATUS" | jq -r '.domain_enabled')" = "true" ] - then - # Workaround: Domains are not supported by the published bindings. - # Generate new bindings for all packages. - for item in $(echo "$REPORTED_STATUS" | jq -r '.versions[]|(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")') - do - ./generate.sh "${item}" python - cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" - sudo rm -rf "./${item}-client" - done - else - # Sadly: Different pulpcore-versions aren't either... - for item in $(echo "$REPORTED_STATUS" | jq -r '.versions[]|select(.component!="ostree")|(.package // ("pulp_" + .component)|sub("pulp_core"; "pulpcore"))|sub("-"; "_")') - do - ./generate.sh "${item}" python - cmd_prefix pip3 install "/root/pulp-openapi-generator/${item}-client" - sudo rm -rf "./${item}-client" - done - fi -fi + for ITEM in $(jq -r '.versions[] | tojson' <<<"${REPORTED_STATUS}") + do + COMPONENT="$(jq -r '.component' <<<"${ITEM}")" + VERSION="$(jq -r '.version' <<<"${ITEM}" | python3 -c "from packaging.version import Version; print(Version(input()))")" + # On older status endpoints, the module was not provided, but the package should be accurate + # there, because we did not merge plugins into pulpcore back then. + MODULE="$(jq -r '.module // (.package|gsub("-"; "_"))' <<<"${ITEM}")" + PACKAGE="${MODULE%%.*}" + 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 + popd + else + if [ ! -f "${PACKAGE}-client/dist/${PACKAGE}_client-${VERSION}-py3-none-any.whl" ] + then + ls -lR "${PACKAGE}-client/" + echo "Error: Client bindings for ${COMPONENT} not found." + echo "File ${PACKAGE}-client/dist/${PACKAGE}_client-${VERSION}-py3-none-any.whl missing." + exit 1 + fi + fi + echo "/root/pulp-openapi-generator/${PACKAGE}-client/dist/${PACKAGE}_client-${VERSION}-py3-none-any.whl" >> "../pulp_ostree/bindings_requirements.txt" + done popd -# At this point, this is a safeguard only, so let's not make too much fuzz about the old status format. -echo "$REPORTED_STATUS" | jq -r '.versions[]|select(.package)|(.package|sub("_"; "-")) + "-client==" + .version' > bindings_requirements.txt +# Install test requirements +########################### + +# Add a safeguard to make sure the proper versions of the clients are installed. +echo "$REPORTED_STATUS" | jq -r '.versions[]|select(.package)|(.package|sub("_"; "-")) + "-client==" + .version' > bindings_constraints.txt cmd_stdin_prefix bash -c "cat > /tmp/unittest_requirements.txt" < unittest_requirements.txt cmd_stdin_prefix bash -c "cat > /tmp/functest_requirements.txt" < functest_requirements.txt cmd_stdin_prefix bash -c "cat > /tmp/bindings_requirements.txt" < bindings_requirements.txt -cmd_prefix pip3 install -r /tmp/unittest_requirements.txt -r /tmp/functest_requirements.txt -r /tmp/bindings_requirements.txt +cmd_stdin_prefix bash -c "cat > /tmp/bindings_constraints.txt" < bindings_constraints.txt +cmd_prefix pip3 install -r /tmp/unittest_requirements.txt -r /tmp/functest_requirements.txt -r /tmp/bindings_requirements.txt -c /tmp/bindings_constraints.txt CERTIFI=$(cmd_prefix python3 -c 'import certifi; print(certifi.where())') cmd_prefix bash -c "cat /etc/pulp/certs/pulp_webserver.crt >> '$CERTIFI'" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 205b82bf..043662c8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,6 +48,19 @@ jobs: name: "plugin_package" path: "pulp_ostree/dist/" + - uses: "actions/download-artifact@v4" + with: + name: "python-client.tar" + path: "pulp_ostree" + + - name: "Unpack client packages" + working-directory: "pulp-openapi-generator" + run: | + mkdir -p "pulp_ostree-client" + pushd "pulp_ostree-client" + tar xvf "../../pulp_ostree/ostree-python-client.tar" + popd + - name: "Install python dependencies" run: | echo ::group::PYDEPS @@ -94,16 +107,6 @@ jobs: GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" REDIS_DISABLED: "${{ contains('', matrix.env.TEST) }}" - - 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 @@ -126,34 +129,6 @@ jobs: if-no-files-found: "error" retention-days: 5 overwrite: true - - name: Upload python client packages - if: ${{ env.TEST == 'pulp' }} - uses: actions/upload-artifact@v4 - with: - name: "python-client.tar" - path: "pulp_ostree/ostree-python-client.tar" - if-no-files-found: "error" - retention-days: 5 - overwrite: true - - - name: Upload python client docs - if: ${{ env.TEST == 'pulp' }} - uses: actions/upload-artifact@v4 - with: - name: "python-client-docs.tar" - path: "pulp_ostree/ostree-python-client-docs.tar" - if-no-files-found: "error" - retention-days: 5 - overwrite: true - - name: Upload Ruby client - if: ${{ env.TEST == 'pulp' }} - uses: actions/upload-artifact@v4 - with: - name: "ruby-client.tar" - path: "pulp_ostree/ostree-ruby-client.tar" - if-no-files-found: "error" - retention-days: 5 - overwrite: true - name: Upload built docs if: ${{ env.TEST == 'docs' }} uses: actions/upload-artifact@v4 @@ -175,3 +150,4 @@ jobs: docker exec pulp ls -latr /etc/yum.repos.d/ || true docker exec pulp cat /etc/yum.repos.d/* || true docker exec pulp bash -c "pip3 list && pip3 install pipdeptree && pipdeptree" +... diff --git a/docs/template_gitref b/docs/template_gitref index 1d4100e7..7150dcb4 100644 --- a/docs/template_gitref +++ b/docs/template_gitref @@ -1 +1 @@ -2021.08.26-341-g5cb6e90 +2021.08.26-345-g747bcf8 From dc9ddef80af389eaaf54fe2d679a5f24db9d0b8a Mon Sep 17 00:00:00 2001 From: Lubos Mjachky Date: Wed, 26 Jun 2024 13:41:32 +0200 Subject: [PATCH 2/3] Install OS required packages [noissue] --- .github/template_gitref | 2 +- .github/workflows/build.yml | 3 +++ template_config.yml | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/template_gitref b/.github/template_gitref index 7150dcb4..90ac2c05 100644 --- a/.github/template_gitref +++ b/.github/template_gitref @@ -1 +1 @@ -2021.08.26-345-g747bcf8 +2021.08.26-346-g8368e4c diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cbb13657..079f806f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,6 +36,9 @@ jobs: echo ::group::PYDEPS pip install packaging twine wheel mkdocs jq echo ::endgroup:: + - name: "Install OS packages" + run: | + sudo apt-get install -y libgirepository1.0-dev libostree-dev - name: "Build package" run: | python3 setup.py sdist bdist_wheel --python-tag py3 diff --git a/template_config.yml b/template_config.yml index 059b2474..504b86b1 100644 --- a/template_config.yml +++ b/template_config.yml @@ -32,6 +32,9 @@ kanban: true latest_release_branch: '2.3' lint_requirements: true noissue_marker: '[noissue]' +os_required_packages: + - libgirepository1.0-dev + - libostree-dev parallel_test_workers: 8 plugin_app_label: ostree plugin_default_branch: main From a4a093577d986ff6f76a22b21a25da0bb3d7900a Mon Sep 17 00:00:00 2001 From: Lubos Mjachky Date: Wed, 26 Jun 2024 14:03:26 +0200 Subject: [PATCH 3/3] Bump up to the latest supported pulpcore version [noissue] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index dc9c054d..97cb33bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -pulpcore>=3.45.1,<3.70 +pulpcore>=3.49.0,<3.70 PyGObject~=3.40.1