From 45471cef922a7bf25b780412a3001132f1057eff Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Tue, 7 Feb 2023 19:43:47 -0300 Subject: [PATCH 1/2] Add charmhub-lp-tool-osci-sync charmhub-lp-tool-osci-sync job takes care of installing charmhub-lp-tools (via pip) and running `charmhub-lp-tool osci-sync` which reads osci.yaml to get the desired charmcraft version to be used when building the charm and update the Launchpad charm build recipe. Introduces a new secret named "launchpad_token" which contains a token associated to a uosci-testing-bot[0] [0] https://launchpad.net/~uosci-testing-bot --- .../charm/charmhub-lp-tool-osci-sync.yaml | 3 +++ .../defaults/main.yaml | 3 +++ .../tasks/main.yaml | 20 +++++++++++++++++++ zuul.d/jobs.yaml | 18 +++++++++++++++++ zuul.d/project-templates.yaml | 3 +++ zuul.d/secrets.yaml | 15 ++++++++++++++ 6 files changed, 62 insertions(+) create mode 100644 playbooks/charm/charmhub-lp-tool-osci-sync.yaml create mode 100644 roles/charmhub-lp-tool-osci-sync/defaults/main.yaml create mode 100644 roles/charmhub-lp-tool-osci-sync/tasks/main.yaml diff --git a/playbooks/charm/charmhub-lp-tool-osci-sync.yaml b/playbooks/charm/charmhub-lp-tool-osci-sync.yaml new file mode 100644 index 0000000..cde5553 --- /dev/null +++ b/playbooks/charm/charmhub-lp-tool-osci-sync.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - charmhub-lp-tool-osci-sync diff --git a/roles/charmhub-lp-tool-osci-sync/defaults/main.yaml b/roles/charmhub-lp-tool-osci-sync/defaults/main.yaml new file mode 100644 index 0000000..3752006 --- /dev/null +++ b/roles/charmhub-lp-tool-osci-sync/defaults/main.yaml @@ -0,0 +1,3 @@ +# allow repos to use a different source to facilitate testing of new features +# in charmhub-lp-tools branches. +charmhub_lp_tools_pkg: "git+https://github.com/openstack-charmers/charmhub-lp-tools.git@main#egg=charmhub-lp-tools" diff --git a/roles/charmhub-lp-tool-osci-sync/tasks/main.yaml b/roles/charmhub-lp-tool-osci-sync/tasks/main.yaml new file mode 100644 index 0000000..10a24b3 --- /dev/null +++ b/roles/charmhub-lp-tool-osci-sync/tasks/main.yaml @@ -0,0 +1,20 @@ +- name: Sync charm recipe definitions to Launchpad + environment: + LP_CREDENTIALS: "{{ launchpad_token.value }}" + block: + - name: Install zosci-tools + become: true + ansible.builtin.pip: + name: "{{ charmhub_lp_tools_pkg }}" + register: result + until: result is not failed + retries: 10 + delay: 10 + - name: Run charmhub-lp-tool osci-sync + args: + executable: /bin/bash + chdir: "{{ zuul.project.src_dir }}" + shell: | + export LP_CREDENTIALS_FILE=$(mktemp) + echo "{{ LP_CREDENTIALS }}" > $LP_CREDENTIALS_FILE + charmhub-lp-tool osci-sync --repo-dir '{{ zuul.project.src_dir }}' --i-really-mean-it diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 4142c0a..73fdb6b 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -804,6 +804,7 @@ nodes: - name: focal-medium label: focal-medium + - job: name: sqa-integration description: Sets up a sqalab connection for this test environment @@ -812,3 +813,20 @@ abstract: true secrets: - sqalab_environment + +- job: + name: charmhub-osci-sync + description: | + Run `charmhub-lp-tool osci-sync` to update the recipe's definition on + Launchpad. + timeout: 3600 + parent: tox + provides: charm + post-review: true + run: playbooks/charm/charmhub-lp-tool-osci-sync.yaml + nodeset: + nodes: + - name: focal-medium + label: focal-medium + secrets: + - launchpad_token diff --git a/zuul.d/project-templates.yaml b/zuul.d/project-templates.yaml index d46e50d..54e9412 100644 --- a/zuul.d/project-templates.yaml +++ b/zuul.d/project-templates.yaml @@ -330,6 +330,9 @@ # NOTE(icey) BUT REALLY, DO NOT ENABLE THE FOLLOWING UNTIL YOU KNOW WE CAN # RUN A 3.10 JOB ON ZOSCI. #- tox-py310 + promote: + jobs: + - charmhub-osci-sync - project-template: name: charm-publish-jobs description: | diff --git a/zuul.d/secrets.yaml b/zuul.d/secrets.yaml index 8b01474..5336d17 100644 --- a/zuul.d/secrets.yaml +++ b/zuul.d/secrets.yaml @@ -191,3 +191,18 @@ username: ZuulBot uuid: 0c00c563-7e9e-40ab-8db6-738d81aa1ce5 weebl_url: http://10.131.231.53:8080 + +- secret: + name: launchpad_token + data: + value: !encrypted/pkcs1-oaep + - lrEt4pm0PLOo3FrHEXTn3ny2U+vYgBDHumZ28Ehn8RIuPyeW7jzL/6weDoAjUPRH/Uz+d + rVswRrYvAhqM01fRyGFLCThsFZ5l1dOlDHKBLGfJDVYcxuWwo1FZ1kroQnYZwA3/t/epw + qc/oB74syFkgtfPweEEuTOLp6hTgZXt6Ifkv7k9pCkVBflnJScWBrJbUZfu0HljygWbVt + ih7VKMPoog0VACcdouQIhohLoOjTvNlLDzKK5RXUSMucAPuUpqIIASExKdftAMzzLURwO + Z9uJ28XMkfM1rtMZ4SR8VbeKPocitTYfGH3vsaHjR950/nB0eyT9NuRnCM8D+axO7N6ad + DoPqskMFuVMSQ4GvqiArqftB526PnFC64s5G3dWPwEkNaY37YPVccqniP2jdl9vu+3+g8 + 1ZXibCO6erTjNV9PEN9lx3luWsuwtpGhW3STSh3Avln/R5ZgzjngEQ59Gl/3rnoY+VeMT + CbeFL7KRLnkRdIUcb3k95LjLNV02Imc1L6RsGoJFwd2r0rATSUB1noUu+ml1sxUKNZYPW + 3vXXAQmjiyKXoXWYKNXyMWEe3nAHicd/h1+OqW9S+7uxHfAplUlPCPL42WQFARzZDwLhP + yl902fu8O2C8DTiUgbI+KJvcgbxweeXfIony5Uat7PXpLpkIxVS7nt+s2efIaI= From 4d3b364a1e656f050fed8361739a71df2d90d8b1 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Thu, 16 Mar 2023 11:39:59 -0300 Subject: [PATCH 2/2] Pin Jinja2<3.1 This change fixes a warning thrown when running ansible-lint: Warning: : Skipping plugin (/home/runner/work/zosci-config/zosci- config/.tox/linters/lib/python3.8/site- packages/ansible/plugins/filter/mathstuff.py) as it seems to be invalid: cannot import name 'environmentfilter' from 'jinja2.filters' (/home/runner/work/zosci- config/zosci-config/.tox/linters/lib/python3.8/site-packages/jinja2/filters.py) --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index c5a2cb6..ab8bb2d 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,8 @@ deps = # production. # # https://github.com/ansible-community/ansible-lint/issues/1795 + # Warning: : Skipping plugin ([...]/ansible/plugins/filter/mathstuff.py) as it seems to be invalid: cannot import name 'environmentfilter' from 'jinja2.filters' + Jinja2<3.1 rich>=9.5.1,<11.0.0 ansible>=2.8,<=2.9 ansible-lint>=4.2.0,<5