Skip to content

Commit

Permalink
Fix nasa#1370, workflow to validate OSAL API
Browse files Browse the repository at this point in the history
Adds a new build and test workflow that includes an API validation with
both C and C++ compilers.  This should catch any cases where syntactical
elements that work in C but do not work in C++ appear in the headers.
  • Loading branch information
jphickey committed Feb 24, 2023
1 parent 7c7fc95 commit 2fd5133
Show file tree
Hide file tree
Showing 12 changed files with 288 additions and 194 deletions.
34 changes: 34 additions & 0 deletions .github/actions/check-coverage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check Coverage Results
description: 'Extracts a summary of the code coverage results'

inputs:
binary-dir:
description: 'Directory containing binary files'
required: true
source-dir:
description: 'Directory containing source code files'
default: ./source

runs:
using: 'composite'
steps:
- name: Capture Results
shell: bash
run: lcov
--capture --rc lcov_branch_coverage=1
--include '${{ github.workspace }}/*'
--directory '${{ inputs.binary-dir }}'
--output-file '${{ inputs.binary-dir }}/coverage.info'

- name: Generate HTML
shell: bash
run: genhtml
'${{ inputs.binary-dir }}/coverage.info'
--branch-coverage
--output-directory '${{ inputs.binary-dir }}/lcov-html'

- name: Extract Summary
shell: bash
run: xsltproc --html
'${{ inputs.source-dir }}/.github/scripts/lcov-output.xslt'
'${{ inputs.binary-dir }}/lcov-html/index.html' > '${{ inputs.binary-dir }}/lcov-summary.xml'
105 changes: 105 additions & 0 deletions .github/scripts/lcov-output.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8"/>

<!-- Identity Template -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<!-- Omit class attributes, width attributes, and img elements -->
<xsl:template match="@class" />
<xsl:template match="@width" />
<xsl:template match="@align" />
<xsl:template match="img" />

<!-- The "coverBar" will not render on github, so pull out the alt text on the image -->
<xsl:template match="td[@class='coverBar']">
<td>
<xsl:for-each select=".//img[1]">
<xsl:if test="@width &lt; 95">X</xsl:if>
</xsl:for-each>
</td>
</xsl:template>

<!-- Convert td w/class="tableHead" to a th tag -->
<xsl:template match="td[@class='tableHead']">
<th>
<xsl:if test="count(@colspan) > 0">
<xsl:attribute name="colspan"><xsl:value-of select="@colspan"/></xsl:attribute>
</xsl:if>
<xsl:for-each select="text()">
<xsl:copy/>
</xsl:for-each>
</th>
</xsl:template>

<xsl:template match="span|center">
<xsl:apply-templates select="@* | node()"/>
</xsl:template>

<!-- Rewrite links to be plain text -->
<xsl:template match="a">
<xsl:for-each select="text()">
<xsl:copy/>
</xsl:for-each>
</xsl:template>

<xsl:template name="summary_row">
<!-- Extract only cells 4-7 here (label, hit, total, coverage) -->
<xsl:for-each select="td[position() &gt;= 4]">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>

<xsl:template name="summary_table">
<table>
<!-- Extract only rows 1-4 here (header, lines, functions, branches) -->
<xsl:for-each select="tr[position() &lt;= 4]">
<xsl:copy>
<xsl:call-template name="summary_row" />
</xsl:copy>
</xsl:for-each>
</table>
<xsl:text>
</xsl:text>
</xsl:template>

<xsl:template name="detail_table">
<table>
<!-- First row appears to be always blank/spacer, real content starts at 2 -->
<xsl:for-each select="tr[position() &gt;= 2]">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:for-each>
</table>
<xsl:text>
</xsl:text>
</xsl:template>

<!-- The LCOV output uses tables for white-spacing purposes as well as actual tabular data -->
<xsl:template match="/">
<h2>LCOV Report</h2>
<xsl:text>
</xsl:text>
<!-- The first table is the summary, but we really want the embedded table within the table at row 3 -->
<xsl:for-each select="/html/body/table[1]/tr[3]/td/table">
<xsl:call-template name="summary_table" />
</xsl:for-each>

<!-- The centered table is the file-by-file details -->
<xsl:for-each select="/html/body/center/table[1]">
<xsl:call-template name="detail_table" />
</xsl:for-each>

</xsl:template>


</xsl:stylesheet>
68 changes: 0 additions & 68 deletions .github/workflows/build-osal-documentation.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/codeql-cfe-build.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/codeql-osal-default.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/format-check.yml

This file was deleted.

70 changes: 0 additions & 70 deletions .github/workflows/local_unit_test.yml

This file was deleted.

Loading

0 comments on commit 2fd5133

Please sign in to comment.