#1 making index.html file for comulative overall results based on avocado css styles
Closed 6 years ago by kparal. Opened 6 years ago by jscotka.
taskotron/ jscotka/task-modularity-testing-framework added_index  into  develop

file modified
+69
@@ -24,6 +24,45 @@ 

  MTF_EXIT_FAIL='125'

  MTF_EXIT_SKIP='126'

  

+ function write_to_index {

+     local HEADER='

+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

+ <html>

+ <head>

+   <title>Taskotron cumulative results for Modularity testing framework subtests</title>

+   <link href="avocado-result.modulelint/html/css/bootstrap.min.css" rel="stylesheet">

+   <link href="avocado-result.modulelint/html/css/dataTables.bootstrap.css" rel="stylesheet">

+ </head>

+ <body>

+ <div class="container">

+   <div class="page-header">

+     <h3>Taskotron cumulative results for Modularity testing framework subtests</h3>

+   </div>

+ 

+   <table id="results" class="table table-striped table-bordered dataTable no-footer" cellspacing="0" width="100%"><thead>

+      <tr>

+        <th>Result</th>

+        <th>Link to subtest</th>

+      </tr></thead>

+ '

+     local FOOTER='

+   </table>

+ </div>

+ </body>

+ </html>

+ '

+     local FUNC=$1

+     local TEXT=$2

+     local OUTFILE="$ARTIFACTSDIR/index.html"

+     if echo $FUNC | grep header; then

+         echo "$HEADER" > $OUTFILE

+     elif echo $FUNC | grep footer; then

+         echo "$FOOTER" >> $OUTFILE

+     elif echo $FUNC | grep body; then

+         echo "$TEXT" >> $OUTFILE

+     fi

+ }

+ 

  function save_outcome {

      local EXITCODE="$1"

      local OUTFILE="$2"
@@ -67,6 +106,32 @@ 

      fi

  }

  

+ function generate_html_table_row {

+     local EXITCODE="$1"

+     local URLLINK="$2"

+     local RES="PASS"

+     local RES_CLASS="success"

+     if [ "$EXITCODE" -eq 0 ]; then

+         true

+     elif [ "$EXITCODE" -eq "$MTF_EXIT_FAIL" ]; then

+         RES="FAIL"

+         RES_CLASS="danger even"

+     elif [ "$EXITCODE" -eq "$MTF_EXIT_SKIP" ]; then

+         RES="SKIP"

+         RES_CLASS="warning"

+     else

+         return 1

+     fi

+     echo "

+   <tr class='$RES_CLASS'>

+     <td>$RES</td>

+     <td><a href='$URLLINK'>$URLLINK</a></td>

+   </tr>

+ "

+     return 0

+ }

+ 

+ write_to_index header

  # run module lint

  echo 'Running MTF with module lint...'

  /usr/share/moduleframework/tools/run-them.sh "$MODULENAME" "$MODULENAME_STREAM_VERSION" pdc lint
@@ -75,6 +140,7 @@ 

  echo 'Saving module lint results...'

  save_outcome "$EXITCODE" "$WORKDIR/outcome.modulelint"

  save_artifacts "$EXITCODE" "$ARTIFACTSDIR/avocado-result.modulelint"

+ write_to_index body "`generate_html_table_row $EXITCODE $ARTIFACTSDIR/avocado-result.modulelint/html/results.html`"

  

  # run module tests

  echo 'Running MTF with module tests...'
@@ -84,7 +150,9 @@ 

  echo 'Saving module tests results...'

  save_outcome "$EXITCODE" "$WORKDIR/outcome.tests"

  save_artifacts "$EXITCODE" "$ARTIFACTSDIR/avocado-result.tests"

+ write_to_index body "`generate_html_table_row $EXITCODE $ARTIFACTSDIR/avocado-result.tests/html/results.html`"

  

+ write_to_index footer

  # generate overall outcome

  if grep -q FAILED "$WORKDIR"/outcome.*; then

      echo "FAILED" > "$WORKDIR/outcome.overall"
@@ -118,3 +186,4 @@ 

  

  # save results as an artifact, for debugging

  cp "$WORKDIR/results.yaml" "$ARTIFACTSDIR"

+ 

no initial comment

1 new commit added

  • fix class attrib for table -> colours visible
6 years ago

Seems to work well, tested locally and file was created:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
  <title>Taskotron cumulative results for Modularity testing framework subtests</title>
  <link href="avocado-result.modulelint/html/css/bootstrap.min.css" rel="stylesheet">
  <link href="avocado-result.modulelint/html/css/dataTables.bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="container">
  <div class="page-header">
    <h3>Taskotron cumulative results for Modularity testing framework subtests</h3>
  </div>

  <table id="results" class="display" cellspacing="0" width="100%"><thead>
     <tr>
       <th>Result</th>
       <th>Link to subtest</th>
     </tr></thead>


  <tr class='success'>
    <td>PASS</td>
    <td><a href='/var/lib/taskotron/artifacts/20170704_083541_121683/avocado-result.modulelint/html/results.html'>/var/lib/taskotron/artifacts/20170704_083541_121683/avocado-result.modulelint/html/results.html</a></td>
  </tr>

  <tr class='success'>
    <td>PASS</td>
    <td><a href='/var/lib/taskotron/artifacts/20170704_083541_121683/avocado-result.tests/html/results.html'>/var/lib/taskotron/artifacts/20170704_083541_121683/avocado-result.tests/html/results.html</a></td>
  </tr>

  </table>
</div>
</body>
</html>

Thanks Jan! I reworked it a bit and pushed b3340eb. Let's see how it works.

Pull-Request has been closed by kparal

6 years ago
Metadata