<div dir="ltr"><div dir="ltr"><div><div>On Mon, Aug 2, 2021 at 2:53 PM Michael Santana <<a href="mailto:msantana@redhat.com">msantana@redhat.com</a>> wrote:<br></div></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Jul 29, 2021 at 5:36 PM Salvatore Daniele <<a href="mailto:sdaniele@redhat.com" target="_blank">sdaniele@redhat.com</a>> wrote:<br>
><br>
> The existing github monitor code only supports a single workflow job.<br>
> This worked as an initial implementation, but some projects are<br>
> configuring multiple workflows and the monitor is unable to cope with<br>
> this.<br>
><br>
> To resolve this, we pull the workflow configurations and then ensure<br>
> that all workflows are completed, and emit results once all have<br>
> finished.  Each workflow run can now emit two 'pw|...' strings.<br>
><br>
> As part of this change, we add a new field 'test_name to the 'pw|...'<br>
> string to support passing the workflow name around.  CI systems like<br>
> Travis won't report anything here so test_name will be blank for those<br>
> systems.<br>
><br>
> Signed-off-by: Salvatore Daniele <<a href="mailto:sdaniele@redhat.com" target="_blank">sdaniele@redhat.com</a>><br>
> ---<br>
>  ci_mon             | 12 +++++++++---<br>
>  github_get_logs.sh | 11 ++++++++---<br>
>  github_mon         | 37 ++++++++++++++++++++++++++-----------<br>
>  3 files changed, 43 insertions(+), 17 deletions(-)<br>
><br>
> diff --git a/ci_mon b/ci_mon<br>
> index a6e4222..e2cdaf2 100755<br>
> --- a/ci_mon<br>
> +++ b/ci_mon<br>
> @@ -149,7 +149,7 @@ for I in travis github dummy; do<br>
>      fi<br>
><br>
>      ./${I}_mon $pw_instance ${!token} "$pw_project" | grep "^pw|" | while IFS="|" \<br>
> -        read -r PW pw_chk_instance BUILD series_id SHA shasum result build_url series_name repo_name; do<br>
> +        read -r PW pw_chk_instance BUILD series_id SHA shasum result build_url series_name repo_name test_name; do<br>
><br>
>          SERIES_LINE=$(./series_get $pw_instance $series_id)<br>
>          sid=$(echo $SERIES_LINE | cut -d\| -f1)<br>
> @@ -200,7 +200,13 @@ for I in travis github dummy; do<br>
>          echo "References: $message_id" >> report.eml<br>
>          echo "" >> report.eml<br>
><br>
> -        echo "Test-Label: ${I}-robot" >> report.eml<br>
> +        if [ "$test_name" != "" ]; then<br>
> +            TEST_LABEL="${I}-robot: ${test_name}"<br>
> +        else<br>
> +            TEST_LABEL="${I}-robot"<br>
> +        fi<br>
> +<br>
> +        echo "Test-Label: $TEST_LABEL" >> report.eml<br>
>          echo "Test-Status: $RESULT" >> report.eml<br>
>          echo "$patch_url" >> report.eml<br>
>          echo "" >> report.eml<br>
> @@ -208,7 +214,7 @@ for I in travis github dummy; do<br>
>          echo "Build URL: $build_url" >> report.eml<br>
><br>
>          if [ -f ./${I}_get_logs.sh ]; then<br>
> -            ./${I}_get_logs.sh "$repo_name" "$series_id" "$shasum" "${!token}" >> report.eml<br>
> +            ./${I}_get_logs.sh "$repo_name" "$series_id" "$shasum" "${!token}" "$test_name" >> report.eml<br>
>          fi<br>
><br>
>          if [ "$result" != "passed" ]; then<br>
> diff --git a/github_get_logs.sh b/github_get_logs.sh<br>
> index 60a763d..2f6cc9c 100755<br>
> --- a/github_get_logs.sh<br>
> +++ b/github_get_logs.sh<br>
> @@ -41,8 +41,13 @@ if [ "X" = "X$github_token" ]; then<br>
>      shift<br>
>  fi<br>
><br>
> -if [ "X" = "X$repo_name" -o "X" = "X$series_id" -o "X" = "X$sha" -o "X" = "X$github_token" ]; then<br>
> -    echo "repo_name, series_id, sha or token were not passed in as an arugment. Exiting" 1>&2<br>
> +if [ "X" = "X$test_name" ]; then<br>
> +    test_name="$1"<br>
> +    shift<br>
> +fi<br>
> +<br>
> +if [ "X" = "X$repo_name" -o "X" = "X$series_id" -o "X" = "X$sha" -o "X" = "X$github_token" -o "X" = "X$test_name" ]; then<br>
> +    echo "repo_name, series_id, sha, token, or test_name were not passed in as an arugment. Exiting" 1>&2<br>
>      exit 1<br>
>  fi<br>
><br>
> @@ -61,7 +66,7 @@ GITHUB_API="<a href="https://api.github.com" rel="noreferrer" target="_blank">https://api.github.com</a>"<br>
>  print_errored_logs_for_commit () {<br>
><br>
>      # Get run metadata<br>
> -    select="select(.head_branch==\"series_${series_id}\") | select(.head_sha==\"${sha}\")"<br>
> +    select="select(.head_branch==\"series_${series_id}\") | select(.head_sha==\"${sha}\") | select(.name==\"${test_name}\")"<br>
>      headers="{id, logs_url}"<br>
>      run_meta="$(echo "$runs" | jq ".workflow_runs[] | $select | $headers")"<br>
><br>
> diff --git a/github_mon b/github_mon<br>
> index bc49f46..6ee604a 100755<br>
> --- a/github_mon<br>
> +++ b/github_mon<br>
> @@ -58,28 +58,43 @@ make_result_for_series () {<br>
>      sha="$5"<br>
>      repo_name="$6"<br>
><br>
> -    # Get run metadata<br>
> +    # Get the name of each respective workflow<br>
> +    workflows="$(echo "$runs" | jq -r ".workflow_runs[].name" | sort -u)"<br>
> +<br>
> +    # Check that workflows have all completed<br>
>      select="select(.head_branch==\"series_${series_id}\") | select(.head_sha==\"${sha}\")"<br>
>      headers="{status, conclusion, html_url}"<br>
>      run_meta="$(echo "$runs" | jq ".workflow_runs[] | $select | $headers")"<br>
><br>
> -    if [ "$(echo "$run_meta" | jq -r ".status")" != "completed" ]; then<br>
> +    if [ "$(echo "$run_meta" | jq -r ".status" | sort -u)" != "completed" ]; then<br>
Can you explain the reason for sort -u ? Does it have something to do<br>
with multiple workflows? Does it make sure all workflows are<br>
completed?<br></blockquote><div><br></div><div>Exactly. <div><br></div><div>e.g. Say an OVN job is being run (2 wf tests currently). 1 workflow could be "status = completed" while the second is still "incomplete".</div><div>"$(echo "$run_meta" | jq -r ".status" | sort -u)" != "completed" makes sure we don't send any reports until all workflows are completed. <br></div><div><br></div><div>We have to sort for unique statuses now too, or else in the case of two completed workflows, that statement would read "completed\ncompleted != completed", which would be True. <br><div></div></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>          echo "patch_id=$patch_id belonging to series_id=$series_id not completed. Skipping" 1>&2<br>
>          return 2<br>
>      fi<br>
><br>
> -    # success/failure?<br>
> -    result="$(echo "$run_meta" | jq -r ".conclusion")"<br>
> -    build_url="$(echo "$run_meta" | jq -r ".html_url")"<br>
> +    # Scan relevant data for each workflow<br>
> +    echo "$workflows" | while IFS='\n' read -r WORKFLOWNAME; do<br>
><br>
> -    if [ "$result" == "success" ]; then<br>
> -        result="passed"<br>
> -    else<br>
> -        result="failed"<br>
> -    fi<br>
> +        # Get run metadata<br>
> +        select="select(.head_branch==\"series_${series_id}\") | select(.head_sha==\"${sha}\") | select(.name==\"${WORKFLOWNAME}\")"<br>
> +        headers="{status, conclusion, html_url}"<br>
> +        run_meta="$(echo "$runs" | jq ".workflow_runs[] | $select | $headers")"<br>
> +<br>
> +        # success/failure?<br>
> +        result="$(echo "$run_meta" | jq -r ".conclusion")"<br>
> +        build_url="$(echo "$run_meta" | jq -r ".html_url")"<br>
> +<br>
> +        if [ "$result" == "success" ]; then<br>
> +            result="passed"<br>
> +        else<br>
> +            result="failed"<br>
> +        fi<br>
> +<br>
> +        test_name=$WORKFLOWNAME<br>
> +<br>
> +        echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|$test_name"<br>
> +    done<br>
><br>
>      set_synced_patch "$patch_id" "$pw_instance"<br>
> -    echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name"<br>
>  }<br>
><br>
>  prev_series=""<br>
> --<br>
> 2.31.1<br>
><br>
> _______________________________________________<br>
> Pwci mailing list<br>
> <a href="mailto:Pwci@lists.esnacc.org" target="_blank">Pwci@lists.esnacc.org</a><br>
> <a href="http://mail.esnacc.org/mailman/listinfo/pwci" rel="noreferrer" target="_blank">http://mail.esnacc.org/mailman/listinfo/pwci</a><br>
><br>
<br>
</blockquote></div></div>