Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/actions/check-coverage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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
--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'
35 changes: 35 additions & 0 deletions .github/actions/setup-osal/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Install OSAL
description: 'Builds and installs NASA OSAL into the workflow filesystem'

inputs:
upstream-ref:
description: 'Upstream ref to check out'
default: main
upstream-repo:
description: 'Upstream repository to use'
default: nasa/osal
config-options:
description: 'Configuration options to pass to CMake'
default: -DCMAKE_BUILD_TYPE=Release -DOSAL_OMIT_DEPRECATED=TRUE -DENABLE_UNIT_TESTS=TRUE -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=ON
staging-dir:
description: 'Directory to stage output'
required: true

runs:
using: 'composite'
steps:
- name: Checkout OSAL
uses: actions/checkout@v4
with:
repository: ${{ inputs.upstream-repo }}
ref: ${{ inputs.upstream-ref }}
path: osal-source

- name: Set up OSAL build
shell: bash
run: cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DOSAL_SYSTEM_BSPTYPE=generic-linux ${{ inputs.config-options }} -S osal-source -B osal-build

- name: Build and Install OSAL
shell: bash
working-directory: osal-build
run: make DESTDIR=${{ inputs.staging-dir }} install
17 changes: 17 additions & 0 deletions .github/scripts/cppcheck-output.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">## CppCheck <xsl:value-of select="//cppcheck/@version"/> Summary
<xsl:if test="count(//error) > 0">
| error | warning | style | performance | portability | information |
| --- | --- | --- | --- | --- | --- |
| <xsl:value-of select="count(//error[@severity='error'])"/> | <xsl:value-of select="count(//error[@severity='warning'])"/> | <xsl:value-of select="count(//error[@severity='style'])"/> | <xsl:value-of select="count(//error[@severity='performance'])"/> | <xsl:value-of select="count(//error[@severity='portability'])"/> | <xsl:value-of select="count(//error[@severity='information'])"/> |

| severity | location | error id | issue |
| --- | --- | --- | --- |
<xsl:for-each select="results//error">| <xsl:value-of select="@severity"/> | <xsl:value-of select="location/@file"/>:<xsl:value-of select="location/@line"/> | <xsl:value-of select="@id"/> | <xsl:value-of select="@msg"/> |
</xsl:for-each>
</xsl:if>
**<xsl:value-of select="count(//error)"/> error(s) reported**
</xsl:template>
</xsl:stylesheet>
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>
14 changes: 14 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Format Check

# Run on all push and pull requests
on:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
format-check:
name: Run format check
uses: nasa/cFS/.github/workflows/format-check.yml@main
20 changes: 20 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Static Analysis

# Run on all push and pull requests
on:
push:
branches:
- dev
- main
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

jobs:

static-analysis:
name: Run cppcheck
uses: nasa/cFS/.github/workflows/static-analysis.yml@main
138 changes: 138 additions & 0 deletions .github/workflows/validation-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Internal Build And Run EdsLib Validation Tests

on:
push:
branches:
- dev
- main
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

# Force bash to apply pipefail option so pipeline failures aren't masked
defaults:
run:
shell: bash

env:
UPSTREAM_OSAL_REPO: nasa/osal
UPSTREAM_OSAL_REF: main

jobs:
prepare-dependencies:
name: Prepare Dependencies
runs-on: ubuntu-latest
steps:
- name: Cache EdsLib Source
uses: actions/cache@v3
id: cache-edslib
with:
path: ${{ github.workspace }}/source
key: edslib-source-${{ github.sha }}

- name: Cache OSAL Dependency
uses: actions/cache@v3
id: cache-osal
with:
path: ${{ github.workspace }}/osal-staging
key: edslib-dep-${{ env.UPSTREAM_OSAL_REPO }}@${{ env.UPSTREAM_OSAL_REF }}

- name: Checkout EdsLib
if: steps.cache-edslib.outputs.cache-hit != 'True'
uses: actions/checkout@v4
with:
path: source

- name: Set up OSAL
if: steps.cache-osal.outputs.cache-hit != 'True'
uses: ./source/.github/actions/setup-osal
with:
staging-dir: ${GITHUB_WORKSPACE}/osal-staging
upstream-repo: ${{ env.UPSTREAM_OSAL_REPO }}
upstream-ref: ${{ env.UPSTREAM_OSAL_REF }}

build-and-test:
name: Build EdsLib and Execute Tests
needs: [prepare-dependencies]
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
buildtype: [Debug, Release]

env:
MATRIX_ID: matrix-${{ matrix.buildtype }}

steps:

- name: Install Build Dependencies
run: sudo apt-get install liblua5.4-dev libpython3-dev libjson-c-dev pkg-config lcov xsltproc -y

# Note - caches were updated in "prepare-dependencies" job so all three of these should be a hit
- name: Retrieve Cached EdsLib Source
uses: actions/cache@v3
id: restore-source
with:
path: ${{ github.workspace }}/source
key: edslib-source-${{ github.sha }}

- name: Retrieve Cached OSAL Dependency
id: restore-osal
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/osal-staging
key: edslib-dep-${{ env.UPSTREAM_OSAL_REPO }}@${{ env.UPSTREAM_OSAL_REF }}

# The files extracted from the cache only have owner permissions,
# so in order to make this work it needs to adjust this.
- name: Import OSAL
run: |
sudo find ${GITHUB_WORKSPACE}/osal-staging -type d -print0 | xargs -0 chmod go+rx
sudo find ${GITHUB_WORKSPACE}/osal-staging -type f -print0 | xargs -0 chmod go+r
sudo find ${GITHUB_WORKSPACE}/osal-staging -type f -path '*/bin/*' -print0 | xargs -0 chmod go+x
sudo cp -rv -t / ${GITHUB_WORKSPACE}/osal-staging/*

- name: Refresh Dynamic Linker Cache
run: sudo ldconfig

- name: Set up EdsLib Build
run: cmake
-DCMAKE_BUILD_TYPE=${{ matrix.buildtype }}
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE
-DENABLE_UNIT_TESTS=TRUE
-DCMAKE_PREFIX_PATH=/usr/local/lib/cmake
-S source -B ${{ env.MATRIX_ID }}

- name: Build BPLib
working-directory: ${{ env.MATRIX_ID }}
run: make all

- name: Check for Tests
run: if [ -e '${{ env.MATRIX_ID }}/CTestTestfile.cmake' ]; then echo 'RUN_TESTS=True' >> $GITHUB_ENV; fi

- name: Run Tests
working-directory: ${{ env.MATRIX_ID }}
if: env.RUN_TESTS == 'True'
run: ctest --output-on-failure 2>&1 | tee ctest.log

- name: Check Coverage
if: env.MATRIX_ID == 'matrix-Debug'
uses: ./source/.github/actions/check-coverage
with:
binary-dir: ${{ env.MATRIX_ID }}

- name: Assemble Results
run: |
if [ -s '${{ env.MATRIX_ID }}/ctest.log' ]; then
echo '<h2>CTest Execution</h2>' >> $GITHUB_STEP_SUMMARY
echo '<pre>' >> $GITHUB_STEP_SUMMARY
cat '${{ env.MATRIX_ID }}/ctest.log' >> $GITHUB_STEP_SUMMARY
echo '</pre>' >> $GITHUB_STEP_SUMMARY
fi
if [ -s '${{ env.MATRIX_ID }}/lcov-summary.xml' ]; then
cat '${{ env.MATRIX_ID }}/lcov-summary.xml' >> $GITHUB_STEP_SUMMARY
fi
Loading
Loading