Skip to content

Commit

Permalink
Package into a .mltbx file
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanpo committed Feb 28, 2024
1 parent 816eeb6 commit ae2874c
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 102 deletions.
68 changes: 1 addition & 67 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "OpenTelemetry-Matlab"
name: "Build and Run Tests"
on:
workflow_dispatch:
push:
Expand Down Expand Up @@ -35,14 +35,6 @@ jobs:
uses: matlab-actions/run-tests@v2
with:
select-by-folder: opentelemetry-matlab/test
- name: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-ubuntu.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-ubuntu.tar.gz
path: ${{ github.workspace }}/otel-matlab-ubuntu.tar.gz
build-and-run-tests-windows:
runs-on: windows-latest
env:
Expand All @@ -69,14 +61,6 @@ jobs:
uses: matlab-actions/run-tests@v2
with:
select-by-folder: opentelemetry-matlab/test
- name: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-windows.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-windows.tar.gz
path: ${{ github.workspace }}/otel-matlab-windows.tar.gz
build-and-run-tests-macos:
runs-on: macos-latest
env:
Expand All @@ -103,53 +87,3 @@ jobs:
uses: matlab-actions/run-tests@v2
with:
select-by-folder: opentelemetry-matlab/test
- name: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-macos.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-macos.tar.gz
path: ${{ github.workspace }}/otel-matlab-macos.tar.gz
package-mltbx:
name: Package MATLAB Toolbox (MLTBX) Files
runs-on: ubuntu-latest
needs:
- build-and-run-tests-ubuntu
- build-and-run-tests-windows
- build-and-run-tests-macos
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
steps:
- name: Checkout OpenTelemetry-Matlab
uses: actions/checkout@v4
with:
path: OpenTelemetry-Matlab
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts-downloaded
- name: Decompress Artifacts
run: |
mv artifacts-downloaded/*/*.tar.gz .
tar -xzf otel-matlab-ubuntu.tar.gz
tar -xzf otel-matlab-macos.tar.gz
tar -xzf otel-matlab-windows.tar.gz
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
with:
release: R2023a
- name: Run commands
env:
MATLABPATH: OpenTelemetry-Matlab/tools
OTEL_MATLAB_TOOLBOX_FOLDER: otel_matlab_install
OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER:
OTEL_MATLAB_TOOLBOX_VERSION: 1.6.0
uses: matlab-actions/run-command@v1
with:
command: packageMatlabInterface
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab.mltbx
path: otel-matlab.mltbx
128 changes: 128 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: "Publish"
on:
workflow_dispatch:
push:
branches:
- package
jobs:
build-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: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-ubuntu.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-ubuntu.tar.gz
path: ${{ github.workspace }}/otel-matlab-ubuntu.tar.gz
build-windows:
runs-on: windows-latest
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
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 -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
cmake --build build --config Release --target install
- name: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-windows.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-windows.tar.gz
path: ${{ github.workspace }}/otel-matlab-windows.tar.gz
build-macos:
runs-on: macos-latest
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
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: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-macos.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-macos.tar.gz
path: ${{ github.workspace }}/otel-matlab-macos.tar.gz
package-mltbx:
name: Package MATLAB Toolbox (MLTBX) Files
runs-on: ubuntu-latest
needs:
- build-ubuntu
- build-windows
- build-macos
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
steps:
- name: Checkout OpenTelemetry-Matlab
uses: actions/checkout@v3
with:
path: OpenTelemetry-Matlab
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts-downloaded
- name: Decompress Artifacts
run: |
mv artifacts-downloaded/*/*.tar.gz .
tar -xzf otel-matlab-ubuntu.tar.gz
tar -xzf otel-matlab-macos.tar.gz
tar -xzf otel-matlab-windows.tar.gz
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
with:
release: R2023a
- name: Run commands
env:
MATLABPATH: OpenTelemetry-Matlab/tools
OTEL_MATLAB_TOOLBOX_FOLDER: otel_matlab_install
OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER:
OTEL_MATLAB_TOOLBOX_VERSION: 1.6.0
uses: matlab-actions/run-command@v1
with:
command: packageMatlabInterface
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab.mltbx
path: otel-matlab.mltbx
49 changes: 14 additions & 35 deletions tools/packageMatlabInterface.m
Original file line number Diff line number Diff line change
@@ -1,61 +1,40 @@
% Licensed to the Apache Software Foundation (ASF) under one
% or more contributor license agreements. See the NOTICE file
% distributed with this work for additional information
% regarding copyright ownership. The ASF licenses this file
% to you under the Apache License, Version 2.0 (the
% "License"); you may not use this file except in compliance
% with the License. You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing,
% software distributed under the License is distributed on an
% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
% KIND, either express or implied. See the License for the
% specific language governing permissions and limitations
% under the License.
% packageMatlabInterface.m
% This script packages installed files for OpenTelemetry interface and
% package them into a single .mltbx file. The location of the installed
% files is taken from environment variable OTEL_MATLAB_TOOLBOX_FOLDER and
% the resulting .mltbx file location is taken from environment variable
% OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER.

% Copyright 2024 The MathWorks, Inc.

toolboxFolder = string(getenv("OTEL_MATLAB_TOOLBOX_FOLDER"));
outputFolder = string(getenv("OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER"));
toolboxVersionRaw = string(getenv("OTEL_MATLAB_TOOLBOX_VERSION"));
toolboxVersion = string(getenv("OTEL_MATLAB_TOOLBOX_VERSION"));

% Output folder must exist.
mkdir(outputFolder);

disp("Toolbox Folder: " + toolboxFolder);
disp("Output Folder: " + outputFolder);
disp("Toolbox Version Raw: " + toolboxVersionRaw);

% Note: This string processing heuristic may not be robust to future
% changes in the versioning scheme.
dotIdx = strfind(toolboxVersionRaw, ".");
numDots = numel(dotIdx);
if numDots >= 3
toolboxVersion = extractBefore(toolboxVersionRaw, dotIdx(3));
else
toolboxVersion = toolboxVersionRaw;
end

disp("Toolbox Version:" + toolboxVersion);

identifier = "dc2cae2f-4f43-4d2c-b6ed-f1a59f0dfcdf";
opts = matlab.addons.toolbox.ToolboxOptions(toolboxFolder, identifier);
opts.ToolboxName = "MATLAB Interface to OpenTelemetry";
opts.ToolboxVersion = toolboxVersion;
opts.AuthorName = "";
opts.ToolboxMatlabPath = toolboxFolder;
disp("Toolbox MATLAB Path: " + opts.ToolboxMatlabPath);
opts.AuthorName = "MathWorks DevOps Team";
opts.AuthorEmail = "";

% Set the SupportedPlatforms
opts.SupportedPlatforms.Win64 = true;
opts.SupportedPlatforms.Maci64 = true;
opts.SupportedPlatforms.Glnxa64 = true;
%opts.SupportedPlatforms.MatlabOnline = true;
opts.SupportedPlatforms.MatlabOnline = false;

% Interface is only qualified against R2023a at the moment
opts.MinimumMatlabRelease = "R2023a";
opts.MaximumMatlabRelease = "R2023a";
opts.MinimumMatlabRelease = "R2022a";

%opts.OutputFile = fullfile(outputFolder, compose("otel-matlab-%s.mltbx", toolboxVersionRaw));
opts.OutputFile = fullfile(outputFolder, "otel-matlab.mltbx");
disp("Output File: " + opts.OutputFile);
matlab.addons.toolbox.packageToolbox(opts);

0 comments on commit ae2874c

Please sign in to comment.