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,107 +65,119 @@ 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 : >
83+ MATLAB
84+ Statistics_and_Machine_Learning_Toolbox
85+ System_Identification_Toolbox
86+ Image_Processing_Toolbox
2587 LD_PRELOAD : /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2688 steps :
2789 # Checks-out your repository
28- - uses : actions/checkout@v4
29-
90+ - uses : actions/checkout@v6
91+
3092 # Sets up a display server
3193 - name : Start display server
3294 if : ${{ always() }}
3395 run : |
34- sudo apt-get install xvfb
96+ sudo apt-get update
97+ sudo apt-get install -y xvfb
3598 Xvfb :99 &
3699 echo "DISPLAY=:99" >> $GITHUB_ENV
37-
100+
38101 # Sets up MATLAB
39- - name : Setup MATLAB
40- uses : matlab-actions/setup-matlab@v2
102+ - name : Setup MATLAB ${{ matrix.Releases }}
103+ uses : matlab-actions/setup-matlab@v3
41104 with :
42- release : ${{ matrix.MATLABVersion }}
43- products : MATLAB Statistics_and_Machine_Learning_Toolbox System_Identification_Toolbox
44- # List required products above in the format shown (and uncomment them)
45- # List of product strings:
46- # Simulink
47- # Statistics_and_Machine_Learning_Toolbox
48- # Simulink_Coder
49- # Econometrics_Toolbox
50- # Deep_Learning_Toolbox
51-
52-
53- # Run all the tests
54- - name : Run SmokeTests
55- uses : matlab-actions/run-command@v2
105+ release : ${{ matrix.Releases }}
106+ products : ${{ env.MATLAB_PRODUCTS }}
107+ cache : true
108+
109+ # Run aggregated test task from buildfile.m.
110+ - name : Run buildtool test
111+ uses : matlab-actions/run-build@v3
56112 with :
57- command : openProject(pwd); RunAllTests;
113+ tasks : test
114+ build-options : -continueOnFailure
58115
59- # Upload the test results as artifact
60- - name : Upload TestResults
116+ # Upload only files required by buildtool report/pages to reduce artifact size.
117+ - name : Upload test results artifact
61118 if : ${{ always() }}
62- uses : actions/upload-artifact@v4
119+ uses : actions/upload-artifact@v6
63120 with :
64- name : TestResults_${{ matrix.MATLABVersion }}
65- path : ./public/*
121+ name : ${{ matrix.Releases }}
122+ path : |
123+ ./public/${{ matrix.Releases }}/
66124 overwrite : true
125+ retention-days : 7
67126
68- badge :
127+ report-and-deploy :
128+ name : Build badge and deploy reports
69129 if : ${{ always() }}
70- needs : [test]
71- strategy :
72- fail-fast : false
130+ needs : [test-matrix]
73131 runs-on : ubuntu-latest
74- steps :
132+ steps :
75133
76134 # Checks-out your repository
77- - uses : actions/checkout@v4
78-
79- # Sets up R2023b
80- - name : Setup MATLAB
81- uses : matlab-actions/setup-matlab@v2
135+ - uses : actions/checkout@v6
136+
137+ # GitHub-hosted jobs are isolated; MATLAB install from test-matrix cannot be reused here.
138+ # Keep this setup minimal (no extra products) and use artifacts from matrix jobs.
139+
140+ # Sets latest MATLAB for report task (no toolbox list needed).
141+ - name : Setup MATLAB latest
142+ uses : matlab-actions/setup-matlab@v3
82143 with :
83- release : R2024b
84-
144+ release : latest
145+ cache : true
146+
85147 # Download the test results from artifact
86148 - name : Download All TestResults
87- uses : actions/download-artifact@v4
149+ uses : actions/download-artifact@v8
88150 with :
89151 path : public
90- pattern : TestResults_*
91- merge-multiple : true
92-
93- # Create the test results badge
94- - name : Run PostSmokeTest
95- uses : matlab-actions/run-command@v2
152+ pattern : R20*
153+ merge-multiple : false
154+
155+ # Aggregate test reports and generate badge via buildfile.
156+ - name : Run buildtool report
157+ uses : matlab-actions/run-build@v3
158+ with :
159+ tasks : report
160+ build-options : -continueOnFailure
161+
162+ # Upload the badge as artifact
163+ - name : Upload Badge
164+ if : ${{ always() }}
165+ uses : actions/upload-artifact@v6
96166 with :
97- command : openProject(pwd); PostSmokeTest;
98-
167+ name : Badge-Artifact
168+ path : ./public/TestedWith.json
169+ overwrite : true
170+
99171 # Deploy reports to GitHub pages
100172 - name : Setup Pages
173+ if : ${{ always() && github.event_name != 'pull_request' }}
101174 uses : actions/configure-pages@v5
102175 - name : Upload pages artifact
176+ if : ${{ always() && github.event_name != 'pull_request' }}
103177 uses : actions/upload-pages-artifact@v3
104178 with :
105179 path : public
106180 - name : Deploy to GitHub Pages
181+ if : ${{ always() && github.event_name != 'pull_request' }}
107182 id : deployment
108183 uses : actions/deploy-pages@v4
109-
110- # Commit the JSON for the MATLAB releases badge
111- - name : Commit changed files
112- continue-on-error : true
113- run : |
114- git config user.name "${{ github.workflow }} by ${{ github.actor }}"
115- git config user.email "<>"
116- git pull
117- git add Images/TestedWith.json
118- git commit Images/TestedWith.json -m "Update CI badges ${{ github.ref_name }}"
119- git fetch
120- git push
0 commit comments