Skip to content

Commit

Permalink
Workflow enhancement to handle Git failures (#4806)
Browse files Browse the repository at this point in the history
- fixes issue of corrupted git directory resulting in test failure

Co-authored-by: Kapil Powar <Kapil.powar@in.ibm.com>
  • Loading branch information
KapilPowar and kapilpowar17 authored Oct 20, 2023
1 parent 97aa18d commit eb0e87f
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions jck/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,42 @@
<available file="${JCK_ROOT_USED}" type="dir" />
<then>
<!--Obtain local and remote SHA to figure out if local materials are up-to-date-->
<exec executable="git" dir="${JCK_ROOT_USED}" outputproperty="localSHA">
<exec executable="git" dir="${JCK_ROOT_USED}" failonerror="false" outputproperty="localSHA" resultproperty="return.code">
<arg line="rev-parse"/>
<arg line="HEAD"/>
</exec>
<exec executable="git" dir="${JCK_ROOT_USED}" outputproperty="remoteSHA">
<arg line="ls-remote"/>
<arg line="${JCK_GIT_REPO_USED}"/>
<arg line="${jck_branch}"/>
</exec>
<loadresource property="localSHATrimmed">
<propertyresource name="localSHA"/>
<filterchain>
<tokenfilter>
<trim/>
</tokenfilter>
<striplinebreaks/>
</filterchain>
</loadresource>

<echo message="LocalSHA = --${localSHATrimmed}--"/>
<echo message="RemoteSHA= --${remoteSHA}--"/>
<if>
<not>
<equals arg1="${return.code}" arg2="0"/>
</not>
<then>
<echo message="Error: Git command failed with return code ${return.code}. Delete the directory and continue." />
<delete dir="${JCK_ROOT_USED}" failonerror="true" />
</then>
<else>
<exec executable="git" dir="${JCK_ROOT_USED}" failonerror="true" outputproperty="remoteSHA">
<arg line="ls-remote"/>
<arg line="${JCK_GIT_REPO_USED}"/>
<arg line="${jck_branch}"/>
</exec>
<loadresource property="localSHATrimmed">
<propertyresource name="localSHA"/>
<filterchain>
<tokenfilter>
<trim/>
</tokenfilter>
<striplinebreaks/>
</filterchain>
</loadresource>

<echo message="LocalSHA = --${localSHATrimmed}--"/>
<echo message="RemoteSHA= --${remoteSHA}--"/>

<condition property="local-material-uptodate">
<contains string="${remoteSHA}" substring="${localSHATrimmed}" />
</condition>
<condition property="local-material-uptodate">
<contains string="${remoteSHA}" substring="${localSHATrimmed}" />
</condition>
</else>
</if>
</then>
</if>
<if>
Expand Down

0 comments on commit eb0e87f

Please sign in to comment.