{"id":19129902,"url":"https://github.com/mathworks/matlab-gitlab-ci-template","last_synced_at":"2025-07-03T19:33:30.596Z","repository":{"id":92436317,"uuid":"488235470","full_name":"mathworks/matlab-gitlab-ci-template","owner":"mathworks","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-30T13:21:48.000Z","size":15,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-03T11:09:31.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-03T14:08:35.000Z","updated_at":"2024-12-18T16:03:59.000Z","dependencies_parsed_at":"2023-03-13T17:29:05.646Z","dependency_job_id":"69928941-f746-4d2f-9d2c-05db9189800d","html_url":"https://github.com/mathworks/matlab-gitlab-ci-template","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"12d25e700242d778ce1c34733adcdf2bb275e4b9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fmatlab-gitlab-ci-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fmatlab-gitlab-ci-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fmatlab-gitlab-ci-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fmatlab-gitlab-ci-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks","download_url":"https://codeload.github.com/mathworks/matlab-gitlab-ci-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240206975,"owners_count":19765038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T06:08:58.349Z","updated_at":"2025-02-22T16:56:41.475Z","avatar_url":"https://github.com/mathworks.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Use MATLAB with GitLab CI/CD\nYou can use [GitLab\u0026trade; CI/CD](https://docs.gitlab.com/ee/ci/index.html) to build and test your MATLAB\u0026reg; project as part of your pipeline. For example, you can identify code issues in your project, run your tests and generate test and coverage artifacts, and package your files into a toolbox.\n\nThe `MATLAB.gitlab-ci.yml` [template](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/MATLAB.gitlab-ci.yml) provides you with jobs that show how to run MATLAB statements, tests, and builds. To run MATLAB code and Simulink\u0026reg; models based on this template, you must use the Docker\u0026reg; executor to run MATLAB within a container. You can use the [MATLAB Container on Docker Hub](https://www.mathworks.com/help/cloudcenter/ug/matlab-container-on-docker-hub.html) to run your build using MATLAB R2020b or a later release. Alternatively, you can create your own container for MATLAB and other MathWorks\u0026reg; products. For more information on how to create and use a custom MATLAB container, see [Create a MATLAB Container Image for Non-Interactive Workflows](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/alternates/non-interactive/README.md).\n\n\u003e**Note:** In addition to the Docker executor, GitLab Runner implements other types of executors that can be used to run your builds. See [Executors](https://docs.gitlab.com/runner/executors/) for more information.\n\n## MATLAB.gitlab-ci.yml Template\nYou can access the `MATLAB.gitlab-ci.yml` template when you create a `.gitlab-ci.yml` file in the UI.\n\n![template](https://user-images.githubusercontent.com/48831250/166474348-2e106005-23eb-4d62-a0ba-3387bbfcb20a.png)\n\nThe template includes four jobs:\n\n* `command` — Run MATLAB scripts, functions, and statements.                \n* `test` — Run tests authored using the MATLAB unit testing framework or Simulink Test\u0026trade;.\n* `test_artifacts` — Run MATLAB and Simulink tests, and generate test and coverage artifacts.\n* `build` — Run a build using the MATLAB build tool.\n\nThe jobs in the template use the `matlab -batch` syntax to start MATLAB. Additionally, they incorporate the contents of a hidden `.matlab_defaults` job. You need to configure this job before running the `command`, `test`, `test_artifacts`, and `build` jobs. To configure the job:\n\n* Specify the name of the MATLAB container image you want to use.\n* Set the `MLM_LICENSE_FILE` environment variable using the port number and DNS address for your network license manager.\n\n```yaml\n.matlab_defaults:\n  image:\n    name: mathworks/matlab:latest  # Replace the value with the name of the MATLAB container image you want to use\n    entrypoint: [\"\"]\n  variables:\n    MLM_LICENSE_FILE: 27000@MyLicenseServer  # Replace the value with the port number and DNS address for your network license manager\n\n```\n\n## Examples\nEach of these examples shows how to specify the contents of a job in your `.gitlab-ci.yml` file.\n\n### Run a Script\nRun the commands in a file named `myscript.m` in the root of your repository.\n\n```yaml\ncommand:\n   extends: .matlab_defaults\n   script: matlab -batch \"myscript\"\n```\n### Run Tests\nRun the tests in your [MATLAB project](https://www.mathworks.com/help/matlab/projects.html) and fail the build if any of the tests fail.\n\n```yaml\ntest:\n  extends: .matlab_defaults\n  script: matlab -batch \"results = runtests('IncludeSubfolders',true), assertSuccess(results);\"\n```\n### Run Tests and Generate Artifacts\nRun the tests in your MATLAB project, and produce test results in JUnit-style XML format and code coverage results in Cobertura XML format. Fail the build if any of the tests fail.\n\n```yaml\ntest_artifacts:\n  extends: .matlab_defaults\n  script: |\n    cat \u003c\u003c- 'BLOCK' \u003e runAllTests.m\n          import matlab.unittest.TestRunner\n          import matlab.unittest.Verbosity\n          import matlab.unittest.plugins.CodeCoveragePlugin\n          import matlab.unittest.plugins.XMLPlugin\n          import matlab.unittest.plugins.codecoverage.CoberturaFormat\n          suite = testsuite(pwd,'IncludeSubfolders',true);\n          [~,~] = mkdir('artifacts')\n          runner = TestRunner.withTextOutput('OutputDetail',Verbosity.Detailed);\n          runner.addPlugin(XMLPlugin.producingJUnitFormat('artifacts/results.xml'))\n          % Replace `pwd` with the location of the folder containing source code\n          runner.addPlugin(CodeCoveragePlugin.forFolder(pwd,'IncludingSubfolders',true, ...\n          'Producing',CoberturaFormat('artifacts/cobertura.xml')))\n          results = runner.run(suite)\n          assertSuccess(results);\n    BLOCK\n    matlab -batch runAllTests\nartifacts:\n    reports:\n      junit: \"./artifacts/results.xml\"\n      coverage_report:\n        coverage_format: cobertura\n        path: \"./artifacts/cobertura.xml\"\n    paths:\n      - \"./artifacts\"\n```\n\n### Run MATLAB Build\nUse the [MATLAB build tool](https://www.mathworks.com/help/matlab/matlab_prog/overview-of-matlab-build-tool.html) to run the default tasks in a file named `buildfile.m` located in the root of your repository, as well as all the tasks on which they depend. \n\n```yaml\nbuild:\n   extends: .matlab_defaults\n   script: matlab -batch \"buildtool\"\n```\n\n## See Also\n- [Continuous Integration with MATLAB and Simulink](https://www.mathworks.com/solutions/continuous-integration.html)\n- [Continuous Integration for Verification of Simulink Models Using GitLab](https://www.mathworks.com/company/newsletters/articles/continuous-integration-for-verification-of-simulink-models-using-gitlab.html)\n\n## Contact Us\nIf you have any questions or suggestions, please contact MathWorks\u0026reg; at [continuous-integration@mathworks.com](mailto:continuous-integration@mathworks.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fmatlab-gitlab-ci-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks%2Fmatlab-gitlab-ci-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fmatlab-gitlab-ci-template/lists"}