Skip to content

Commit

Permalink
Add codecov to build.yml to upload coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MWSestabro committed Apr 12, 2024
1 parent 7869efb commit 93438b8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,38 @@ jobs:
uses: matlab-actions/run-tests@v2
with:
select-by-folder: opentelemetry-matlab/test
codecov-ubuntu:
runs-on: ubuntu-latest
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
SYSTEM_LIBSTDCPP_PATH: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
steps:
- name: Download OpenTelemetry-Matlab source
uses: actions/checkout@v3
with:
path: opentelemetry-matlab
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: MATLAB_Compiler
- name: Build OpenTelemetry-Matlab
run: |
cd opentelemetry-matlab
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
cmake --build build --config Release --target install
- name: Codecov
env:
# The version of libstdc++ that is bundled with MATLAB is used when building MEX files.
# This version of libstdc++ is incompatible with the system version of libstdc++.
# As a workaround, set LD_PRELOAD to use the system version of libstdc++ with MATLAB.
LD_PRELOAD: ${{ env.SYSTEM_LIBSTDCPP_PATH }}

# Add the installation directory to the MATLAB Search Path by
# setting the MATLABPATH environment variable.
MATLABPATH: ${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
uses: matlab-actions/run-tests@v2
with:
source-folder: install/+opentelemetry
code-coverage-cobertura: cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }}
slug: mathworks/OpenTelemetry-Matlab
14 changes: 14 additions & 0 deletions testToolbox.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
suite = testsuite(fullfile('test/'));
runner = testrunner("textoutput");
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.codecoverage.CoverageReport
import matlab.unittest.plugins.codecoverage.CoberturaFormat

sourceFile = fullfile('install','+opentelemetry');
reportFile = fullfile("cobertura.xml");
reportFormat = CoberturaFormat(reportFile);
p = CodeCoveragePlugin.forFolder(sourceFile,'IncludingSubfolders',true,'Producing',reportFormat);
runner.addPlugin(p);
result = runner.run(suite);

result.assertSuccess()

0 comments on commit 93438b8

Please sign in to comment.