Git Product home page Git Product logo

moxunit-action's Introduction

MOxUnit action

GitHub Marketplace Test codecov

This action performs unit tests for GNU Octave and Matlab using the unit testing framework MOxUnit. Documentation tests and coverage reports are supported via MOdox and MOCov.

Container

This action uses the qmrlab/octaveci:latest docker image which contains GNU-Octave 5.2.0 and the following packages/versions:

Package Name    | Version | Installation directory
----------------+---------+-----------------------
       control  |   3.2.0 | /usr/share/octave/packages/control-3.2.0
data-smoothing  |   1.3.0 | /usr/share/octave/packages/data-smoothing-1.3.0
     dataframe  |   1.2.0 | /usr/share/octave/packages/dataframe-1.2.0
         dicom  |   0.2.2 | /usr/share/octave/packages/dicom-0.2.2
     financial  |   0.5.3 | /usr/share/octave/packages/financial-0.5.3
         image  |  2.12.0 | /usr/share/octave/packages/image-2.12.0
            io  |  2.4.13 | /usr/share/octave/packages/io-2.4.13
         optim  |   1.6.0 | /usr/share/octave/packages/optim-1.6.0
      parallel  |   3.1.3 | /usr/share/octave/packages/parallel-3.1.3
    statistics  |   1.4.1 | /usr/share/octave/packages/statistics-1.4.1
       strings  |   1.2.0 | /usr/share/octave/packages/strings-1.2.0
        struct  |  1.0.16 | /usr/share/octave/packages/struct-1.0.16

Usage

CI-beginner github example

  1. at your github repo click on the "Actions" button or go to https://github.com/[user]/[repo]/actions
  2. add a new workflow by clicking on "New workflow"
  3. click on "set up a workflow yourself" to create you .yml configuration file
  4. paste this: (where mySimpleTest1.m is a test script of function placed in your repo)
name: moxunittest

on:
 push:
   branches: [ main ]
 pull_request:
   branches: [ main ]

jobs:
 build:
   runs-on: ubuntu-latest
   steps:
     - uses: actions/checkout@v2
     - uses: joergbrech/moxunit-action@v1
       with:
         tests: mySimpleTest1.m
  1. commit the change and go back to actions to check the build status.

CI-non-beginner user

In the simplest case

steps:
 - uses: actions/checkout@v2
 - uses: joergbrech/moxunit-action@v1

runs all MOxUnit test cases found in this repository. A more complex use case could look like this:

steps:
- uses: actions/checkout@v2
 - uses: joergbrech/moxunit-action@v1
  with:
    tests: tests my_extra_testfile.m
    src: src thirdparty util
    with_coverage: true
    doc_tests: true
    cover_xml_file: coverage.xml
- uses: codecov/codecov-action@v1
  with:
    file: ./coverage.xml

To use your test data along with Octave packages, you can see this example configuration file.

Arguments

All file and directory paths are interpreted as relative to the working directory, which defaults to the Github Workspace. Optionally, the working-directory can be changed with the argument working_directory, see below.

Input Description Usage
tests files or directories containing the MOxUnit test cases Optional, defaults to the root directory of the repo. All subdirectories are added recursively.
src directories to be added to the Octave search path before running the tests. These directories will be considered in the coverage reports, if coverage is enabled. Optional
data Directory for test data Optional
pkg Octave packages to load. Available options: image io optim parallel statistics struct Optional
ext External resources to add to the search put (excluded from coverage) Optional
log_file store the output in file output Optional
doc_tests set to true to run documentation tests with MOdox Optional
with_coverage set to true to record coverage using MOCov Optional
cover_xml_file store coverage XML output in file Optional
cover_html_dir store coverage HTML output in directory Optional
cover_junit_xml_file store test results in junit XML file Optional
cover_json_file store coverage report in json file for processing by coveralls.io Optional
working_directory relative path to a working directory under the github workspace, defaults to .. Optional

moxunit-action's People

Contributors

agahkarakuzu avatar joergbrech avatar jorgepz avatar remi-gau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

moxunit-action's Issues

errors in coverage report

Hi, I am having odd results in the coverage report generated using moxunit-action. My final goal is to get it working for the ONSAS.m but I created a much simpler repo to reproduce the errors and explain better.

I created this minimal repo where this simple test script is run https://github.com/jorgepz/Octave_Matlab_CI_Testbed/blob/master/test/moxunit_testWithCoverage.m the process goes well, both tests are executed and passed https://github.com/jorgepz/Octave_Matlab_CI_Testbed/actions/runs/4252541995/jobs/7396264753 but for some reason the coverage report show only part of the file executions of the last test https://app.codecov.io/gh/jorgepz/Octave_Matlab_CI_Testbed . This is the same behavior that i am seeing in the ONSAS repo.

I am aware that this could be a MOcov issue, but I was not able to run it locally yet.

Thanks in advance

Bump octave version

Would it be possible to bump the octave version and maybe not depend on qmrilab image for the base build?

Maybe from spm12 docker image? Because the Docker recipe is available

https://github.com/spm/spm-docker

docker pull ghcr.io/spm/spm-docker:docker-octave

setting up several ext directories

Hey

Related to bids-standard/bids-matlab#108

Trying to list several ext directories to add to the path of the MOxUnit github action give some weird results.

    - name: MOxUnit Action
      uses: joergbrech/moxunit-action@master
      with:
        tests: tests
        src: +bids 
        ext: JSONio tests/utils      # < ------ External resources to add to the search put (excluded from coverage)
        with_coverage: true
        cover_xml_file: coverage.xml

This fails:
https://github.com/bids-standard/bids-matlab/pull/108/checks?check_run_id=1694214979

The setup phase of the action gives this (amongst other things):

addpath(genpath("/github/workspace/JSONio tests/utils"));

Expected behavior

I think I would have assumed that the set up phase would do something like this.

addpath(genpath("/github/workspace/JSONio"));
addpath(genpath("/github/workspace/tests/utils"));

Am I correct in my expectations?

Updating Octave version?

@joergbrech I will soon upgrade the Octave version to 5.2.0 (Ubuntu 20.04 based) in the Docker images I built for our software. Currently we are pulling from qmrlab/octaveci:v4.2.2, I can update this to the new one if you agree.

Best!

0% coverage report from codecov

I am getting some strange reports from codecov from the output from the moxunit-action.

My tests passes, the coverage differences show some changes, but it still tells me I am hitting 0 lines.

See here: bids-standard/bids-matlab#124 (comment)

I could take it up with codecov but I would like to make sure it does not come from moxunit action or moxunit first.

Any idea or pointer?

Problems running tests that depend on another repository

I'd been using MOxUnit successfully for a long time with another build system, and when I needed to migrate to GitHub Actions, I figured I would use this system. I'm having difficulty, however, because my tests use some large data files that are in another repository. I can get both repositories checked out, but moxunit-action appears to run in a fixed location, and thus I'm not able to run on GitHub actions using the same relative directory convention that has worked for me in the past, since the location where it runs is unrelated to the location where checkouts occur.

Can't reproduce failures locally

I once in a while run into failures that I can't reproduce locally, on either Matlab, octave 4 or 5.

For example the following code fails with that error in CI (details below):

subject.(modality) = [subject.(modality), p]

failure: octave_base_value::convert_to_str_internal (): wrong type argument 'scalar struct'
  append_to_layout:52 (/github/workspace/+bids/+internal/append_to_layout.m)

https://github.com/bids-standard/bids-matlab/pull/124/checks?check_run_id=1902345529

I am trying to figure out what is going on but this becoming a bit of a headache. Any idea?

>> subject.(modality)

ans = 

  0×0 empty struct array with no fields.

>> p

p = 

  struct with fields:

    filename: 'sub-16_ses-mri_run-1_acq-hd_T1w.nii.gz'
         ext: '.nii.gz'
      suffix: 'T1w'
    entities: [1×1 struct]

>>  subject.(modality) = [subject.(modality), p]

subject = 

  struct with fields:

    anat: [1×1 struct]

setting up several `ext` directories

Hey

Related to bids-standard/bids-matlab#108

Trying to list several ext directories to add to the path of the MOxUnit github action give some weird results.

    - name: MOxUnit Action
      uses: joergbrech/moxunit-action@master
      with:
        tests: tests
        src: +bids 
        ext: JSONio tests/utils      # < ------ External resources to add to the search put (excluded from coverage)
        with_coverage: true
        cover_xml_file: coverage.xml

This fails:
https://github.com/bids-standard/bids-matlab/pull/108/checks?check_run_id=1694214979

The setup phase of the action gives this (amongst other things):

addpath(genpath("/github/workspace/JSONio tests/utils"));

Expected behavior

I think I would have assumed that the set up phase would do something like this.

addpath(genpath("/github/workspace/JSONio"));
addpath(genpath("/github/workspace/tests/utils"));

Am I correct in my expectations?

Basic Matlab Functions Not Defined

Hi Jeorg,

I'm currently developing a MATLAB toolbox for importing mocap ASF and AMC files and would like to set up a really basic CI testing set using this awesome repo.

Issue

When running some really simple tests with this action, I'm getting the following error in one of my recent failed runs :

'split' undefined near line 215 column 51
LoadSkeleton>checkFileCorrect:215 (/tmp/oct-S1IzVd/LoadSkeleton.m)

FYI, in the LoadSkeleton.m file, I am simply converting a basic char array into a string under the following:

function checkFileCorrect(path)
   path = string(path);
% etc.

I should note too, this script runs perfectly in MATLAB and I have had this for other MATLAB functions like convertCharToStrings(...)

Question

I'm new to CI and deployment testing - Is this an issue with my action implementation , or is there something else going on?

Pre-test and post-test hooks

Per discussion on #20, would it be possible to have moxunit-action support a pre-test initialization hook, where one could point to an arbitrary pre-test file to run? (presumably some might also want a post-test hook)

This would then be more symmetric with the pattern suggested in MOxUnit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.