PoC: triggering of maintenance tests for openSUSE#473
Conversation
We need to query the source packages of the update to be able to figure out the name of the given staged update, for now we're sticking to the promise that staged updates are single units
Avoid multiple nested ifs, to the code more readable
This is mainly to avoid collisions later on
Build parameter was missing, so query would return all jobs for given parameters
| from collections import namedtuple | ||
| import osc.core | ||
|
|
||
| USER_AGENT = "manual-trigger.py (https://github.com/os-autoinst/scripts)" |
There was a problem hiding this comment.
There are probably still many improvements to be made but it looks like this would generally work.
This is indeed very similar to what I have already created in qem-bot except that no external dashboard is involved. So this is now kind of a mix between qem-bot gitea-sync and qem-bot increment-approve. (It would be nice if we wouldn't have to duplicate our effort here but I also don't see an easy way of streamlining this. In theory qem-bot could be used for openSUSE as well, though.)
It would be nice to document the usage with some examples in the README.
| dry_run = True | ||
| openqa_dry_run = False |
There was a problem hiding this comment.
It is a bit confusing that dry_run is sometimes shadowed by local variables. Both variables should probably be CLI arguments. Considering you're doing proper CLI argument parsing anyway this shouldn't be a big deal.
| "scope": "relevant", | ||
| "latest": "1", | ||
| } | ||
| jobs = openqa.openqa_request("GET", "jobs", values)["jobs"] |
There was a problem hiding this comment.
I guess this is good enough for now. I'd just like to note that there's a route which gets you all jobs of the latest scheduled product matching the parameters you're using here as well: https://github.com/os-autoinst/openQA/blob/345b0552e13c159d5b31d8403813125b29332929/lib/OpenQA/WebAPI/Controller/API/V1/Iso.pm#L61
With this route you could for instance drop the logic to skip clones and it would only check jobs scheduled via the relevant scheduled products.
I created this route for doing the same what you're doing here in qem-bot so you can find Python code using it in https://github.com/openSUSE/qem-bot/blob/master/openqabot/incrementapprover.py. (This code also has unit tests.)
| else: | ||
| packages.append(package) | ||
|
|
||
| # In theory every staged update, has a single package |
There was a problem hiding this comment.
If that's also true in practice then this is different from what I have been dealing with for SLFO/SLE16 on the internal Gitea/IBS.
There was a problem hiding this comment.
My theory was wrong :), https://src.opensuse.org/products/PackageHub/pulls/192 has two packages for instance.
This part now computes the shortest package name: https://github.com/foursixnine/openSUSE-release-tools/blob/92f405972f5cba472c3c7e3efb85a82a6b0c44df/git-openqa-maintenance.py#L287
|
|
||
| def get_open_prs_for_project_branch(project, branch): | ||
| pull_requests_url = ( | ||
| GITEA_HOST + f"/api/v1/repos/{project}/pulls?state=open&base_branch={branch}" |
There was a problem hiding this comment.
When I remember correctly, this will only consider the first 50 PRs or so. You could steal the while loop from https://github.com/openSUSE/qem-bot/blob/44a89a2bb5fe46167169759804a59de3bfc8eb89/openqabot/loader/gitea.py#L138 for paging. (If there are tons of open PRs this won't be very fast, though.)
(Maybe I can make use of the base_branch search parameter in qem-bot as well.)
That's why we have https://progress.opensuse.org/issues/189912 planned. Meanwhile I would recommend to incorporate the necessary functionality within qem-bot to replace this implementation here |
Yeah
That is something I would like too, having three different bots doesn't sound very sustainable In the meantime I extracted this, and created openSUSE/openSUSE-release-tools#3271 which handles the full workflow (an example is the PR I already linked above https://src.opensuse.org/products/PackageHub/pulls/192)
|
|
Ok, good to know that there's a more up-to-date version of this. Then I'll try it out and update my findings on https://progress.opensuse.org/projects/openqatests/wiki/Wiki#Scheduling-maintenance-tests-for-openSUSE-Leap-16. To avoid confusion I would close this draft in favor of openSUSE/openSUSE-release-tools#3271, or do you still want anything to be merged here? |
No objections, this was never meant to be merged here :) |
Ticket: https://progress.opensuse.org/issues/190158
This script is only a proof of concept based of what I understood of what openqabot does.
I basically started off from #468 for some boilerplate and ended up with this script. So aside from requiring
GITEA_TOKENas environment variable, it also requires osc credentials for the given build service api (--bs, defaults to api.opensuse.org)To call it:
Which results in the following openqa-cli call:
This is mostly the flow for incident updates (or staged updates), I don't quite get yet how the aggregated updates are handled.
There's also a hardcoded architecture, but that shouldn't be a blocker at this stage, I tried this on my local openQA instance with the following job-group:
Machine and test settings were taken from openqa.opensuse.org
PR data can be passed with
--pr-data tests/data/opensuse-maintenance/by-autogits_workflow_pr_bot-151-20251007-154142.json, there's a switch to store the pr data too.