Skip to content

Commit

Permalink
Fix openapi client generation in the playbooks. (#2109)
Browse files Browse the repository at this point in the history
Handle the unique path required for generating the galaxy client.

No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner authored Mar 29, 2024
1 parent 430e7b2 commit c6cb9ac
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ jobs:
run: pip3 install ansible

- name: run the build container playbook
run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v build_container.yaml
run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v build_container.yaml

- name: run the start container playbook
run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v start_container.yaml
run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v start_container.yaml

- name: run the unit test playbook
run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v run_unit_tests.yaml
run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v run_unit_tests.yaml

- name: run the functional test playbook
run: cd dev/playbooks; ansible-playbook -i 'localhost,' --forks=1 -v run_functional_tests.yaml
run: cd dev/playbooks; ANSIBLE_STDOUT_CALLBACK=yaml ansible-playbook -i 'localhost,' --forks=1 -v run_functional_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash -x

set -e

PULP_IP=$1
PLUGIN=$2

cd ../../..
if [[ ! -d pulp-openapi-generator ]]; then
git clone https://github.com/pulp/pulp-openapi-generator
fi
cd pulp-openapi-generator;

export USE_LOCAL_API_JSON=true;
export PULP_URL="https://${PULP_IP}/api/galaxy/pulp/api/v3/";

curl -L -k -u admin:password -o status.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/status/";
curl -L -k -u admin:password -o api.json "https://${PULP_IP}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin=${PLUGIN}";

if [ "${PLUGIN}" == "galaxy_ng" ]; then
cat status.json | head
export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"')
echo "REPORTED_VERSION: ${REPORTED_VERSION}"
export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')"
echo "FINAL_VERSION: ${FINAL_VERSION}"
else
export VERSION=""
fi;

bash -x generate.sh ${PLUGIN} python ${VERSION}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,41 @@
connection: local
register: pulp_ip

#- name: run the generate script
# galaxy_ng.tools.local_run:
# command: >
# cd ../../../pulp-openapi-generator;
# export USE_LOCAL_API_JSON=true;
# export PULP_URL='https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/';
# curl -L -k -u admin:password -o status.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/status/';
# curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}';
# if [ "{{ item }}" == "galaxy_ng" ]; then
# cat status.json | head
# export REPORTED_VERSION=$(jq '.versions[] | select (.component == "galaxy").version' status.json | tr -d '"')
# echo "REPORTED_VERSION: ${REPORTED_VERSION}"
# export VERSION="$(echo "$REPORTED_VERSION" | python -c 'from packaging.version import Version; print(Version(input()))')"
# echo "FINAL_VERSION: ${FINAL_VERSION}"
# else
# export VERSION=""
# fi;
# bash -x generate.sh {{ item }} python $VERSION
# connection: local
# loop:
# - galaxy_ng
# - pulp_ansible
# - pulp_container
# - pulpcore

- name: copy the generate script to a tmp location
copy:
src: generate.sh
dest: /tmp/generate.sh
mode: '0777'
connection: local

- name: run the generate script
galaxy_ng.tools.local_run:
command: >
cd ../../../pulp-openapi-generator;
export USE_LOCAL_API_JSON=true;
curl -L -k -u admin:password -o api.json 'https://{{ pulp_ip.stdout }}/api/galaxy/pulp/api/v3/docs/api.json?bindings&plugin={{ item }}';
bash -x generate.sh {{ item }} python
command: /tmp/generate.sh {{ pulp_ip.stdout }} {{ item }}
connection: local
loop:
- galaxy_ng
Expand All @@ -25,9 +53,12 @@
- pulpcore

- name: install the generated client inside the pulp container
shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install -e .
shell: cd /src/pulp-openapi-generator/{{ item }}-client/; pip3 install .
loop:
- galaxy_ng
- pulp_ansible
- pulp_container
- pulpcore

- name: show what we eneded up with
shell: pip3 list | grep -e galaxy -e pulp -e ansible

0 comments on commit c6cb9ac

Please sign in to comment.