GitHub actions are an amazing tool to automate different stages on in the software development workflow, and they can be used in Matlab projects!
By using Matlab GitHub actions, it is possible to set up Matlab, and run Matlab code on GitHub-hosted runners with different OS (Linux, macOS and Windows). This allows painless testing of your code on different Matlab versions on different OS.
Toy example
A working toy example of using Matlab with GitHub actions can be found here. The repo consists of two main parts: a yaml file and a Matlab script:
1. yaml file
The yaml file ./github/workflows/github-actions.yaml
defines:
- When the GitHub action will run
- The OS versions: Linux (Ubuntu 20.04), macOS (12 Monterey) and Windows (Server 2019) for the runners
- The Matlab version (R2021b) that will be used
- The Matlab script (
wonder_script.m
) in the repo to be executed - Other task (display results)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
2. Matlab script
The wonder_script.m
Matlab script gets information of the computer where the code is running and writes such information on a text file
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
Comments
comments powered by Disqus