Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /job_groups/id/build_results API route #5433

Merged
merged 2 commits into from
Feb 7, 2024

Conversation

perlpunk
Copy link
Contributor

@perlpunk perlpunk commented Jan 23, 2024

Issue: https://progress.opensuse.org/issues/152939

I moved _map_tags_into_build into the compute_build_results() function.

The command lime to get the last "published" build would look like this:

    openqa-cli api job_groups/1/build_results only_tagged=1 limit_builds=1 \
      | jq -r '[.build_results[] | select(.tag.description=="published") | select(.version=="Tumbleweed") | .build ][0]'

To only get the latest build:

    openqa-cli api job_groups/1/build_results  limit_builds=1| jq -r '[.build_results[] | .build ][0]'

Only normal groups are supported, not parent groups, to keep it simple. I can go though our logs to see if the group_overview.json is ever called for parent groups.

I am seeing a problem with the documentation display of the new function when getting a 404. The documentation for the new function is displayed for +/job_groups/<group_id:num>/jobs GET as well as +/job_groups/<group_id:num>/build_results.
Maybe a bug in how Mojolicious renders the pod. I can't see anything wrong there.

Also I found a misdocumented route. I will open a seperate PR.

Still need to document this somewhere.

Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8c66280) 98.37% compared to head (2dd03be) 98.38%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5433   +/-   ##
=======================================
  Coverage   98.37%   98.38%           
=======================================
  Files         389      389           
  Lines       37769    37827   +58     
=======================================
+ Hits        37157    37215   +58     
  Misses        612      612           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@Martchus
Copy link
Contributor

Martchus commented Jan 24, 2024

openqa-cli api job_groups/1/build_results | jq -r '[.build_results[] | .build ][0]'

So the limit_builds parameter is not supported (as on the UI route like this: https://openqa.suse.de/group_overview/110?limit_builds=1)? It would make sense to support the same set of parameters:

openqa-cli api job_groups/1/build_results?limit_builds=1

EDIT: Looks like this would actually already work.

Issue: https://progress.opensuse.org/issues/152939

I moved `_map_tags_into_build` into the `compute_build_results()` function.

The command lime to get the last "published" build would look like this:

    openqa-cli api job_groups/1/build_results only_tagged=1 limit_builds=1 \
      | jq -r '[.build_results[] | select(.tag.description=="published") | select(.version=="Tumbleweed") | .build ][0]'

To only get the latest build:

    openqa-cli api job_groups/1/build_results limit_builds=1 | jq -r '[.build_results[] | .build ][0]'
@perlpunk
Copy link
Contributor Author

perlpunk commented Feb 7, 2024

openqa-cli api job_groups/1/build_results?limit_builds=1

EDIT: Looks like this would actually already work.

I edited the commit message to include limit_builds

@perlpunk perlpunk marked this pull request as ready for review February 7, 2024 15:08
@mergify mergify bot merged commit 0421525 into os-autoinst:master Feb 7, 2024
41 checks passed
@perlpunk perlpunk deleted the latest-build branch February 8, 2024 11:32
@AdamWill
Copy link
Contributor

AdamWill commented Jun 28, 2024

Two tests from this are failing in Fedora, for some reason. $t->json_is('/build_results/4/all_passed' => ''); in t/api/10-jobgroups.t and all_passed => '', in the is_deeply in t/api/04-jobs.t "json representation of group overview (actually not part of the API)" subtest both fail because it's coming out as '0' (or 0, or both...hard to say...thanks perl), not ''. I've no idea why. We have perl 5.40.0-509.fc41 and Mojolicious 9.37; no idea what else would be involved in the JSONification. I can just patch the expected result, I guess - functionally, '0' should behave the same as '', they both evaluate false in if checks, which is what this is used for - but it's weird.

@AdamWill
Copy link
Contributor

Huh, this "fixes" it:

-    $build_res->{all_passed} = $build_res->{passed} + $build_res->{softfailed} >= $build_res->{total};
+    $build_res->{all_passed} = $build_res->{passed} + $build_res->{softfailed} >= $build_res->{total} ? "1" : "";

...weird.

@AdamWill
Copy link
Contributor

AdamWill commented Jun 28, 2024

Hmm, this feels very fuzzy. If I make the code into this:

$build_res->{all_passed} = $build_res->{passed} + $build_res->{softfailed} >= $build_res->{total} ? 1 : 0;

and then make the check this:

$t->json_is('/build_results/4/all_passed' => 0);

it passes, not surprisingly. But it also passes if I make the check this:

$t->json_is('/build_results/4/all_passed' => "0");

so it "is" both 0 and "0"? Hmm.

@AdamWill
Copy link
Contributor

#5731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants