From 23b2be0b8688b6db3e8814b87bab0a0258fedbe1 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Fri, 17 May 2024 15:57:43 +0200 Subject: [PATCH 01/14] add scheduler script --- script/schedule_verficiation_run.sh | 126 ++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 script/schedule_verficiation_run.sh diff --git a/script/schedule_verficiation_run.sh b/script/schedule_verficiation_run.sh new file mode 100755 index 00000000000..4f06a05fe93 --- /dev/null +++ b/script/schedule_verficiation_run.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# Copyright 2024 (c) SUSE LLC +# SPDX-License-Identifier: GPL-2.0-or-later + +# Schedule a verification run for a os-autoinst PR +# USAGE: +# +# schedule_verification_run $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module, ...] $TEST_NAME +# +# Parameters +# +# * $SOURCE - The source you want to schedule a rund for. Can be either opensuse or suse. +# * $PR_ID - The ID of your GitHub Pull Request. +# * $BASE_TEST_ID - The ID of the test you want you use as a base. +# * $[test/module, ...] - The modules of your test you want to schedule for. +# * $TEST_NAME - The Name of your test. (E.g.: TETS=RUST) +# +# Specify your GitHub access token in a config file at '~/.config/openqa/gh.conf' like this: +# +# ``` +# GH_ACCESS_TOKEN="YOUR_TOKEN_HERE" +# ``` +# +# Default test modules +# +# The following modules are automatically selected to load for your run: +# +# * 'tests/installation/bootloader_start' +# * 'tests/boot/boot_to_desktop' +# +# Example +# +# Pass arguments to this script like this: +# +# schedule_verification_run opensuse TOKEN 1234 12345 tests/console/rustup,tests/console/cargo RUST + + +help_text=$(cat <<'EOF' +OpenQA verification run scheduler. + +USAGE: +====== + +$ schedule_verification_run \$SOURCE \$PR_ID \$BASE_TEST_ID \$[test/module, test/module,...] \$TEST_NAME + +Parameters +---------- + +* \$SOURCE - The source you want to schedule a rund for. Can be either opensuse or suse. +* \$PR_ID - The ID of your GitHub Pull Request. +* \$BASE_TEST_ID - The ID of the test you want you use as a base. +* \$[test/module,...] - The modules of your test you want to schedule for. +* \$TEST_NAME - The Name of your test. (E.g.: TEST=RUST) + +Specify your GitHub access token in '~/.config/openqa/gh.conf' like this: + +``` +GH_ACCESS_TOKEN="YOUR_TOKEN_HERE" +``` + +Default test modules +-------------------- + +The following modules are automatically selected to load for your run: + +* 'tests/installation/bootloader_start' +* 'tests/boot/boot_to_desktop' + +Options +------- + +* '-h' / '--help' - Display this help text. + +EOF +) + +source="$1" +pr_id="$2" +test_id="$3" +modules="$4" +test_name="$5" + +config_file="$HOME/.config/openqa/gh.conf" +config="" + +# See help text. +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "$help_text" + exit 0 +fi + +# If too few or too many arguments are supplied -> die. +if [ "$#" -ne 5 ]; then + echo "Invalid number of arguments. Run with '-h' or '--help' to view usage." + exit 1 +fi + +# Read GH token from config file. +if [[ -f "$config_file" ]]; then + config=$(grep "^GH_ACCESS_TOKEN=" "$config_file" | cut -d'"' -f2) +else + echo "No GitHub token file found! Run with '-h' for more info." + exit 1 +fi + +GITHUB_TOKEN=$config + +export GITHUB_TOKEN + +if [ "$source" = "opensuse" ]; then + 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" \ + TEST="$test_name" +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" \ + SCHEDULE="tests/installation/bootloader_start,tests/boot/boot_to_desktop,$modules" \ + TEST="$test_name" +else + # NOTE: Technically we could support custom targets via a config file. TBI. + echo "Unknown argument '$1'. Must be either 'suse' or 'opensuse'. Custom openqa instances not yet supported." + exit 1 +fi From 42fb4e74fa7f21268c33b4e4506e42c4ad8f62e0 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Tue, 21 May 2024 11:18:13 +0200 Subject: [PATCH 02/14] update script naming to fit convention --- script/{schedule_verficiation_run.sh => openqa-verify_pr} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename script/{schedule_verficiation_run.sh => openqa-verify_pr} (100%) diff --git a/script/schedule_verficiation_run.sh b/script/openqa-verify_pr similarity index 100% rename from script/schedule_verficiation_run.sh rename to script/openqa-verify_pr From 33a384b95f1057846915a5bc1b07b02212720b67 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Tue, 21 May 2024 11:19:54 +0200 Subject: [PATCH 03/14] fix help text --- script/openqa-verify_pr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/openqa-verify_pr b/script/openqa-verify_pr index 4f06a05fe93..de2658c1d43 100755 --- a/script/openqa-verify_pr +++ b/script/openqa-verify_pr @@ -41,7 +41,7 @@ OpenQA verification run scheduler. USAGE: ====== -$ schedule_verification_run \$SOURCE \$PR_ID \$BASE_TEST_ID \$[test/module, test/module,...] \$TEST_NAME +$ schedule_verification_run $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module,...] $TEST_NAME Parameters ---------- From 6c9dc7eac79f70f1b73fd949f96bf1dac72d0ab6 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Tue, 21 May 2024 16:42:28 +0200 Subject: [PATCH 04/14] support custom target domains support custom domains of openqa instances. Configurable in the config file. --- script/openqa-verify_pr | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/script/openqa-verify_pr b/script/openqa-verify_pr index de2658c1d43..32f34c038f1 100755 --- a/script/openqa-verify_pr +++ b/script/openqa-verify_pr @@ -52,12 +52,18 @@ Parameters * \$[test/module,...] - The modules of your test you want to schedule for. * \$TEST_NAME - The Name of your test. (E.g.: TEST=RUST) -Specify your GitHub access token in '~/.config/openqa/gh.conf' like this: +Specify your GitHub access token in '~/.config/openqa/verification.conf' like this: ``` GH_ACCESS_TOKEN="YOUR_TOKEN_HERE" ``` +To specify the URL to your own openQA instance specify it in the same config file like this: + +``` +CUSTOM_TARGET="https://openqa.yourdomain.com" +``` + Default test modules -------------------- @@ -80,8 +86,9 @@ test_id="$3" modules="$4" test_name="$5" -config_file="$HOME/.config/openqa/gh.conf" +config_file="$HOME/.config/openqa/verification.conf" config="" +custom_target="" # See help text. if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then @@ -98,8 +105,9 @@ fi # Read GH token from config file. if [[ -f "$config_file" ]]; then config=$(grep "^GH_ACCESS_TOKEN=" "$config_file" | cut -d'"' -f2) + custom_target=$(grep "^CUSTOM_TARGET=" "$config_file" | cut -d'"' -f2) else - echo "No GitHub token file found! Run with '-h' for more info." + echo "No config file found! Run with '-h' for more info." exit 1 fi @@ -119,8 +127,14 @@ elif [ "$source" = "suse" ]; then "https://openqa.suse.de/tests/$test_id" \ SCHEDULE="tests/installation/bootloader_start,tests/boot/boot_to_desktop,$modules" \ TEST="$test_name" +elif [ "$source" = "custom" ]; then + echo "Dispatching verification run for your custom target '$custom_target'..." + openqa-clone-custom-git-refspec "https://github.com/os-autoinst-distri-opensuse/pull/$pr_id" \ + "$custom_target/tests/$test_id" \ + SCHEDULE="tests/installation/bootloader_start,tests/boot/boot_to_desktop,$modules" \ + TEST="$test_name" else # NOTE: Technically we could support custom targets via a config file. TBI. - echo "Unknown argument '$1'. Must be either 'suse' or 'opensuse'. Custom openqa instances not yet supported." + echo "Unknown argument '$1'. Must be either 'suse', 'opensuse' or 'custom'." exit 1 fi From c7f23eee7bd9b614c1b89b9259c3be860c8a70e6 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 22 May 2024 10:12:36 +0200 Subject: [PATCH 05/14] Fix style of help text --- script/{openqa-verify_pr => openqa-verify-pr} | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) rename script/{openqa-verify_pr => openqa-verify-pr} (83%) diff --git a/script/openqa-verify_pr b/script/openqa-verify-pr similarity index 83% rename from script/openqa-verify_pr rename to script/openqa-verify-pr index 32f34c038f1..499c525e034 100755 --- a/script/openqa-verify_pr +++ b/script/openqa-verify-pr @@ -38,48 +38,38 @@ help_text=$(cat <<'EOF' OpenQA verification run scheduler. -USAGE: -====== +Usage: + schedule_verification_run $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module,...] $TEST_NAME -$ schedule_verification_run $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module,...] $TEST_NAME - -Parameters ----------- - -* \$SOURCE - The source you want to schedule a rund for. Can be either opensuse or suse. -* \$PR_ID - The ID of your GitHub Pull Request. -* \$BASE_TEST_ID - The ID of the test you want you use as a base. -* \$[test/module,...] - The modules of your test you want to schedule for. -* \$TEST_NAME - The Name of your test. (E.g.: TEST=RUST) +Parameters: + SOURCE - The source you want to schedule a run for. Can be either opensuse or suse. + PR_ID - The ID of your GitHub Pull Request. + BASE_TEST_ID - The ID of the test you want you use as a base. + [test/module,...] - The modules of your test you want to schedule for. + TEST_NAME - The Name of your test. (E.g.: TEST=RUST) Specify your GitHub access token in '~/.config/openqa/verification.conf' like this: -``` GH_ACCESS_TOKEN="YOUR_TOKEN_HERE" -``` To specify the URL to your own openQA instance specify it in the same config file like this: -``` CUSTOM_TARGET="https://openqa.yourdomain.com" -``` - -Default test modules --------------------- +Default test modules: The following modules are automatically selected to load for your run: -* 'tests/installation/bootloader_start' -* 'tests/boot/boot_to_desktop' + 'tests/installation/bootloader_start' + 'tests/boot/boot_to_desktop' -Options -------- - -* '-h' / '--help' - Display this help text. +Options: + -h, --help Display this help text. EOF ) +set -o pipefail + source="$1" pr_id="$2" test_id="$3" From 6bd62d6363800f8fcb34ddcef2b38764814015a9 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 22 May 2024 14:31:21 +0200 Subject: [PATCH 06/14] Apply coding style feedback --- script/openqa-verify-pr | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/script/openqa-verify-pr b/script/openqa-verify-pr index 499c525e034..2ab0a03efe7 100755 --- a/script/openqa-verify-pr +++ b/script/openqa-verify-pr @@ -36,14 +36,14 @@ help_text=$(cat <<'EOF' -OpenQA verification run scheduler. +OpenQA verification run scheduler Usage: - schedule_verification_run $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module,...] $TEST_NAME + openqa-verify-pr $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module,...] $TEST_NAME Parameters: - SOURCE - The source you want to schedule a run for. Can be either opensuse or suse. - PR_ID - The ID of your GitHub Pull Request. + SOURCE - The source you want to schedule a run for. Can be either 'opensuse' or 'suse'. + PR_ID - The ID of your GitHub pull request. BASE_TEST_ID - The ID of the test you want you use as a base. [test/module,...] - The modules of your test you want to schedule for. TEST_NAME - The Name of your test. (E.g.: TEST=RUST) @@ -70,30 +70,22 @@ EOF set -o pipefail -source="$1" -pr_id="$2" -test_id="$3" -modules="$4" -test_name="$5" +source=$1 pr_id=$2 test_id=$3 modules=$4 test_name=$5 +config_file=$HOME/.config/openqa/verification.conf config= custom_target= -config_file="$HOME/.config/openqa/verification.conf" -config="" -custom_target="" - -# See help text. if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "$help_text" exit 0 fi -# If too few or too many arguments are supplied -> die. -if [ "$#" -ne 5 ]; then +# Validate argument count +if [ $# -ne 5 ]; then echo "Invalid number of arguments. Run with '-h' or '--help' to view usage." exit 1 fi # Read GH token from config file. -if [[ -f "$config_file" ]]; then +if [[ -f $config_file ]]; then config=$(grep "^GH_ACCESS_TOKEN=" "$config_file" | cut -d'"' -f2) custom_target=$(grep "^CUSTOM_TARGET=" "$config_file" | cut -d'"' -f2) else @@ -101,9 +93,7 @@ else exit 1 fi -GITHUB_TOKEN=$config - -export GITHUB_TOKEN +export GITHUB_TOKEN=$config if [ "$source" = "opensuse" ]; then echo "Dispatching verification run for opensuse..." From b7737ac171bae2283f4d1382a8cc9d529299827d Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 22 May 2024 14:37:40 +0200 Subject: [PATCH 07/14] Fix text formatting --- script/openqa-verify-pr | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/script/openqa-verify-pr b/script/openqa-verify-pr index 2ab0a03efe7..b48fa18119a 100755 --- a/script/openqa-verify-pr +++ b/script/openqa-verify-pr @@ -1,32 +1,33 @@ #!/bin/bash -# Copyright 2024 (c) SUSE LLC +# Copyright 2024 SUSE LLC # SPDX-License-Identifier: GPL-2.0-or-later -# Schedule a verification run for a os-autoinst PR -# USAGE: +# OpenQA verification run scheduler # -# schedule_verification_run $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module, ...] $TEST_NAME +# Usage: +# openqa-verify-pr $SOURCE $PR_ID $BASE_TEST_ID $[test/module, test/module,...] $TEST_NAME # -# Parameters +# Parameters: +# SOURCE - The source you want to schedule a run for. Can be either 'opensuse' or 'suse'. +# PR_ID - The ID of your GitHub pull request. +# BASE_TEST_ID - The ID of the test you want you use as a base. +# [test/module,...] - The modules of your test you want to schedule for. +# TEST_NAME - The Name of your test. (E.g.: TEST=RUST) # -# * $SOURCE - The source you want to schedule a rund for. Can be either opensuse or suse. -# * $PR_ID - The ID of your GitHub Pull Request. -# * $BASE_TEST_ID - The ID of the test you want you use as a base. -# * $[test/module, ...] - The modules of your test you want to schedule for. -# * $TEST_NAME - The Name of your test. (E.g.: TETS=RUST) +# Specify your GitHub access token in '~/.config/openqa/verification.conf' like this: # -# Specify your GitHub access token in a config file at '~/.config/openqa/gh.conf' like this: -# -# ``` # GH_ACCESS_TOKEN="YOUR_TOKEN_HERE" -# ``` # -# Default test modules +# To specify the URL to your own openQA instance specify it in the same config file like this: # -# The following modules are automatically selected to load for your run: +# CUSTOM_TARGET="https://openqa.yourdomain.com" # -# * 'tests/installation/bootloader_start' -# * 'tests/boot/boot_to_desktop' +# Default test modules +# 'tests/installation/bootloader_start' +# 'tests/boot/boot_to_desktop' +# +# Options: +# -h, --help Display this help text. # # Example # @@ -57,8 +58,6 @@ To specify the URL to your own openQA instance specify it in the same config fil CUSTOM_TARGET="https://openqa.yourdomain.com" Default test modules: -The following modules are automatically selected to load for your run: - 'tests/installation/bootloader_start' 'tests/boot/boot_to_desktop' @@ -73,7 +72,7 @@ set -o pipefail source=$1 pr_id=$2 test_id=$3 modules=$4 test_name=$5 config_file=$HOME/.config/openqa/verification.conf config= custom_target= -if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then +if [ $1 = '-h' ] || [ $1 = '--help' ]; then echo "$help_text" exit 0 fi From dbac7fb1c59c930775b31d1d9c281669a2861d5d Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 22 May 2024 16:36:03 +0200 Subject: [PATCH 08/14] Remove unnecessary quotations --- script/openqa-verify-pr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/openqa-verify-pr b/script/openqa-verify-pr index b48fa18119a..3a81bc3299b 100755 --- a/script/openqa-verify-pr +++ b/script/openqa-verify-pr @@ -94,19 +94,19 @@ fi export GITHUB_TOKEN=$config -if [ "$source" = "opensuse" ]; then +if [ $source = 'opensuse' ]; then 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" \ TEST="$test_name" -elif [ "$source" = "suse" ]; then +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" \ SCHEDULE="tests/installation/bootloader_start,tests/boot/boot_to_desktop,$modules" \ TEST="$test_name" -elif [ "$source" = "custom" ]; then +elif [ $source = 'custom' ]; then echo "Dispatching verification run for your custom target '$custom_target'..." openqa-clone-custom-git-refspec "https://github.com/os-autoinst-distri-opensuse/pull/$pr_id" \ "$custom_target/tests/$test_id" \ From b113b10ead342e7f19b3fa9069cac6023eb34ed2 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Tue, 28 May 2024 15:22:08 +0200 Subject: [PATCH 09/14] Merge token retrieval into clone-custom-git-refspec script --- script/openqa-clone-custom-git-refspec | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index 2fa950ed88d..a7b59946dc2 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -32,6 +32,9 @@ set -o pipefail if [[ -n "$GITHUB_TOKEN" ]]; then AUTHENTICATED_REQUEST=" -u $GITHUB_TOKEN:x-oauth-basic" echo "Github oauth token provided, performing authenticated requests" +elif [[ -f "$HOME/.config/openqa/verification.conf" ]]; then + AUTHENTICATED_REQUEST=" -u $(get_token_from_file):x-oauth-basic" + echo "Github oauth token found in config file, performing authenticated requests" fi curl_github="${curl_github:-"curl${AUTHENTICATED_REQUEST}"}" @@ -55,6 +58,16 @@ extract_urls_from_pr() { fi } +# Get the Github Token from a config file +# located at ~/.config/openqa/verification.conf +get_token_from_file() { + local config_file="$HOME/.config/openqa/verification.conf" + if [[ -f $config_file ]]; then + token=$(grep "^GH_ACCESS_TOKEN=" "$config_file" | cut -d'd' -f2) + echo "$token" + fi +} + opts=$(getopt -o vhnc: --long verbose,dry-run,help,clone-job-args: -n "$0" -- "$@") || usage 1 eval set -- "$opts" while true; do @@ -97,8 +110,8 @@ if [[ -z "$repo_name" ]] || [[ -z "$pr" ]]; then casedir="${casedir:-"${forked_repo_part}.git#${branch}"}" build="${build:-"$repo_name#$branch"}" fi - fi + if [[ -z "$branch" ]] || [[ -z "$repo_name" ]]; then pr_url=${target_repo_part/github.com/api.github.com/repos}/pulls/$pr pr_content=$(eval "${curl_github} -s $pr_url") From f8fc47ba849be1d640c7e38ba818a1b50f9b6dd9 Mon Sep 17 00:00:00 2001 From: Christopher Hock Date: Wed, 29 May 2024 10:09:20 +0200 Subject: [PATCH 10/14] Change name of configuration file Co-authored-by: Santiago Zarate --- script/openqa-clone-custom-git-refspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index a7b59946dc2..fa2879a6b36 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -32,7 +32,7 @@ set -o pipefail if [[ -n "$GITHUB_TOKEN" ]]; then AUTHENTICATED_REQUEST=" -u $GITHUB_TOKEN:x-oauth-basic" echo "Github oauth token provided, performing authenticated requests" -elif [[ -f "$HOME/.config/openqa/verification.conf" ]]; then +elif [[ -f "$HOME/.config/openqa/github-token.conf" ]]; then AUTHENTICATED_REQUEST=" -u $(get_token_from_file):x-oauth-basic" echo "Github oauth token found in config file, performing authenticated requests" fi From d1030774b5dc846cabb0cc95696c5600b1b7f537 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 29 May 2024 11:47:18 +0200 Subject: [PATCH 11/14] Implement --modules flag --- script/openqa-clone-custom-git-refspec | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index fa2879a6b36..80063c0c094 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -12,16 +12,23 @@ Options: -v, --verbose execute with verbose output -h, -?, --help display this help -n, --dry-run execute in dry-run mode, do not clone any openQA jobs + -m, --modules specify the tets modules you want to load as a comma-separated list of paths to your test files -c --clone-job-args pass additional parameters to 'openqa-clone-job', e.g. '--clone-job-args="--show-progress"'. The default parameters are '$clone_args' defined in the env variable \$clone_args. Examples: - openqa-clone-custom-git-refspec https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/6529 https://openqa.opensuse.org/tests/835060 DESKTOP=textmode + openqa-clone-custom-git-refspec https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/6529D https://openqa.opensuse.org/tests/835060 DESKTOP=textmode openqa-clone-custom-git-refspec https://github.com/coolgw/os-autoinst-distri-opensuse/tree/nfs https://openqa.opensuse.org/tests/835060 DESKTOP=textmode openqa-clone-custom-git-refspec -n -c '--show-progress' https://github.com/coolgw/os-autoinst-distri-opensuse/tree/nfs https://openqa.opensuse.org/tests/835060 DESKTOP=textmode openqa-clone-custom-git-refspec https://github.com/foursixnine/os-autoinst-distri-opensuse/tree/oopsitsbrokenagain https://openqa.opensuse.org/tests/3128467 NEEDLES_DIR='https://github.com/foursixnine/os-autoinst-needles-opensuse.git#oopsitsbrokenagain' + openqa-clone-custom-git-refspec -m tests/console/rust_rustup,tests/console/rust_cargo https://github.com/os-autoinst-distri-opensuse/os-autoinst-distri-opensuse/pull/19080 https://openqa.opensuse.org/tests/835060 -You need to set the environment variable GITHUB_TOKEN to use authenticated requests. +To use authenticated requests, you need to either provide a GitHub token via a configuration file at '~/.config/openqa/github-token.conf' or set +the GITHUB_TOKEN environment variable. + +Example of the config file option: + + GITHUB_ACCESS_TOKEN="you_token_here" EOF exit "$1" @@ -61,15 +68,16 @@ extract_urls_from_pr() { # Get the Github Token from a config file # located at ~/.config/openqa/verification.conf get_token_from_file() { - local config_file="$HOME/.config/openqa/verification.conf" + local config_file="$HOME/.config/openqa/github-token.conf" if [[ -f $config_file ]]; then token=$(grep "^GH_ACCESS_TOKEN=" "$config_file" | cut -d'd' -f2) echo "$token" fi } -opts=$(getopt -o vhnc: --long verbose,dry-run,help,clone-job-args: -n "$0" -- "$@") || usage 1 +opts=$(getopt -o vhnm:c: --long verbose,dry-run,help,modules:,clone-job-args: -n "$0" -- "$@") || usage 1 eval set -- "$opts" +modules="" while true; do case "$1" in -v | --verbose) @@ -81,6 +89,10 @@ while true; do dry_run=true shift ;; + -m | --modules) + modules="$2" + shift 2 + ;; -c | --clone-job-args) clone_args="$2 $clone_args" shift 2 @@ -170,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 + fail "Error: 'SCHEDULE' and 'YAML_SCHEDULE' are set in '--clone-job-args'. Cannot continue as they are mutually exclusive!" + fi + if [[ -n "$modules" ]] && [[ $cmd =~ (SCHEDULE|YAML_SCHEDULE) ]]; then + fail "Error: '--modules' flag cannot exist when passing 'SCHEDULE' or 'YAML_SCHEDULE' with '--clone-job-args'!" + fi [[ ${#args[@]} -ne 0 ]] && cmd=$cmd"$(printf " '%s'" "${args[@]}")" if [[ -n "$MARKDOWN" ]]; then eval "$cmd" | sed 's/^Created job.*: \([^ ]*\) -> \(.*\)$/* [\1](\2)/' From 95c234ee40d0f6ca7cdcf9cf76a724dcbd409886 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 29 May 2024 11:48:52 +0200 Subject: [PATCH 12/14] Fix typo in example --- script/openqa-clone-custom-git-refspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index 80063c0c094..c726b0aaff0 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -17,7 +17,7 @@ Options: The default parameters are '$clone_args' defined in the env variable \$clone_args. Examples: - openqa-clone-custom-git-refspec https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/6529D https://openqa.opensuse.org/tests/835060 DESKTOP=textmode + openqa-clone-custom-git-refspec https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/6529 https://openqa.opensuse.org/tests/835060 DESKTOP=textmode openqa-clone-custom-git-refspec https://github.com/coolgw/os-autoinst-distri-opensuse/tree/nfs https://openqa.opensuse.org/tests/835060 DESKTOP=textmode openqa-clone-custom-git-refspec -n -c '--show-progress' https://github.com/coolgw/os-autoinst-distri-opensuse/tree/nfs https://openqa.opensuse.org/tests/835060 DESKTOP=textmode openqa-clone-custom-git-refspec https://github.com/foursixnine/os-autoinst-distri-opensuse/tree/oopsitsbrokenagain https://openqa.opensuse.org/tests/3128467 NEEDLES_DIR='https://github.com/foursixnine/os-autoinst-needles-opensuse.git#oopsitsbrokenagain' From 1c3a1e21f3975f26464145d83c3e27d1012a60d1 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 29 May 2024 12:54:50 +0200 Subject: [PATCH 13/14] Move token collection after function declaration --- script/openqa-clone-custom-git-refspec | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index c726b0aaff0..7c826c16060 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -36,17 +36,6 @@ EOF set -o pipefail -if [[ -n "$GITHUB_TOKEN" ]]; then - AUTHENTICATED_REQUEST=" -u $GITHUB_TOKEN:x-oauth-basic" - echo "Github oauth token provided, performing authenticated requests" -elif [[ -f "$HOME/.config/openqa/github-token.conf" ]]; then - AUTHENTICATED_REQUEST=" -u $(get_token_from_file):x-oauth-basic" - echo "Github oauth token found in config file, performing authenticated requests" -fi - -curl_github="${curl_github:-"curl${AUTHENTICATED_REQUEST}"}" -curl_openqa="${curl_openqa:-"curl"}" - fail() { echo "$*" >&2 exit 1 @@ -75,6 +64,18 @@ get_token_from_file() { fi } +if [[ -n "$GITHUB_TOKEN" ]]; then + AUTHENTICATED_REQUEST=" -u $GITHUB_TOKEN:x-oauth-basic" + echo "Github oauth token provided, performing authenticated requests" +elif [[ -f "$HOME/.config/openqa/github-token.conf" ]]; then + AUTHENTICATED_REQUEST=" -u $(get_token_from_file):x-oauth-basic" + echo "Github oauth token found in config file, performing authenticated requests" +fi + +curl_github="${curl_github:-"curl${AUTHENTICATED_REQUEST}"}" +curl_openqa="${curl_openqa:-"curl"}" + + opts=$(getopt -o vhnm:c: --long verbose,dry-run,help,modules:,clone-job-args: -n "$0" -- "$@") || usage 1 eval set -- "$opts" modules="" @@ -182,7 +183,8 @@ 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 + # FIXME: This does not work yet. Maybe I am checking the wrong list of arguments + if [[ $cmd =~ "SCHEDULE" ]] && [[ $cmd =~ "YAML_SCHEDULE" ]]; then fail "Error: 'SCHEDULE' and 'YAML_SCHEDULE' are set in '--clone-job-args'. Cannot continue as they are mutually exclusive!" fi if [[ -n "$modules" ]] && [[ $cmd =~ (SCHEDULE|YAML_SCHEDULE) ]]; then From f1ab36fe9c6ee6923d8fccdb6c9d76cd73415bdc Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Wed, 29 May 2024 14:23:48 +0200 Subject: [PATCH 14/14] Update scripts (tmp) --- script/openqa-clone-custom-git-refspec | 13 +++++++------ script/openqa-verify-pr | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/script/openqa-clone-custom-git-refspec b/script/openqa-clone-custom-git-refspec index 7c826c16060..8d3b3953241 100755 --- a/script/openqa-clone-custom-git-refspec +++ b/script/openqa-clone-custom-git-refspec @@ -184,12 +184,6 @@ Please try 'curl $json_url' or select another job, e.g. in the same scenario: $h 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\"" # FIXME: This does not work yet. Maybe I am checking the wrong list of arguments - if [[ $cmd =~ "SCHEDULE" ]] && [[ $cmd =~ "YAML_SCHEDULE" ]]; then - fail "Error: 'SCHEDULE' and 'YAML_SCHEDULE' are set in '--clone-job-args'. Cannot continue as they are mutually exclusive!" - fi - if [[ -n "$modules" ]] && [[ $cmd =~ (SCHEDULE|YAML_SCHEDULE) ]]; then - fail "Error: '--modules' flag cannot exist when passing 'SCHEDULE' or 'YAML_SCHEDULE' with '--clone-job-args'!" - fi [[ ${#args[@]} -ne 0 ]] && cmd=$cmd"$(printf " '%s'" "${args[@]}")" if [[ -n "$MARKDOWN" ]]; then eval "$cmd" | sed 's/^Created job.*: \([^ ]*\) -> \(.*\)$/* [\1](\2)/' @@ -203,6 +197,13 @@ if [[ -z "$host" ]] && [[ -z "$job_list" ]]; then exit 1 fi args=("${@:3}") +if [[ $(echo "${args[*]}" | grep -q "SCHEDULE") ]] && [[ $(echo "${args[*]}" | grep -q "YAML_SCHEDULE") ]]; then + fail "Error: 'SCHEDULE' and 'YAML_SCHEDULE' are set in '--clone-job-args'. Cannot continue as they are mutually exclusive!" +fi +if [[ -n "$modules" ]] && ([[ $(echo "${args[*]}" | grep -q "SCHEDULE") ]] || [[ $(echo "${args[*]}" | grep -q "YAML_SCHEDULE") ]]); then + fail "Error: '--modules' flag cannot exist when passing 'SCHEDULE' or 'YAML_SCHEDULE' with '--clone-job-args'!" +fi + IFS=',' for i in $job_list; do clone_job "$i" diff --git a/script/openqa-verify-pr b/script/openqa-verify-pr index 3a81bc3299b..03ca00d0068 100755 --- a/script/openqa-verify-pr +++ b/script/openqa-verify-pr @@ -84,6 +84,7 @@ if [ $# -ne 5 ]; then fi # Read GH token from config file. +# TODO: Wrap into function. Call it in clone-custom-refspec when $TOKEN not set. if [[ -f $config_file ]]; then config=$(grep "^GH_ACCESS_TOKEN=" "$config_file" | cut -d'"' -f2) custom_target=$(grep "^CUSTOM_TARGET=" "$config_file" | cut -d'"' -f2) @@ -99,6 +100,7 @@ if [ $source = 'opensuse' ]; then 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" \ + YAML_SCHEDULE="" \ TEST="$test_name" elif [ $source = 'suse' ]; then echo "Dispatching verification run for suse..."