1- name : MATLAB Build
1+ name : MATLAB CI and Pages
22
3- # Controls when the action will run.
3+ # WORKFLOW OVERVIEW
4+ # ==================
5+ # This workflow implements a multi-release MATLAB testing and documentation pipeline.
6+ # It tests courseware code across multiple MATLAB releases in parallel, validates results,
7+ # generates a status badge, and deploys documentation to GitHub Pages.
8+ #
9+ # ARCHITECTURE:
10+ # Phase 1 - test-matrix (parallel): Run tests independently for each MATLAB release
11+ # Phase 2 - report-and-deploy (sequential): Merge artifacts, validate, generate badge, deploy
12+ #
13+ # KEY FILES:
14+ # - buildfile.m : Defines build tasks (testing, validation, badge generation)
15+ # - SoftwareTests/CoursewareSmokeTests.m : Tests core courseware scripts
16+ # - SoftwareTests/FunctionTests.m : Placeholder for development function tests
17+ # - SoftwareTests/CrossReleaseTestResults.m : Validates all releases passed (gate for badge)
18+ #
19+ # ARTIFACT FLOW:
20+ # 1. test-matrix job (runs for each MATLAB release R2025a, R2025b):
21+ # $ buildtool test
22+ # -> public/R2025a/CoursewareSmokeTests.mat, FunctionTests.mat, etc.
23+ # -> Upload artifacts: test-results-R2025a, test-results-R2025b
24+ #
25+ # 2. report-and-deploy job (runs once, after test-matrix completes):
26+ # $ Download and merge all test-results-* artifacts into public/
27+ # $ buildtool report (runs report:validate, report:badge, report:link tasks)
28+ # -> SoftwareTests/CrossReleaseTestResults.m validates all releases passed
29+ # -> createBadge() generates public/TestedWith.json (shields.io format)
30+ # -> linkResultArtifactPathsInReportIndex() wraps test result links in HTML
31+ # -> Deploy public/ to GitHub Pages
32+ #
33+ # CUSTOMIZATION:
34+ # To change tested MATLAB releases: Edit matrix.Releases list (line 29)
35+ # To add/remove products: Edit MATLAB_PRODUCTS env variable (line 28)
36+ # To change deploy trigger: Edit 'on' workflow events (lines 3-7)
37+ #
38+ # FOR YOUR OWN COURSEWARE:
39+ # 1. Copy buildfile.m and SoftwareTests/ structure to your repo
40+ # 2. Create SoftwareTests/CoursewareSmokeTests.m with your own test suite
41+ # (reference: https://www.mathworks.com/help/matlab/matlab_prog/write-simple-test-suite.html)
42+ # 3. Update .github/workflows/ci.yml with your product list and release matrix
43+ # 4. Push to your release branch and monitor GitHub Actions
44+ #
45+ # TROUBLESHOOTING:
46+ # If tests fail in CI but pass locally:
47+ # - Check version(-release) output matches your installed MATLAB
48+ # - Verify all dependencies (products) are listed in MATLAB_PRODUCTS
49+ # - Review public/index.html report for detailed test output
50+ # If badge generation fails:
51+ # - Ensure SoftwareTests/CrossReleaseTestResults.m can find all release artifacts
52+ # - Check public/CrossReleaseTestResults.mat for missing or empty result variables
53+
54+ # Controls when the action will run.
455on :
556 push :
657 branches : [ release ]
@@ -14,90 +65,105 @@ permissions:
1465 pages : write
1566 id-token : write
1667
68+ # Cancel older in-progress runs on the same ref to save CI time.
69+ concurrency :
70+ group : ${{ github.workflow }}-${{ github.ref }}
71+ cancel-in-progress : true
72+
1773jobs :
18- test :
19- strategy :
74+ test-matrix :
75+ name : Test on ${{ matrix.Releases }}
76+ strategy :
2077 fail-fast : false
2178 matrix :
22- MATLABVersion : [R2024b,R2025a, R2025b]
79+ Releases : [R2025b, R2026a ]
2380 runs-on : ubuntu-latest
2481 env :
82+ MATLAB_PRODUCTS : Symbolic_Math_Toolbox
2583 LD_PRELOAD : /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2684 steps :
2785 # Checks-out your repository
28- - uses : actions/checkout@v4
29-
86+ - uses : actions/checkout@v6
87+
3088 # Sets up a display server
3189 - name : Start display server
3290 if : ${{ always() }}
3391 run : |
34- sudo apt-get install xvfb
92+ sudo apt-get update
93+ sudo apt-get install -y xvfb
3594 Xvfb :99 &
3695 echo "DISPLAY=:99" >> $GITHUB_ENV
37-
96+
3897 # Sets up MATLAB
39- - name : Setup MATLAB
40- uses : matlab-actions/setup-matlab@v2
98+ - name : Setup MATLAB ${{ matrix.Releases }}
99+ uses : matlab-actions/setup-matlab@v3
41100 with :
42- release : ${{ matrix.MATLABVersion }}
43- products : >
44- Symbolic_Math_Toolbox
45- # Simulink Statistics_and_Machine_Learning_Toolbox
46- # List required products above in the format shown (and uncomment them)
47- # List of product strings:
48- # Simulink
49- # Statistics_and_Machine_Learning_Toolbox
50- # Simulink_Coder
51- # Econometrics_Toolbox
52- # Deep_Learning_Toolbox
53-
54-
55- # Run all the tests
56- - name : Run SmokeTests
57- uses : matlab-actions/run-command@v2
101+ release : ${{ matrix.Releases }}
102+ products : ${{ env.MATLAB_PRODUCTS }}
103+ cache : true
104+
105+ # Run aggregated test task from buildfile.m.
106+ - name : Run buildtool test
107+ uses : matlab-actions/run-build@v3
58108 with :
59- command : openProject(pwd); RunAllTests;
109+ tasks : test
110+ build-options : -continueOnFailure
60111
61- # Upload the test results as artifact
62- - name : Upload TestResults
112+ # Upload only files required by buildtool report/pages to reduce artifact size.
113+ - name : Upload test results artifact
63114 if : ${{ always() }}
64- uses : actions/upload-artifact@v4
115+ uses : actions/upload-artifact@v6
65116 with :
66- name : TestResults_${{ matrix.MATLABVersion }}
67- path : ./public/*
117+ name : ${{ matrix.Releases }}
118+ path : |
119+ ./public/${{ matrix.Releases }}/
68120 overwrite : true
121+ retention-days : 7
69122
70- badge :
123+ report-and-deploy :
124+ name : Build badge and deploy reports
71125 if : ${{ always() }}
72- needs : [test]
73- strategy :
74- fail-fast : false
126+ needs : [test-matrix]
75127 runs-on : ubuntu-latest
76- steps :
128+ steps :
77129
78130 # Checks-out your repository
79- - uses : actions/checkout@v4
80-
81- # Sets up R2023b
82- - name : Setup MATLAB
83- uses : matlab-actions/setup-matlab@v2
131+ - uses : actions/checkout@v6
132+
133+ # GitHub-hosted jobs are isolated; MATLAB install from test-matrix cannot be reused here.
134+ # Keep this setup minimal (no extra products) and use artifacts from matrix jobs.
135+
136+ # Sets latest MATLAB for report task (no toolbox list needed).
137+ - name : Setup MATLAB latest
138+ uses : matlab-actions/setup-matlab@v3
84139 with :
85- release : R2024b
86-
140+ release : latest
141+ cache : true
142+
87143 # Download the test results from artifact
88144 - name : Download All TestResults
89- uses : actions/download-artifact@v4
145+ uses : actions/download-artifact@v8
90146 with :
91147 path : public
92- pattern : TestResults_*
93- merge-multiple : true
94-
95- # Create the test results badge
96- - name : Run PostSmokeTest
97- uses : matlab-actions/run-command@v2
148+ pattern : R20*
149+ merge-multiple : false
150+
151+ # Aggregate test reports and generate badge via buildfile.
152+ - name : Run buildtool report
153+ uses : matlab-actions/run-build@v3
154+ with :
155+ tasks : report
156+ build-options : -continueOnFailure
157+
158+ # Upload the badge as artifact
159+ - name : Upload Badge
160+ if : ${{ always() }}
161+ uses : actions/upload-artifact@v6
98162 with :
99- command : openProject(pwd); PostSmokeTest;
100-
163+ name : Badge-Artifact
164+ path : ./public/TestedWith.json
165+ overwrite : true
166+
101167 # Deploy reports to GitHub pages
102168 - name : Setup Pages
103169 uses : actions/configure-pages@v5
@@ -108,15 +174,3 @@ jobs:
108174 - name : Deploy to GitHub Pages
109175 id : deployment
110176 uses : actions/deploy-pages@v4
111-
112- # Commit the JSON for the MATLAB releases badge
113- - name : Commit changed files
114- continue-on-error : true
115- run : |
116- git config user.name "${{ github.workflow }} by ${{ github.actor }}"
117- git config user.email "<>"
118- git pull
119- git add Images/TestedWith.json
120- git commit Images/TestedWith.json -m "Update CI badges ${{ github.ref_name }}"
121- git fetch
122- git push
0 commit comments