Skip to content

Commit 680fe45

Browse files
authored
Merge pull request #103 from nasa/draco-integration
Open Source Draco Release
2 parents 7eb9447 + 2ee125d commit 680fe45

186 files changed

Lines changed: 20080 additions & 6555 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Check Coverage Results
2+
description: 'Extracts a summary of the code coverage results'
3+
4+
inputs:
5+
binary-dir:
6+
description: 'Directory containing binary files'
7+
required: true
8+
source-dir:
9+
description: 'Directory containing source code files'
10+
default: ./source
11+
12+
runs:
13+
using: 'composite'
14+
steps:
15+
- name: Capture Results
16+
shell: bash
17+
run: lcov
18+
--capture --rc lcov_branch_coverage=1
19+
--directory '${{ inputs.binary-dir }}'
20+
--output-file '${{ inputs.binary-dir }}/coverage.info'
21+
22+
- name: Generate HTML
23+
shell: bash
24+
run: genhtml
25+
'${{ inputs.binary-dir }}/coverage.info'
26+
--branch-coverage
27+
--output-directory '${{ inputs.binary-dir }}/lcov-html'
28+
29+
- name: Extract Summary
30+
shell: bash
31+
run: xsltproc --html
32+
'${{ inputs.source-dir }}/.github/scripts/lcov-output.xslt'
33+
'${{ inputs.binary-dir }}/lcov-html/index.html' > '${{ inputs.binary-dir }}/lcov-summary.xml'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Install OSAL
2+
description: 'Builds and installs NASA OSAL into the workflow filesystem'
3+
4+
inputs:
5+
upstream-ref:
6+
description: 'Upstream ref to check out'
7+
default: main
8+
upstream-repo:
9+
description: 'Upstream repository to use'
10+
default: nasa/osal
11+
config-options:
12+
description: 'Configuration options to pass to CMake'
13+
default: -DCMAKE_BUILD_TYPE=Release -DOSAL_OMIT_DEPRECATED=TRUE -DENABLE_UNIT_TESTS=TRUE -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=ON
14+
staging-dir:
15+
description: 'Directory to stage output'
16+
required: true
17+
18+
runs:
19+
using: 'composite'
20+
steps:
21+
- name: Checkout OSAL
22+
uses: actions/checkout@v4
23+
with:
24+
repository: ${{ inputs.upstream-repo }}
25+
ref: ${{ inputs.upstream-ref }}
26+
path: osal-source
27+
28+
- name: Set up OSAL build
29+
shell: bash
30+
run: cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DOSAL_SYSTEM_BSPTYPE=generic-linux ${{ inputs.config-options }} -S osal-source -B osal-build
31+
32+
- name: Build and Install OSAL
33+
shell: bash
34+
working-directory: osal-build
35+
run: make DESTDIR=${{ inputs.staging-dir }} install
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3+
<xsl:output method="text" encoding="UTF-8"/>
4+
<xsl:template match="/">## CppCheck <xsl:value-of select="//cppcheck/@version"/> Summary
5+
<xsl:if test="count(//error) > 0">
6+
| error | warning | style | performance | portability | information |
7+
| --- | --- | --- | --- | --- | --- |
8+
| <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'])"/> |
9+
10+
| severity | location | error id | issue |
11+
| --- | --- | --- | --- |
12+
<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"/> |
13+
</xsl:for-each>
14+
</xsl:if>
15+
**<xsl:value-of select="count(//error)"/> error(s) reported**
16+
</xsl:template>
17+
</xsl:stylesheet>

.github/scripts/lcov-output.xslt

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0"?>
2+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3+
<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8"/>
4+
5+
<!-- Identity Template -->
6+
<xsl:template match="@* | node()">
7+
<xsl:copy>
8+
<xsl:apply-templates select="@* | node()"/>
9+
</xsl:copy>
10+
</xsl:template>
11+
12+
<!-- Omit class attributes, width attributes, and img elements -->
13+
<xsl:template match="@class" />
14+
<xsl:template match="@width" />
15+
<xsl:template match="@align" />
16+
<xsl:template match="img" />
17+
18+
<!-- The "coverBar" will not render on github, so pull out the alt text on the image -->
19+
<xsl:template match="td[@class='coverBar']">
20+
<td>
21+
<xsl:for-each select=".//img[1]">
22+
<xsl:if test="@width &lt; 95">X</xsl:if>
23+
</xsl:for-each>
24+
</td>
25+
</xsl:template>
26+
27+
<!-- Convert td w/class="tableHead" to a th tag -->
28+
<xsl:template match="td[@class='tableHead']">
29+
<th>
30+
<xsl:if test="count(@colspan) > 0">
31+
<xsl:attribute name="colspan"><xsl:value-of select="@colspan"/></xsl:attribute>
32+
</xsl:if>
33+
<xsl:for-each select="text()">
34+
<xsl:copy/>
35+
</xsl:for-each>
36+
</th>
37+
</xsl:template>
38+
39+
<xsl:template match="span|center">
40+
<xsl:apply-templates select="@* | node()"/>
41+
</xsl:template>
42+
43+
<!-- Rewrite links to be plain text -->
44+
<xsl:template match="a">
45+
<xsl:for-each select="text()">
46+
<xsl:copy/>
47+
</xsl:for-each>
48+
</xsl:template>
49+
50+
<xsl:template name="summary_row">
51+
<!-- Extract only cells 4-7 here (label, hit, total, coverage) -->
52+
<xsl:for-each select="td[position() &gt;= 4]">
53+
<xsl:copy>
54+
<xsl:apply-templates select="@* | node()" />
55+
</xsl:copy>
56+
</xsl:for-each>
57+
<xsl:text>
58+
</xsl:text>
59+
</xsl:template>
60+
61+
<xsl:template name="summary_table">
62+
<table>
63+
<!-- Extract only rows 1-4 here (header, lines, functions, branches) -->
64+
<xsl:for-each select="tr[position() &lt;= 4]">
65+
<xsl:copy>
66+
<xsl:call-template name="summary_row" />
67+
</xsl:copy>
68+
</xsl:for-each>
69+
</table>
70+
<xsl:text>
71+
</xsl:text>
72+
</xsl:template>
73+
74+
<xsl:template name="detail_table">
75+
<table>
76+
<!-- First row appears to be always blank/spacer, real content starts at 2 -->
77+
<xsl:for-each select="tr[position() &gt;= 2]">
78+
<xsl:copy>
79+
<xsl:apply-templates select="@* | node()"/>
80+
</xsl:copy>
81+
</xsl:for-each>
82+
</table>
83+
<xsl:text>
84+
</xsl:text>
85+
</xsl:template>
86+
87+
<!-- The LCOV output uses tables for white-spacing purposes as well as actual tabular data -->
88+
<xsl:template match="/">
89+
<h2>LCOV Report</h2>
90+
<xsl:text>
91+
</xsl:text>
92+
<!-- The first table is the summary, but we really want the embedded table within the table at row 3 -->
93+
<xsl:for-each select="/html/body/table[1]/tr[3]/td/table">
94+
<xsl:call-template name="summary_table" />
95+
</xsl:for-each>
96+
97+
<!-- The centered table is the file-by-file details -->
98+
<xsl:for-each select="/html/body/center/table[1]">
99+
<xsl:call-template name="detail_table" />
100+
</xsl:for-each>
101+
102+
</xsl:template>
103+
104+
105+
</xsl:stylesheet>

.github/workflows/format-check.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Format Check
2+
3+
# Run on all push and pull requests
4+
on:
5+
pull_request:
6+
types:
7+
- opened
8+
- reopened
9+
- synchronize
10+
11+
jobs:
12+
format-check:
13+
name: Run format check
14+
uses: nasa/cFS/.github/workflows/format-check.yml@main
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Static Analysis
2+
3+
# Run on all push and pull requests
4+
on:
5+
push:
6+
branches:
7+
- dev
8+
- main
9+
pull_request:
10+
types:
11+
- opened
12+
- reopened
13+
- synchronize
14+
workflow_dispatch:
15+
16+
jobs:
17+
18+
static-analysis:
19+
name: Run cppcheck
20+
uses: nasa/cFS/.github/workflows/static-analysis.yml@main
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Internal Build And Run EdsLib Validation Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- main
8+
pull_request:
9+
types:
10+
- opened
11+
- reopened
12+
- synchronize
13+
workflow_dispatch:
14+
15+
# Force bash to apply pipefail option so pipeline failures aren't masked
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
env:
21+
UPSTREAM_OSAL_REPO: nasa/osal
22+
UPSTREAM_OSAL_REF: main
23+
24+
jobs:
25+
prepare-dependencies:
26+
name: Prepare Dependencies
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Cache EdsLib Source
30+
uses: actions/cache@v3
31+
id: cache-edslib
32+
with:
33+
path: ${{ github.workspace }}/source
34+
key: edslib-source-${{ github.sha }}
35+
36+
- name: Cache OSAL Dependency
37+
uses: actions/cache@v3
38+
id: cache-osal
39+
with:
40+
path: ${{ github.workspace }}/osal-staging
41+
key: edslib-dep-${{ env.UPSTREAM_OSAL_REPO }}@${{ env.UPSTREAM_OSAL_REF }}
42+
43+
- name: Checkout EdsLib
44+
if: steps.cache-edslib.outputs.cache-hit != 'True'
45+
uses: actions/checkout@v4
46+
with:
47+
path: source
48+
49+
- name: Set up OSAL
50+
if: steps.cache-osal.outputs.cache-hit != 'True'
51+
uses: ./source/.github/actions/setup-osal
52+
with:
53+
staging-dir: ${GITHUB_WORKSPACE}/osal-staging
54+
upstream-repo: ${{ env.UPSTREAM_OSAL_REPO }}
55+
upstream-ref: ${{ env.UPSTREAM_OSAL_REF }}
56+
57+
build-and-test:
58+
name: Build EdsLib and Execute Tests
59+
needs: [prepare-dependencies]
60+
runs-on: ubuntu-latest
61+
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
buildtype: [Debug, Release]
66+
67+
env:
68+
MATRIX_ID: matrix-${{ matrix.buildtype }}
69+
70+
steps:
71+
72+
- name: Install Build Dependencies
73+
run: sudo apt-get install liblua5.4-dev libpython3-dev libjson-c-dev pkg-config lcov xsltproc -y
74+
75+
# Note - caches were updated in "prepare-dependencies" job so all three of these should be a hit
76+
- name: Retrieve Cached EdsLib Source
77+
uses: actions/cache@v3
78+
id: restore-source
79+
with:
80+
path: ${{ github.workspace }}/source
81+
key: edslib-source-${{ github.sha }}
82+
83+
- name: Retrieve Cached OSAL Dependency
84+
id: restore-osal
85+
uses: actions/cache@v3
86+
with:
87+
path: ${{ github.workspace }}/osal-staging
88+
key: edslib-dep-${{ env.UPSTREAM_OSAL_REPO }}@${{ env.UPSTREAM_OSAL_REF }}
89+
90+
# The files extracted from the cache only have owner permissions,
91+
# so in order to make this work it needs to adjust this.
92+
- name: Import OSAL
93+
run: |
94+
sudo find ${GITHUB_WORKSPACE}/osal-staging -type d -print0 | xargs -0 chmod go+rx
95+
sudo find ${GITHUB_WORKSPACE}/osal-staging -type f -print0 | xargs -0 chmod go+r
96+
sudo find ${GITHUB_WORKSPACE}/osal-staging -type f -path '*/bin/*' -print0 | xargs -0 chmod go+x
97+
sudo cp -rv -t / ${GITHUB_WORKSPACE}/osal-staging/*
98+
99+
- name: Refresh Dynamic Linker Cache
100+
run: sudo ldconfig
101+
102+
- name: Set up EdsLib Build
103+
run: cmake
104+
-DCMAKE_BUILD_TYPE=${{ matrix.buildtype }}
105+
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE
106+
-DENABLE_UNIT_TESTS=TRUE
107+
-DCMAKE_PREFIX_PATH=/usr/local/lib/cmake
108+
-S source -B ${{ env.MATRIX_ID }}
109+
110+
- name: Build BPLib
111+
working-directory: ${{ env.MATRIX_ID }}
112+
run: make all
113+
114+
- name: Check for Tests
115+
run: if [ -e '${{ env.MATRIX_ID }}/CTestTestfile.cmake' ]; then echo 'RUN_TESTS=True' >> $GITHUB_ENV; fi
116+
117+
- name: Run Tests
118+
working-directory: ${{ env.MATRIX_ID }}
119+
if: env.RUN_TESTS == 'True'
120+
run: ctest --output-on-failure 2>&1 | tee ctest.log
121+
122+
- name: Check Coverage
123+
if: env.MATRIX_ID == 'matrix-Debug'
124+
uses: ./source/.github/actions/check-coverage
125+
with:
126+
binary-dir: ${{ env.MATRIX_ID }}
127+
128+
- name: Assemble Results
129+
run: |
130+
if [ -s '${{ env.MATRIX_ID }}/ctest.log' ]; then
131+
echo '<h2>CTest Execution</h2>' >> $GITHUB_STEP_SUMMARY
132+
echo '<pre>' >> $GITHUB_STEP_SUMMARY
133+
cat '${{ env.MATRIX_ID }}/ctest.log' >> $GITHUB_STEP_SUMMARY
134+
echo '</pre>' >> $GITHUB_STEP_SUMMARY
135+
fi
136+
if [ -s '${{ env.MATRIX_ID }}/lcov-summary.xml' ]; then
137+
cat '${{ env.MATRIX_ID }}/lcov-summary.xml' >> $GITHUB_STEP_SUMMARY
138+
fi

0 commit comments

Comments
 (0)