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 verification run scheduler #5647

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ByteOtter
Copy link
Contributor

What?

Add a script which wraps the standard use cases for openqa-clone-custom-git-refspec into a more usable form. Instead of requiring the user to type out the URLs of the openqa.opensuse.org test they want to use it injects all information - like the PR number, base test ID, test modules to load, etc. - into a openqa-clone-custom-git-refspec call.

This script itself does not implement new functionality or behaviour, but is simply a different "front-end" - with a more descriptive name - to use for quickly scheduling verification runs for PRs against e.g os-autoinst.

This is just a thought experiment and could theoretically be integrated into other components without the need for a separate script.

How?

Several parameters are mandatory for the script to function:

  • $SOURCE - Which specifies whether to use openqa.opensuse.org or openqa.suse.de (with custom targets potentially supported via config file)
  • $PR_ID - The ID the GitHub PR
  • $BASE_TEST_ID - The ID of the test the user wants to use as a base
  • $[test/module,...] - A comma sperated list of test modules to load
  • $TEST_NAME - The TEST parameter for the call

The GitHub access token is provided via a config file at ~/.config/gh.conf (name temporary).

Why?

This PR aims to lower the barrier of entry for new contributors and make general test writing easier by having a easy-to-use, descriptively named script a user can call to provide a run for their PR. Instead of going around trying to find the right command.

@foursixnine
Copy link
Member

Following the discussion slack:

  • This could be integrated inside clone-custom-git-refspec directly. That’s more due to how we already work, and I fear introducing a new script might not be 100% the best idea, but its a start already
  • The handling of github tokens is a great adition!
  • on the spec file, perhaps once we figure out what to do, it could be aliased to openqa-verify-pr or a nice short name :D (because openqa-clone-custom-git-refspec is... well, a bit long

@foursixnine foursixnine self-assigned this May 17, 2024
@foursixnine foursixnine self-requested a review May 17, 2024 14:46
elif [ "$source" = "suse" ]; then
echo "Dispatching verification run for suse..."
openqa-clonse-custom-git-refspec "https://github.com/os-autoinst-distri-opensuse/pull/$pr_id" \
"https://openqa.suse.de/tests/$test_id" \
Copy link
Member

Choose a reason for hiding this comment

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

I wonder, are you aware of the existing support for job URL's within the PR description? See https://github.com/os-autoinst/openQA/blob/master/script/openqa-clone-custom-git-refspec#L52

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually wasn't aware of this, thanks for making me aware. That'd make integrating parts of the ideas into openqa-clone-custom-git-refspec even more alluring to take advantage of this feature. @foursixnine, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to mention that we came to the conclusion that it is better to avoid the @-syntax as one probably don't want to mention the @openqa organization on GitHub here. Of course this makes the mentioned feature of the refspec script less interesting - unless one would change it.

However, I suggest to use https://github.com/os-autoinst/scripts/blob/master/openqa-clone-and-monitor-job-from-pr instead (which is already setup for the openSUSE test distribution and uses the openqa: Clone … syntax). It will soon also support creating clones by creating/editing comments but it is so far limited to the PR description.

(You can also read https://open.qa/docs/#_create_and_monitor_openqa_jobs_from_within_the_ci_runner for more information on the broader topic.)

Copy link
Member

@foursixnine foursixnine May 21, 2024

Choose a reason for hiding this comment

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

I actually wasn't aware of this, thanks for making me aware. That'd make integrating parts of the ideas into openqa-clone-custom-git-refspec even more alluring to take advantage of this feature. @foursixnine, what do you think?

Yep its the first point here: #5647 (comment)

I wonder, are you aware of the existing support for job URL's within the PR description?

the extract URLs from description sounds nice, but only useful if it would edit the description and add the badges; I'd say lets keep that out of scope :)

support custom domains of openqa instances.
Configurable in the config file.
@Martchus
Copy link
Contributor

Please capitalize the first letter of the commit message subject lines. It would also be much nicer if openqa-verify_pr was openqa-verify-pr. The formatting of the help text and general coding style is unfortunately not in-line with what we generally use in our scripts. I would at least add a set -e or perhaps even set -eux -o pipefail at the beginning.

Note that additional scripts could also be added to https://github.com/os-autoinst/scripts - although if it is supposed to be distributed via an RPM package keeping it here might be the better option.

@ByteOtter
Copy link
Contributor Author

Thanks for your feedback, I have changed the name and added the set -o pipefail line. Could you elaborate a bit on what you mean with "general coding style"? What do I need to do differently?
Thanks :)

Copy link
Contributor

@Martchus Martchus left a comment

Choose a reason for hiding this comment

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

Generally we use a more compact coding style. I gave a few concrete suggestions in inline-comments.

script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
script/openqa-verify-pr Outdated Show resolved Hide resolved
Co-authored-by: Santiago Zarate <[email protected]>
echo "Dispatching verification run for opensuse..."
openqa-clone-custom-git-refspec "https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/$pr_id" \
"https://openqa.opensuse.org/tests/$test_id" \
SCHEDULE="tests/installation/bootloader_start,tests/boot/boot_to_desktop,$modules" \
Copy link
Member

Choose a reason for hiding this comment

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

Remember to move this to the openqa-clone-custom-git-refspec behind a switch i.e --modules a,b,c so it gets appended via the for loop, before calling cone job.

and then there's the consideration that if the caller is passing:

  • YAML_SCHEDULE + SCHEDULE, die (as one of them has to be overwritten.
  • if the switch is passed, and so is either (yaml_schedule or schedule) die, as options aren't compatible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, currently looking into that :)

@@ -157,6 +182,12 @@ Please try 'curl $json_url' or select another job, e.g. in the same scenario: $h
local scriptdir
scriptdir=$(dirname "${BASH_SOURCE[0]}")
local cmd="$dry_run $scriptdir/openqa-clone-job $clone_args \"$host\" \"$job\" _GROUP=\"$GROUP\" TEST+=\"$test_suffix\" BUILD=\"$build\" CASEDIR=\"$casedir\" PRODUCTDIR=\"$productdir\" NEEDLES_DIR=\"$needles_dir\""
if [[ $cmd =~ (SCHEDULE|YAML_SCHEDULE) ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

is this an and? or an or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's an or, my bad. Though changing it to

if [[ $cmd =~ SCHEDULE ]] && [[ $cmd =~ YAML_SCHEDULE ]]; then
...

doesnt seem to change anythin rn so my problem may be that I am using cmd?

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.

As suggested in chat originally I appreciate that you try to bring in new ideas with pull requests but we should be careful about introducing new scripts. And the same probably goes for the modules command line parameter which is redundant considering the support for generic openQA test variables. Before investing more effort into that I recommend you look into this variables concept in general. Maybe for now you want to focus only on the aspect of reading the github token from a config file which seems independent of the other changes

script/openqa-clone-custom-git-refspec Show resolved Hide resolved
Copy link
Contributor

mergify bot commented Jun 10, 2024

This pull request is now in conflicts. Could you fix it? 🙏

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