Skip to content

Commit

Permalink
Merge pull request #303 from perlpunk/no-git-url
Browse files Browse the repository at this point in the history
Do not create investigation jobs with broken CASEDIR
  • Loading branch information
mergify[bot] committed Mar 18, 2024
2 parents 5a6d260 + c7d0da5 commit c545d59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion openqa-investigate
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ clone() {
vars_json=$(fetch-vars-json "$origin")
testgiturl=$(echo "$vars_json" | runjq -r '.TEST_GIT_URL')
casedir=$(echo "$clone_job_data" | runjq -r '.job.settings.CASEDIR') || return $?
[[ $testgiturl != null ]] && casedir=$testgiturl
if [[ $testgiturl != null ]]; then
if [[ ! $testgiturl =~ ^https?://[^[:space:]]+$ ]]; then
warn "Can not clone refspec of job $origin with unknown/invalid git url TEST_GIT_URL='$testgiturl'"
return 0
fi
casedir=$testgiturl
fi
[[ $casedir == null ]] && casedir=''
repo=${casedir:-'https://github.com/os-autoinst/os-autoinst-distri-opensuse.git'}
clone_settings+=("CASEDIR=${repo%#*}#${refspec}")
Expand Down
8 changes: 7 additions & 1 deletion test/02-investigate.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source test/init
bpan:source bashplus +err +fs +sym

plan tests 85
plan tests 87

host=localhost
url=https://localhost
Expand All @@ -21,6 +21,8 @@ fetch-vars-json() {
local tid=$1
if [[ $tid -eq 10020 ]]; then
echo '{"TEST_GIT_URL": "https://github.com/os-autoinst/os-autoinst-distri-openQA.git"}'
elif [[ $tid -eq 10026 ]]; then
echo '{"TEST_GIT_URL": "UNKNOWN (origin remote not found)"}'
elif [[ $tid -eq 10022 ]]; then
echo '{"WORKER_CLASS": "foo,duh,bar"}'
else
Expand Down Expand Up @@ -232,6 +234,10 @@ try clone 10023 10024 foo refspec
is "$rc" 0 "Successful clone"
like "$got" 'CASEDIR=.*/os-autoinst-distri-opensuse.git#refspec' "job is cloned and it uses default CASEDIR"

try clone 10026 10024 foo refspec
is "$rc" 0 "Successful clone"
like "$got" 'Can not clone refspec' "job with non-git TEST_GIT_URL is not cloned"

try clone 10020 10024 foo refspec
is "$rc" 0 "Successful clone"
like "$got" 'CASEDIR=.*/os-autoinst-distri-openQA.git#refspec' "job is cloned with sets CASEDIR from TEST_GIT_URL"
Expand Down

0 comments on commit c545d59

Please sign in to comment.