diff --git a/.circleci/config.yml b/.circleci/config.yml index 92d6f93c..55e705df 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,15 +1,34 @@ version: 2.1 orbs: - matlab: mathworks/matlab@0 + matlab: mathworks/matlab@1 jobs: build: + environment: + MLM_LICENSE_TOKEN: kapilg@mathworks.com|test_token|AAARAYelzOx0ZtlcbAzLqfVklD1U/WR8wE6UNGVy+kwT+AUq8zWnWvSvchpfeU1s+Ryyj6Wi/fO/elTyIS994z7zbk/TiyNJ/amAZNVKZMQz8SWQplW2fj+fL9uRY7X2meObVT6LA0pzE4QGvKt9wmQKAIsNt1AlcRznzyk82E6bPdWiaw+fjwk + # MATHWORKS_ACCOUNT: kapilg@mathworks.com machine: image: ubuntu-2004:202201-02 steps: - - checkout + # - checkout - matlab/install - - matlab/run-tests: - source-folder: code + - run: + command: | + echo "$PATH" + # echo "$MATHWORKS_ACCOUNT" + matlab-batch pwd + # mkdir matlabCommandArtifacts + # echo '

HTML Links

HTML links are defined with the a tag:

This is a link' > matlabCommandArtifacts/myfile.html + # cd matlabCommandArtifacts + # ls + # cat myfile.html + # - store_artifacts: + # path: matlabCommandArtifacts/ + # - matlab/run-tests: + # source-folder: code + # select-by-folder: tests + # code-coverage-html: /matlabTestArtifacts/coverage + # - store_artifacts: + # path: /matlabTestArtifacts/coverage # As an alternative to run-tests, you can use run-command to execute a MATLAB script, function, or statement. # - matlab/run-command: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 1d12b0e2..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,41 +0,0 @@ -# This is a basic workflow to help you get started with MATLAB Actions - -name: MATLAB Build - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [ main ] - pull_request: - branches: [ main ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - # Sets up MATLAB on the GitHub Actions runner - - name: Setup MATLAB - uses: matlab-actions/setup-matlab@v1 - - # Runs a set of commands using the runners shell - - name: Run all tests - uses: matlab-actions/run-tests@v1 - with: - source-folder: code - - # As an alternative to run-tests, you can use run-command to execute a MATLAB script, function, or statement. - #- name: Run all tests - # uses: matlab-actions/run-command@v1 - # with: - # command: addpath('code'); results = runtests('IncludeSubfolders', true); assertSuccess(results); diff --git a/.github/workflows/templateSample1.yml b/.github/workflows/templateSample1.yml new file mode 100644 index 00000000..9ca51be1 --- /dev/null +++ b/.github/workflows/templateSample1.yml @@ -0,0 +1,55 @@ +# This is a basic workflow to help you get started with MATLAB Actions + +name: Build and test your MEX file + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ testing ] + pull_request: + branches: [ testing ] + workflow_dispatch: + +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Sets up MATLAB on the GitHub Actions runner + - name: Setup MATLAB + uses: matlab-actions/setup-matlab@v1 + + - name: Softwares + uses: matlab-actions/run-command@v1 + with: + command: ver + + - name: Build MEX file using buildtool + uses: matlab-actions/run-build@v1 + + - name: Run all tests and generate artifacts + uses: matlab-actions/run-tests@v1 + with: + source-folder: codeDesign + test-results-junit: test-results/results.xml + code-coverage-cobertura: code-coverage/coverage.xml + + - name: Upload test results artifact + uses: actions/upload-artifact@v2 + if: always() + with: + name: test-restuls + path: test-results/results.xml + + - name: Upload code coverage artifact + uses: actions/upload-artifact@v2 + if: always() + with: + name: code-coverage + path: code-coverage/coverage.xml diff --git a/.github/workflows/templateSample2.yml b/.github/workflows/templateSample2.yml new file mode 100644 index 00000000..e608b079 --- /dev/null +++ b/.github/workflows/templateSample2.yml @@ -0,0 +1,56 @@ +# This is a basic workflow to help you get started with MATLAB Actions + +name: Build and test + +# Controls when the action will run +on: + # Triggers the workflow on push or pull request events + push: + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + +jobs: + # This workflow contains a single job called "bat" + bat: + name: Build and test + + # The type of runner that the job will run on + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Set up MATLAB on the GitHub Actions runner + - name: Setup MATLAB + uses: matlab-actions/setup-matlab@v1 + + # Run the given tasks from the buildfile + - name: Execute buildplan + uses: matlab-actions/run-build@v1 + with: + tasks: clean check compile + + # Run all MATLAB tests and generate required artifacts + - name: Run tests and generate artifacts + uses: matlab-actions/run-tests@v1 + with: + source-folder: code + test-results-junit: test-results/results.xml + code-coverage-cobertura: code-coverage/coverage.xml + + # Upload generated artifacts to GitHub Actions + - name: Upload test results artifact + uses: actions/upload-artifact@v2 + if: always() + with: + name: test-results + path: test-results/results.xml + + - name: Upload code coverage artifact + uses: actions/upload-artifact@v2 + if: always() + with: + name: code-coverage + path: code-coverage/coverage.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index a280165a..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,7 +0,0 @@ -stages: - - test - -matlab-test-job: - stage: test - script: - - matlab -batch "addpath('code'); results = runtests('IncludeSubfolders', true); assertSuccess(results);" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b52b45db..00000000 --- a/.travis.yml +++ /dev/null @@ -1,2 +0,0 @@ -language: matlab -script: matlab -batch "addpath('code'); results = runtests('IncludeSubfolders', true); assertSuccess(results);" \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index e18f586b..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,15 +0,0 @@ -pipeline { - agent any - stages { - stage('Run MATLAB Tests') { - steps { - runMATLABTests( - sourceFolder: 'code' - ) - - // As an alternative to runMATLABTests, you can use runMATLABCommand to execute a MATLAB script, function, or statement. - // runMATLABCommand "addpath('code'); results = runtests('IncludeSubfolders', true); assertSuccess(results);" - } - } - } -} diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index cc5ed7e5..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,25 +0,0 @@ -pool: - vmImage: ubuntu-latest -steps: - - task: InstallMATLAB@0 - - task: RunMATLABTests@0 - inputs: - sourceFolder: code - codeCoverageCobertura: code-coverage/coverage.xml - testResultsJUnit: test-results/results.xml - - task: PublishTestResults@2 - condition: always() - inputs: - testResultsFormat: 'JUnit' - testResultsFiles: 'test-results/results.xml' - - task: PublishCodeCoverageResults@1 - condition: always() - inputs: - codeCoverageTool: 'Cobertura' - summaryFileLocation: 'code-coverage/coverage.xml' - pathToSources: 'code/' - - # As an alternative to RunMATLABTests, you can use RunMATLABCommand to execute a MATLAB script, function, or statement. - # - task: RunMATLABCommand@0 - # inputs: - # command: addpath('code'); results = runtests('IncludeSubfolders', true); assertSuccess(results); \ No newline at end of file diff --git a/buildfile.m b/buildfile.m new file mode 100644 index 00000000..d175178b --- /dev/null +++ b/buildfile.m @@ -0,0 +1,23 @@ +function plan = buildfile + % Create a plan from the task functions + plan = buildplan(localfunctions); + + % Make the "mex" task the default task in the plan + plan.DefaultTasks = "mex"; + +% % Make the "mex" task dependent on the "check" task +% plan("mex").Dependencies = ["check"]; +end + +function mexTask(~) + cd codeDesign + mex -setup C + mex arrayProduct.c +end + +% function checkTask(~) +% % Identify code issues +% issues = codeIssues; +% assert(isempty(issues.Issues),formattedDisplayText(issues.Issues)) +% end +% diff --git a/code/dayofyear.m b/code/dayofyear.m index 3d45872e..6f1073f5 100644 --- a/code/dayofyear.m +++ b/code/dayofyear.m @@ -51,4 +51,3 @@ end - diff --git a/codeSample/arrayProduct.c b/codeSample/arrayProduct.c new file mode 100644 index 00000000..d272bb51 --- /dev/null +++ b/codeSample/arrayProduct.c @@ -0,0 +1,88 @@ +/*========================================================== + * arrayProduct.c - example in MATLAB External Interfaces + * + * Multiplies an input scalar (multiplier) + * times a 1xN matrix (inMatrix) + * and outputs a 1xN matrix (outMatrix) + * + * The calling syntax is: + * + * outMatrix = arrayProduct(multiplier, inMatrix) + * + * This is a MEX-file for MATLAB. + * Copyright 2007-2012 The MathWorks, Inc. + * + *========================================================*/ + +#include "mex.h" + +/* The computational routine */ +void arrayProduct(double x, double *y, double *z, mwSize n) +{ + mwSize i; + /* multiply each element y by x */ + for (i=0; i