-
Notifications
You must be signed in to change notification settings - Fork 26
Add usage+help to all scripts #331
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
base: master
Are you sure you want to change the base?
Changes from all commits
9eaa9f5
165b4f8
6ba6ead
09f7b6a
60b594c
1ec6e90
842a969
ed77bda
0b48d10
2e69af6
563ddc4
bd70d13
8e4c59f
6af4dd8
d15e9ce
47783ff
cb357ca
92bda47
d38eb77
9bd19ce
ffc2193
e24499a
ba70c56
955f617
0f472bc
3b1285f
a67e19a
2f71372
c6f5bc1
43576b1
995f31b
fbcd436
9d8a9b2
efc133c
2ee3cbf
00fa80a
210795c
532aad8
7881226
e925b2d
a3722ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,39 @@ | ||
| #!/bin/sh -e | ||
| #!/bin/bash -e | ||
| redmine_api_key="${redmine_api_key:?"Need redmine API key"}" | ||
| host="${host:-"https://progress.opensuse.org"}" | ||
| query_id="${query_id:-400}" | ||
| ticket_limit="${ticket_limit:-200}" | ||
| wip_limit="${wip_limit:-10}" | ||
| status="${status:-"In Progress"}" | ||
| tickets=$(curl -s -H "X-Redmine-API-Key: $redmine_api_key" "https://progress.opensuse.org/issues.json?query_id=$query_id&limit=$ticket_limit" | jq -r '.issues | .[] | select(.status.name=="In Progress") | .id') | ||
| test "$(echo "$tickets" | wc -l)" -le "$wip_limit" | ||
|
|
||
| usage() { | ||
| cat << EOF | ||
| Usage: $0 [OPTIONS] | ||
|
|
||
| Checks the number of tickets in a redmine query against a "WIP-Limit". | ||
Martchus marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please document at least the most important env vars and what happens if check fails (exit code=1?) |
||
|
|
||
| Options: | ||
| -h, --help display this help | ||
| EOF | ||
| exit "$1" | ||
| } | ||
|
|
||
| main() { | ||
| opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1 | ||
| eval set -- "$opts" | ||
| while true; do | ||
| case "$1" in | ||
| -h | --help) usage 0 ;; | ||
| --) | ||
| shift | ||
| break | ||
| ;; | ||
| *) break ;; | ||
| esac | ||
| done | ||
|
|
||
| tickets=$(curl -s -H "X-Redmine-API-Key: $redmine_api_key" "https://progress.opensuse.org/issues.json?query_id=$query_id&limit=$ticket_limit" | jq -r '.issues | .[] | select(.status.name=="In Progress") | .id') | ||
| test "$(echo "$tickets" | wc -l)" -le "$wip_limit" | ||
| } | ||
|
|
||
| caller 0 > /dev/null || main "$@" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,5 @@ | ||
| #!/bin/bash -ex | ||
|
|
||
| # Monitor an openQA job by polling the status of a job over the API. | ||
| # | ||
| # Continuously polls the openQA API for the status of the specified jobs until | ||
| # all jobs finish. After the jobs have finished this program exits with an exit | ||
| # code corresponding to the jobs' result. For example all jobs pass it would exit | ||
| # this program with exit code 0 for success; otherwise with 1. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # configuration variables with defaults. | ||
|
|
@@ -18,38 +11,72 @@ obs_component="${obs_component:-"package"}" | |
| obs_package_name="${1:-""}" | ||
| comment_on_obs=${comment_on_obs:-} | ||
|
|
||
| # shellcheck source=/dev/null | ||
| . "$(dirname "$0")"/_common | ||
|
|
||
| [[ -f job_post_response ]] || (echo "Need job response status file 'job_post_response'" && exit 2) | ||
| declare -A failed_versions | ||
| failed_jobs=() | ||
| for job_id in $(job_ids job_post_response); do | ||
| echo "Waiting for job $job_id to finish" | ||
| while sleep "${sleep_time}"; do | ||
| job_state=$($openqa_cli api --host "$host" jobs/"$job_id" | jq -r '.job.state') | ||
| [[ $job_state = 'done' ]] && break | ||
| usage() { | ||
| cat << EOF | ||
| Usage: $0 [OPTIONS] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add an example here on how to invoke this script (how to supply job id(s?)). |
||
|
|
||
| Monitor an openQA job by polling the status of a job over the API. | ||
|
|
||
| Continuously polls the openQA API for the status of the specified jobs until | ||
| all jobs finish. After the jobs have finished this program exits with an exit | ||
| code corresponding to the jobs' result. For example all jobs pass it would | ||
| exit this program with exit code 0 for success; otherwise with 1. | ||
|
|
||
| Options: | ||
| -h, --help display this help | ||
| EOF | ||
| exit "$1" | ||
| } | ||
|
|
||
| main() { | ||
| opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1 | ||
| eval set -- "$opts" | ||
| while true; do | ||
| case "$1" in | ||
| -h | --help) usage 0 ;; | ||
| --) | ||
| shift | ||
| break | ||
| ;; | ||
| *) break ;; | ||
| esac | ||
| done | ||
| response=$($openqa_cli api --host "$host" jobs/"$job_id") | ||
| result=$(echo "$response" | jq -r '.job.result') | ||
| echo "Result of job $job_id: $result" | ||
| if [[ $result != 'passed' ]] && [[ -n $obs_package_name ]]; then | ||
| version=$(echo "$response" | jq -r '.job.settings.VERSION') | ||
| failed_versions[$version]=1 | ||
| failed_jobs+=("$job_id") | ||
| fi | ||
| done | ||
|
|
||
| [[ ${failed_jobs[*]} ]] || exit 0 | ||
| [[ $comment_on_obs ]] || exit 1 | ||
|
|
||
| osc api "/comments/$obs_component/$obs_package_name" | grep id= | sed -n 's/.*id="\([^"]*\)">.*test.* failed.*/\1/p' | while read -r id; do | ||
|
|
||
| # shellcheck source=/dev/null | ||
| . "$(dirname "$0")"/_common | ||
|
|
||
| [[ -f job_post_response ]] || (echo "Need job response status file 'job_post_response'" && exit 2) | ||
| declare -A failed_versions | ||
| failed_jobs=() | ||
| for job_id in $(job_ids job_post_response); do | ||
| echo "Waiting for job $job_id to finish" | ||
| while sleep "${sleep_time}"; do | ||
| job_state=$($openqa_cli api --host "$host" jobs/"$job_id" | jq -r '.job.state') | ||
| [[ $job_state = 'done' ]] && break | ||
| done | ||
| response=$($openqa_cli api --host "$host" jobs/"$job_id") | ||
| result=$(echo "$response" | jq -r '.job.result') | ||
| echo "Result of job $job_id: $result" | ||
| if [[ $result != 'passed' ]] && [[ -n $obs_package_name ]]; then | ||
| version=$(echo "$response" | jq -r '.job.settings.VERSION') | ||
| failed_versions[$version]=1 | ||
| failed_jobs+=("$job_id") | ||
| fi | ||
| done | ||
|
|
||
| [[ ${failed_jobs[*]} ]] || exit 0 | ||
| [[ $comment_on_obs ]] || exit 1 | ||
|
|
||
| osc api "/comments/$obs_component/$obs_package_name" | grep id= | sed -n 's/.*id="\([^"]*\)">.*test.* failed.*/\1/p' | while read -r id; do | ||
| osc api -X DELETE /comment/"$id" | ||
| done | ||
| comment="openQA-in-openQA test(s) failed (job IDs: ${failed_jobs[*]}), see https://openqa.opensuse.org/tests/overview?" | ||
| for version in "${!failed_versions[@]}"; do | ||
| comment+="version=${version}&" | ||
| done | ||
| comment+="groupid=$openqa_groupid" | ||
| osc api --data="$comment" -X POST "/comments/${obs_component}/$obs_package_name" | ||
| exit 1 | ||
| done | ||
| comment="openQA-in-openQA test(s) failed (job IDs: ${failed_jobs[*]}), see https://openqa.opensuse.org/tests/overview?" | ||
| for version in "${!failed_versions[@]}"; do | ||
| comment+="version=${version}&" | ||
| done | ||
| comment+="groupid=$openqa_groupid" | ||
| osc api --data="$comment" -X POST "/comments/${obs_component}/$obs_package_name" | ||
| exit 1 | ||
| } | ||
|
|
||
| caller 0 > /dev/null || main "$@" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,16 +2,45 @@ | |
|
|
||
| osc="osc --apiurl https://api.opensuse.org" | ||
|
|
||
| for project in $($osc search --project -s 'devel:openQA:Leap:' | grep -o '^devel:openQA:Leap:.*'); do | ||
| for package in $($osc list "$project"); do | ||
| $osc api "/comments/package/$project/$package" \ | ||
| | yq -pxml -oy '.comments.comment |= ([] + .) | .comments.comment[].+content' \ | ||
| | grep -q "Reason for linking:" \ | ||
| || { | ||
| echo "No reason for $project/$package, consider adding a comment or remove the link (see poo#128087 for details)" >&2 | ||
| problem=1 | ||
| } | ||
| usage() { | ||
| cat << EOF | ||
| Usage: $0 [OPTIONS] | ||
|
|
||
| Checks devel:openQA:Leap: OBS project dependencies. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please be a bit more descriptive here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, me neither
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If nobody knows what this does, we might want to delete the script.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the script is actively used within https://gitlab.suse.de/openqa/scripts-ci/ |
||
|
|
||
| Options: | ||
| -h, --help display this help | ||
| EOF | ||
| exit "$1" | ||
| } | ||
|
|
||
| main() { | ||
| opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1 | ||
| eval set -- "$opts" | ||
| while true; do | ||
| case "$1" in | ||
| -h | --help) usage 0 ;; | ||
| --) | ||
| shift | ||
| break | ||
| ;; | ||
| *) break ;; | ||
| esac | ||
| done | ||
| done | ||
|
|
||
| test -z "$problem" | ||
| for project in $($osc search --project -s 'devel:openQA:Leap:' | grep -o '^devel:openQA:Leap:.*'); do | ||
| for package in $($osc list "$project"); do | ||
| $osc api "/comments/package/$project/$package" \ | ||
| | yq -pxml -oy '.comments.comment |= ([] + .) | .comments.comment[].+content' \ | ||
| | grep -q "Reason for linking:" \ | ||
| || { | ||
| echo "No reason for $project/$package, consider adding a comment or remove the link (see poo#128087 for details)" >&2 | ||
| problem=1 | ||
| } | ||
| done | ||
| done | ||
|
|
||
| test -z "$problem" | ||
| } | ||
|
|
||
| caller 0 > /dev/null || main "$@" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| # Motivation: https://progress.opensuse.org/issues/154723 | ||
| # 1. fetch requirements from package spec file, | ||
| # 2. look for package names for such requirements | ||
| # 3. search all relevant instances where the package is maintained | ||
| # 4. fetch version info from spec file and from Tumbleweed repo | ||
|
|
||
| osc="${osc:-"osc --apiurl https://api.opensuse.org"}" | ||
|
|
||
| BLUE="\e[94m" | ||
|
|
@@ -155,12 +149,45 @@ list_versions() { | |
| done | sort | column -t -N Origin,Version,TW-Version | ||
| } | ||
|
|
||
| init_check | ||
| [ $# -eq 0 ] && { | ||
| info "Usage: $0 package-name ..." | ||
| exit 99 | ||
| usage() { | ||
| cat << EOF | ||
| Usage: $0 [OPTIONS] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please include positional argument(s) in usage. |
||
|
|
||
| Motivation: https://progress.opensuse.org/issues/154723 | ||
| 1. fetch requirements from package spec file, | ||
| 2. look for package names for such requirements | ||
| 3. search all relevant instances where the package is maintained | ||
| 4. fetch version info from spec file and from Tumbleweed repo | ||
|
|
||
| Options: | ||
| -h, --help display this help | ||
| EOF | ||
| exit "$1" | ||
| } | ||
|
|
||
| main() { | ||
| opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1 | ||
| eval set -- "$opts" | ||
| while true; do | ||
| case "$1" in | ||
| -h | --help) usage 0 ;; | ||
| --) | ||
| shift | ||
| break | ||
| ;; | ||
| *) break ;; | ||
| esac | ||
| done | ||
|
|
||
| init_check | ||
| [ $# -eq 0 ] && { | ||
| info "Usage: $0 package-name ..." | ||
| exit 99 | ||
| } | ||
| while (($#)); do | ||
| list_versions "$1" | ||
| shift | ||
| done | ||
| } | ||
| while (($#)); do | ||
| list_versions "$1" | ||
| shift | ||
| done | ||
|
|
||
| caller 0 > /dev/null || main "$@" | ||
Uh oh!
There was an error while loading. Please reload this page.