Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Use external project MatBox for developer tools #27

Merged
merged 43 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1435d17
Update tasks to use MatBox
ehennestad Oct 25, 2024
17a9385
Update code issues and tests badges
Oct 25, 2024
b6cfb82
Add upload of code issues report in "update" workflow
ehennestad Oct 25, 2024
155ec86
Merge branch 'change/use-matbox' of https://github.com/openMetadataIn…
ehennestad Oct 25, 2024
efa19a8
Update README.md
ehennestad Oct 25, 2024
54655c8
Merge branch 'main' into change/use-matbox
ehennestad Oct 25, 2024
68bac75
Merge branch 'main' into change/use-matbox
ehennestad Oct 25, 2024
e547e5a
Update README.md
ehennestad Oct 25, 2024
f141514
Update README.md
ehennestad Oct 25, 2024
07a8280
Update update.yml
ehennestad Oct 25, 2024
022632a
Merge branch 'change/use-matbox' of https://github.com/openMetadataIn…
ehennestad Oct 25, 2024
9565d97
Fix typos
ehennestad Oct 25, 2024
a0e5f24
Move installMatBox to ommtools namespace
ehennestad Oct 25, 2024
450a21e
Add codespellToolbox function
ehennestad Oct 25, 2024
42ac4f1
Delete writeBadgeJSONFile.m
ehennestad Oct 25, 2024
cbaba98
Fix code issue
ehennestad Oct 25, 2024
2948c0e
Update code issues and tests badges
Oct 25, 2024
2170225
Minor change
ehennestad Oct 26, 2024
6512f59
Add pre-commit hook
ehennestad Oct 26, 2024
15831f2
Update code issues and tests badges
Oct 26, 2024
27052e3
Update README.md
ehennestad Oct 27, 2024
d1fa5c2
Update README.md
ehennestad Oct 27, 2024
bdbb874
Update README.md
ehennestad Oct 27, 2024
36e02ac
Update README.md
ehennestad Oct 27, 2024
2955487
Merge branch 'main' into x/change/use-matbox
ehennestad Oct 28, 2024
addfd03
Update testToolbox.m
ehennestad Oct 28, 2024
84f6fbc
Remove functions for releasing that are now part of MatBox
ehennestad Oct 28, 2024
71f45e2
Update MLToolboxInfo.json
ehennestad Oct 28, 2024
e0731f6
Update packageToolbox to use MatBox
ehennestad Oct 28, 2024
ab574a0
rename dev to tools
ehennestad Oct 28, 2024
3a7d1c4
Format whitespace
ehennestad Oct 28, 2024
e8c141c
Update code issues and tests badges
Oct 28, 2024
588fde3
Delete mustBeValidVersionNumber.m
ehennestad Oct 28, 2024
c565ee1
Update README.md
ehennestad Oct 28, 2024
ed4a51c
Update release workflow
ehennestad Oct 30, 2024
6bc6b49
Update code issues and tests badges
Oct 30, 2024
ac888ff
Update badges in README.md
ehennestad Oct 30, 2024
e87b7fc
Create codecov.yml
ehennestad Oct 30, 2024
cdb14d3
Update release workflow based on latest release workflow in MatBox
ehennestad Oct 30, 2024
7fb72a3
Delete deprecated json badges
ehennestad Oct 30, 2024
6302047
Update update.yml
ehennestad Oct 30, 2024
60f98ab
Fix renamed files
ehennestad Oct 30, 2024
53251c2
Add test class for internal functions
ehennestad Oct 30, 2024
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
1 change: 1 addition & 0 deletions .github/badges/code_issues.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/badges/tests.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion .github/badges/v0.9.3/tested_with.json

This file was deleted.

12 changes: 12 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
coverage:
range: "75...100"
status:
project:
default:
target: 30 # Set the desired coverage target as 40%
threshold: 2 # Allowable drop in coverage
patch:
default:
# 50% of the changed code must be covered by tests
threshold: 50
only_pulls: true
85 changes: 60 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Test openMINDS MATLAB Toolbox across all supported releases of MATLAB, package toolbox, create release
# Adapted from: https://github.com/mathworks/climatedatastore/blob/main/.github/workflows/release.yml

name: MATLAB Release
name: Create new release

# Run workflow when a tag is created
on:
Expand All @@ -23,7 +23,8 @@ jobs:

steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
Expand All @@ -34,7 +35,9 @@ jobs:
- name: Run tests
uses: matlab-actions/run-command@v2
with:
command: addpath(genpath("dev")), testToolbox('ReportSubdirectory',"${{ matrix.MATLABVersion }}")
command: |
addpath(genpath("tools"));
testToolbox('ReportSubdirectory',"${{ matrix.MATLABVersion }}", 'CreateBadge', false)

# Upload code coverage information to Codecov
- name: Upload code coverage report to Codecov (https://app.codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB)
Expand All @@ -46,7 +49,7 @@ jobs:
env_vars: ${{ matrix.MATLABVersion }}

# Save the contents of the report directory from each release into an artifact.
- name: Save Report Directory
- name: Save report directory
uses: actions/upload-artifact@v4
if: always()
with:
Expand All @@ -62,10 +65,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
# Use deploy key to push back to protected branch
- name: Checkout repository using deploy key
uses: actions/checkout@v4
with:
ref: refs/heads/main

ref: refs/heads/main
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2

Expand All @@ -80,20 +86,20 @@ jobs:
- name: Generate tested with badge
uses: matlab-actions/run-command@v2
with:
command: addpath(genpath("dev")), createTestedWithBadgeforToolbox("${{ github.ref_name }}")
command: addpath(genpath("tools")), createTestedWithBadgeforToolbox("${{ github.ref_name }}")

# Publish test results from all the releases
- name: Publish Test Results
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
junit_files: "docs/reports/*/test-results.xml"

# Package the MLTBX
- name: Package Toolbox
- name: Package toolbox
uses: matlab-actions/run-command@v2
with:
command: addpath(genpath("dev")), packageToolbox("specific","${{ github.ref_name }}")
command: addpath(genpath("tools")), packageToolbox("specific","${{ github.ref_name }}")

# Define the versionNumber using underscores, as this is used in the MLTBX
- name: Set version number
Expand All @@ -102,45 +108,74 @@ jobs:
versionNumber=$(echo "${{ github.ref_name }}" | sed 's/\./_/g')
echo "versionNumber=$versionNumber" >> $GITHUB_ENV


# Save the MLTBX.
- name: Save Packaged Toolbox
- name: Save packaged toolbox
uses: actions/upload-artifact@v4
with:
name: openMINDS_MATLAB_${{ env.versionNumber }}.mltbx
path: releases/openMINDS_MATLAB_${{ env.versionNumber }}.mltbx

# Commit the JSON for the MATLAB releases badge and ToolboxPackaging.prj
- name: commit changed files
# Commit the updated Contents.m
- name: Commit updated Contents.m file
continue-on-error: true
run: |
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
git status
git add code/Contents.m
git add .github/badges/${{ github.ref_name }}/tested_with.json
git commit -m "Final checkins for release ${{ github.ref_name }}"
git fetch
git push

# Commit the JSON for the MATLAB releases test badge to gh-badges branch
- name: Checkout gh-badges branch
uses: actions/checkout@v4
with:
ref: gh-badges
path: gh-badges
token: ${{ secrets.GITHUB_TOKEN }}

- name: Push to gh-badges
run: |
mkdir -p gh-badges/.github/badges/${{ github.ref_name }}
cp .github/badges/${{ github.ref_name }}/tested_with.json gh-badges/.github/badges/${{ github.ref_name }}/tested_with.json
cd gh-badges

git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"

# Only proceed with commit and push if changes are detected
if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then
git add .github/badges/*
git commit -m "Update tested with badge for release"
git push -f
else
echo "Nothing to commit"
fi

# Retag the repo so that the updated files are included in the release tag
- name: update tag
- name: Update tag
if: always()
continue-on-error: true
run: |
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
git tag -d "${{ github.ref_name }}"
git push --delete origin ${{ github.ref_name }}
git tag -m "Release ${{ github.ref_name }}" ${{ github.ref_name }}
git push --tag

# Delete the existing tag locally and remotely
git tag -d "${{ github.ref_name }}"
git push origin --delete "${{ github.ref_name }}"

# Recreate the tag with a message, including [skip ci] to prevent CI workflows
git tag -a "${{ github.ref_name }}" -m "Release ${{ github.ref_name }} [skip ci]"

# Push the new tag to the remote repository
git push origin "${{ github.ref_name }}"

# Create the release
- name: Create GitHub Release
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
draft: true
artifacts: "releases/openMINDS_MATLAB_${{ env.versionNumber }}.mltbx"
generateReleaseNotes: true
body: "![MATLAB Versions Tested](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FopenMetadataInitiative%2FopenMINDS_MATLAB%2Fmain%2F.github%2Fbadges%2F${{ github.ref_name }}%2Ftested_with.json)"

body: "![MATLAB Versions Tested](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FopenMetadataInitiative%2FopenMINDS_MATLAB%2Fgh-badges%2F.github%2Fbadges%2F${{ github.ref_name }}%2Ftested_with.json)"
71 changes: 54 additions & 17 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: Update openMINDS_MATLAB

on:
# Triggers the workflow on push or pull request events for the "main" branch
# Triggers the workflow on push to any branch other than main or PR to main
# This way tests will run on any push to a feature branch and when feature
# branches are merged to main, but not repeated when PRs are actually merged.
push:
branches-ignore: ["pipeline"]
branches-ignore: ["main", "pipeline", "gh-badges"]
paths-ignore:
- '*README.md'
- '.github/workflows/**'
- 'docs/reports/**'
- '*md'
- '.github/**'
pull_request:
branches: [ "main" ]

# Allows for manually running this workflow from the Actions tab
workflow_dispatch:

Expand All @@ -25,7 +26,7 @@ jobs:
steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
- name: Check out repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
Expand All @@ -35,27 +36,38 @@ jobs:
uses: matlab-actions/run-command@v2
if: always()
with:
command: addpath(genpath("dev")),codecheckToolbox()
command: addpath(genpath("tools")),codecheckToolbox()

# Upload code issues report
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: docs/reports/code_issues.sarif

# Runs all tests in the project.
# Run all tests in the project.
- name: Run tests
uses: matlab-actions/run-command@v2
if: always()
with:
command: addpath(genpath("dev")), testToolbox()
command: addpath(genpath("tools")), testToolbox()

# Commit the JSON for the badge for the issues and tests
- name: commit code issues badge JSON
# Commit updated SVG badges for the issues and tests (if changed)
- name: Commit svg badges if updated
if: always()
continue-on-error: true
run: |
git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"
git add docs/reports/badge/code_issues.json docs/reports/badge/tests.json
git commit -m "Update code issues and tests badges"
git fetch
# git push returns error code 1 if there's nothing to push (which there often isn't in this case)
git push || true

if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then
git add .github/badges/*
git commit -m "Update code issues and tests badges"
git push -f
else
echo "Nothing to commit"
fi

- name: Upload code coverage report to Codecov (https://app.codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB)
uses: codecov/codecov-action@v4
Expand All @@ -65,16 +77,41 @@ jobs:
files: docs/reports/codecoverage.xml

# Publish test results
- name: Publish Test Results
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: "docs/reports/test-results.xml"

# Save the contents of the reports directory as an artifact
- name: Save Reports Directory
- name: Save reports directory
uses: actions/upload-artifact@v4
if: always()
with:
name: reports
path: docs/reports

- name: Checkout gh-badges branch
uses: actions/checkout@v4
with:
ref: gh-badges
path: gh-badges
token: ${{ secrets.GITHUB_TOKEN }}

- name: Push to gh-badges
run: |
cp .github/badges/code_issues.svg gh-badges/.github/badges/code_issues.svg
cp .github/badges/tests.svg gh-badges/.github/badges/tests.svg
cd gh-badges

git config user.name "${{ github.workflow }} by ${{ github.actor }}"
git config user.email "<>"

# Only proceed with commit and push if changes are detected
if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then
git add .github/badges/*
git commit -m "Update code issues and tests badges"
git push -f
else
echo "Nothing to commit"
fi
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ releases/
# Ignore everything in docs/reports
docs/reports/*

# Don't ignore the badge file/directory
!docs/reports/badge

# Autosave files
*.asv
*.m~
Expand Down
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,37 @@
[![Version Number](https://img.shields.io/github/v/release/openMetadataInitiative/openMINDS_MATLAB?label=version)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/releases/latest)
[![Open in MATLAB Online](https://github.com/openMetadataInitiative/openMINDS_MATLAB/blob/gh-badges/.github/badges/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=openMetadataInitiative/openMINDS_MATLAB&file=code/gettingStarted.mlx)
[![View openMINDS_MATLAB on File Exchange](https://github.com/openMetadataInitiative/openMINDS_MATLAB/blob/gh-badges/.github/badges/matlab-file-exchange.svg)](https://se.mathworks.com/matlabcentral/fileexchange/134212-openminds_matlab)
![MATLAB Tests](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FopenMetadataInitiative%2FopenMINDS_MATLAB%2Fgh-badges%2F.github%2Fbadges%2Ftests.json)
[![MATLAB Tests](.github/badges/tests.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/actions/workflows/update.yml)
[![codecov](https://codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB/graph/badge.svg?token=FTD5FHZSFA)](https://codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB)
![MATLAB Code Issues](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FopenMetadataInitiative%2FopenMINDS_MATLAB%2Fgh-badges%2F.github%2Fbadges%2Fcode_issues.json)
[![MATLAB Code Issues](.github/badges/code_issues.svg)](https://github.com/openMetadataInitiative/openMINDS_MATLAB/security/code-scanning)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://gitHub.com/openMetadataInitiative/openMINDS_MATLAB/graphs/commit-activity)

<p align="center">
<a href="#requirements-and-installation">Requirements and Installation</a> •
<a href="#before-you-start">Before you start</a> •
<a href="#getting-started">Getting Started</a> •
<a href="#acknowledgements">Acknowledgements</a>
</p>

---


MATLAB package for the openMINDS metadata framework for linked data in neuroscience. The package contains all the latest openMINDS schemas as MATLAB classes in addition to schema base classes and utility methods.

To generally learn more about the openMINDS metadata framework please go to :arrow_right: [**ReadTheDocs**](https://openminds-documentation.readthedocs.io).
You can test and learn how to use openMINDS in MATLAB by going through a small :arrow_right: [**DEMO**](https://matlab.mathworks.com/open/github/v1?repo=openMetadataInitiative/openMINDS_MATLAB&file=code/gettingStarted.mlx) on MATLAB Online.

MathWorks provides a free basic version of [MATLAB Online](https://uk.mathworks.com/products/matlab-online.html), but you need to register for a [MathWorks Account](https://www.mathworks.com/mwaccount/register?uri=https%3A%2F%2Fwww.mathworks.com%2Fproducts%2Fmatlab.html).

<p align="right">

## Requirements and Installation
openMINDS for MATLAB requires **MATLAB R2022b** or later. The toolbox can be installed from MATLAB's [Add-On Explorer](https://se.mathworks.com/help/matlab/matlab_env/get-add-ons.html) (recommended). It is also possible to download the MATLAB toolbox from [FileExchange](https://se.mathworks.com/matlabcentral/fileexchange/134212-openminds_matlab) or from the [Releases](https://github.com/openMetadataInitiative/openMINDS_MATLAB/releases/latest) page of this repository and install it manually. If you are new to MATLAB, see the detailed [installation instructions](#Detailed-Installation-Instructions)
[(Back to top)](#openminds-metadata-models-for-matlab)

openMINDS for MATLAB requires **MATLAB R2022b** or later. The toolbox can be installed from MATLAB's [Add-On Explorer](https://se.mathworks.com/help/matlab/matlab_env/get-add-ons.html) (recommended). It is also possible to download the MATLAB toolbox from [FileExchange](https://se.mathworks.com/matlabcentral/fileexchange/134212-openminds_matlab) or from the [Releases](https://github.com/openMetadataInitiative/openMINDS_MATLAB/releases/latest) page of this repository and install it manually. If you are new to MATLAB, see the detailed [installation instructions](#Detailed-Installation-Instructions)

## Before you start
[(Back to top)](#openminds-metadata-models-for-matlab)

```matlab
% Verify that openMINDS_MATLAB is installed
disp( openminds.toolboxversion )
Expand All @@ -41,6 +54,7 @@ If you have installed **openMINDS_MATLAB** and the above command does not work,


## Getting Started
[(Back to top)](#openminds-metadata-models-for-matlab)

See also: [Crew Member Collection Tutorial](./docs/tutorials/crewMemberCollection.md)

Expand Down Expand Up @@ -153,13 +167,16 @@ disp(subject1)
```

## Detailed Installation Instructions
[(Back to top)](#openminds-metadata-models-for-matlab)

The easiest way to install the openMINDS for MATLAB is to use the [**Add-on Explorer**](https://www.mathworks.com/products/matlab/add-on-explorer.html):
1. Launch the Add-on Explorer from MATLAB's Home tab. Click Add-Ons -> Get Add-Ons<img width="860" alt="openminds_installation_step1" src="https://github.com/openMetadataInitiative/openMINDS_MATLAB/assets/17237719/71e7d8a3-1548-44e4-8ad2-84798773ce90">
2. Search for "openminds"
3. Select openMINDS Metadata Models for MATLAB<img width="860" alt="openminds_installation_step2" src="https://github.com/openMetadataInitiative/openMINDS_MATLAB/assets/17237719/f46eb742-b2c8-47a1-a46b-c96a3d4c0b35">
4. Press the "Add" button.<img width="860" alt="openminds_installation_step4" src="https://github.com/openMetadataInitiative/openMINDS_MATLAB/assets/17237719/cc2edc9e-4a5d-43cd-a3fc-a94a52d8d84a">

## Acknowledgements
[(Back to top)](#openminds-metadata-models-for-matlab)

<div><img src="https://www.braincouncil.eu/wp-content/uploads/2018/11/wsi-imageoptim-EU-Logo.jpg" alt="EU Logo" height="23%" width="15%" align="right" style="margin-left: 10px"></div>

Expand Down
Loading
Loading