-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
716c1d5
commit 1435d17
Showing
13 changed files
with
132 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
dev/common/+ommtools/getProjectRootDir.m → dev/+ommtools/projectdir.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
function rootFolder = getProjectRootDir() | ||
function rootFolder = projectdir() | ||
scriptFolder = fileparts(mfilename('fullpath')); | ||
% Assumes project root directory is 3 levels up from script location | ||
rootFolder = fileparts(fileparts(fileparts(scriptFolder))); | ||
rootFolder = fileparts(fileparts(scriptFolder)); | ||
L = dir(rootFolder); | ||
assert(all(contains( {'code', 'dev'}, {L.name})), ... | ||
'Expected project root directory to contain "code" and "dev" folder.'); | ||
'Expected project root directory to contain "code" and "tools" folder.'); | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
{ | ||
"Identifier": "b8bc10bb-6afb-4c6a-b357-a57037d1dcb3", | ||
"ToolboxName": "openMINDS Metadata Models", | ||
"AuthorName": "Eivind Hennestad", | ||
"AuthorEmail": "[email protected]", | ||
"AuthorCompany": "openMetadataInitiative", | ||
"Summary": "A MATLAB toolbox to create metadata instances using the openMINDS metadata models", | ||
"Description": "MATLAB package for the openMINDS metadata models. The package contains all the latest openMINDS schemas as MATLAB classes in addition to schema base classes and utility methods", | ||
"MinimumMatlabRelease": "R2022b", | ||
"MaximumMatlabRelease": "" | ||
"Namespace" : "openminds", | ||
"ToolboxOptions": { | ||
"Identifier": "b8bc10bb-6afb-4c6a-b357-a57037d1dcb3", | ||
"ToolboxName": "openMINDS Metadata Models", | ||
"AuthorName": "Eivind Hennestad", | ||
"AuthorEmail": "[email protected]", | ||
"AuthorCompany": "openMetadataInitiative", | ||
"Summary": "A MATLAB toolbox to create metadata instances using the openMINDS metadata models", | ||
"Description": "MATLAB package for the openMINDS metadata models. The package contains all the latest openMINDS schemas as MATLAB classes in addition to schema base classes and utility methods", | ||
"MinimumMatlabRelease": "R2022b", | ||
"MaximumMatlabRelease": "" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function codecheckToolbox() | ||
% codecheckToolbox - Identify code issues for openMINDS_MATLAB toolbox | ||
|
||
installMatBox("commit") | ||
projectRootDirectory = ommtools.projectdir(); | ||
|
||
matbox.tasks.codecheckToolbox(projectRootDirectory, ... | ||
"CreateBadge", true) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,8 @@ | ||
function createTestedWithBadgeforToolbox(versionNumber, rootDir) | ||
%createTestedWithBadgesforToolbox - Take the test reports from the runs against | ||
% multiple MATLAB releases, and generate the "Tested with" badge | ||
% | ||
% Adapted from: https://github.com/mathworks/climatedatastore/tree/main/buildUtilities | ||
|
||
function createTestedWithBadgeforToolbox(versionNumber) | ||
arguments | ||
versionNumber (1,1) string | ||
rootDir (1,1) string {mustBeFolder} = ommtools.getProjectRootDir() | ||
end | ||
|
||
releasesTestedWith = ""; | ||
releasesFailed = 0; | ||
% Go through the R2* directories and extract the failed test info | ||
releaseDirectoryInfo = dir(fullfile(rootDir, "docs", "reports")); | ||
% Select only folders | ||
releaseDirectoryInfo = releaseDirectoryInfo([releaseDirectoryInfo.isdir]); | ||
% with a name like R2* | ||
releaseDirectoryInfo = releaseDirectoryInfo(startsWith(string({releaseDirectoryInfo.name}), "R2", "IgnoreCase", true)); | ||
|
||
% Sort releases newest to oldest | ||
[~, ix] = sort(string({releaseDirectoryInfo.name}), "descend"); | ||
releaseDirectoryInfo = releaseDirectoryInfo(ix); | ||
|
||
% go through the directories and check if tests passed | ||
for iReleaseDirectoryInfo = 1:numel(releaseDirectoryInfo) | ||
releaseName = string(releaseDirectoryInfo(iReleaseDirectoryInfo).name); | ||
testresultsFilename = fullfile(releaseDirectoryInfo(iReleaseDirectoryInfo).folder, releaseName, "test-results.xml"); | ||
% Read the test results file | ||
testResults = readstruct(testresultsFilename); | ||
% If no tests failed, errors, or were skipped, then add it to the list | ||
if sum([testResults.testsuite.errorsAttribute]) == 0 ... | ||
&& sum([testResults.testsuite.failuresAttribute]) == 0 ... | ||
&& sum([testResults.testsuite.skippedAttribute]) == 0 | ||
if releasesTestedWith ~= "" | ||
% Insert the separator between released after the first one | ||
releasesTestedWith = releasesTestedWith + " | "; | ||
end | ||
releasesTestedWith = releasesTestedWith + releaseName; | ||
else | ||
releasesFailed = releasesFailed + 1; | ||
end | ||
end | ||
if releasesTestedWith ~= "" | ||
switch releasesFailed | ||
case 0 | ||
badgecolor = "green"; | ||
case 1 | ||
badgecolor = "orange"; | ||
case 2 | ||
badgecolor = "yellow"; | ||
otherwise | ||
badgecolor = "red"; | ||
end | ||
|
||
outputDirectory = fullfile(rootDir, '.github', 'badges', versionNumber); | ||
utility.writeBadgeJSONFile("tested with", releasesTestedWith, badgecolor,... | ||
"OutputFolder", outputDirectory) | ||
end | ||
installMatBox() | ||
projectRootDirectory = ommtools.projectdir(); | ||
matbox.tasks.createTestedWithBadgeforToolbox(versionNumber, projectRootDirectory) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
function installMatBox(mode) | ||
% installMatBox - Install MatBox from latest release or latest commit | ||
|
||
% Todo: | ||
% - If MatBox release has been updated on remote, should reinstall. | ||
|
||
arguments | ||
mode (1,1) string {mustBeMember(mode, ["release", "commit"])} = "release" | ||
end | ||
|
||
if mode == "release" | ||
installFromRelease() % local function | ||
elseif mode == "commit" | ||
installFromCommit() % local function | ||
end | ||
end | ||
|
||
function installFromRelease() | ||
addonsTable = matlab.addons.installedAddons(); | ||
isMatchedAddon = addonsTable.Name == "MatBox"; | ||
|
||
if ~isempty(isMatchedAddon) && any(isMatchedAddon) | ||
matlab.addons.enableAddon('MatBox') | ||
else | ||
info = webread('https://api.github.com/repos/ehennestad/MatBox/releases/latest'); | ||
assetNames = {info.assets.name}; | ||
isMltbx = startsWith(assetNames, 'MatBox'); | ||
|
||
mltbx_URL = info.assets(isMltbx).browser_download_url; | ||
|
||
% Download matbox | ||
tempFilePath = websave(tempname, mltbx_URL); | ||
cleanupObj = onCleanup(@(fp) delete(tempFilePath)); | ||
|
||
% Install toolbox | ||
matlab.addons.install(tempFilePath); | ||
end | ||
end | ||
|
||
function installFromCommit() | ||
% Download latest zipped version of repo | ||
url = "https://github.com/ehennestad/MatBox/archive/refs/heads/main.zip"; | ||
tempFilePath = websave(tempname, url); | ||
cleanupObj = onCleanup(@(fp) delete(tempFilePath)); | ||
|
||
% Unzip in temporary location | ||
unzippedFiles = unzip(tempFilePath, tempdir); | ||
unzippedFolder = unzippedFiles{1}; | ||
if endsWith(unzippedFolder, filesep) | ||
unzippedFolder = unzippedFolder(1:end-1); | ||
end | ||
|
||
% Move to installation location | ||
[~, repoFolderName] = fileparts(unzippedFolder); | ||
targetFolder = fullfile(userpath, "Add-Ons"); | ||
targetFolder = fullfile(targetFolder, repoFolderName); | ||
if isfolder(targetFolder); rmdir(targetFolder, "s"); end | ||
movefile(unzippedFolder, targetFolder); | ||
|
||
% Add to MATLAB's search path | ||
addpath(genpath(targetFolder)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function testToolbox(varargin) | ||
% testToolbox - Run tests for openMINDS_MATLAB toolbox | ||
|
||
% Prepare | ||
installMatBox("commit") | ||
projectRootDirectory = ommtools.projectdir(); | ||
% matbox.installRequirements(projectRootDirectory) % No requirements... | ||
|
||
matbox.tasks.testToolbox(... | ||
projectRootDirectory, ... | ||
"CreateBadge", true, ... | ||
"ToolsFolderName", 'dev', ... | ||
varargin{:} ... | ||
) | ||
end |
Oops, something went wrong.