Skip to content

Commit 27508ad

Browse files
committed
refactor: Modernize build system
1 parent 15cf94a commit 27508ad

58 files changed

Lines changed: 734 additions & 532 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 120 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,57 @@
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.
455
on:
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+
1773
jobs:
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

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ codegen/
4747
# Project settings
4848
Utilities/ProjectSettings.mat
4949

50-
# Test results
51-
SoftwareTests/TestResults_*
52-
53-
# GitLab page fodler
50+
# Testing and CI related artifact
5451
public/
52+
.buildtool/
53+
ci_utilities/

.gitlab-ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
stages:
2+
# Set up two testing paths
3+
- test
4+
- deploy
5+
- release
6+
7+
test-matrix:
8+
parallel:
9+
matrix:
10+
- VERSION: [R2025b,R2026a]
11+
tags:
12+
- training
13+
- windows
14+
stage: test
15+
script:
16+
- Set-Alias -Name matlab -Value "D:\MATLAB\$VERSION\bin\matlab-batch"
17+
- matlab "openProject(pwd); buildtool -continueOnFailure"
18+
when: always
19+
allow_failure: true
20+
artifacts:
21+
name: "$VERSION"
22+
paths:
23+
- public/$VERSION/*
24+
when: always
25+
26+
pages:
27+
needs:
28+
- test-matrix
29+
variables:
30+
VERSION: "R2026a"
31+
tags:
32+
- training
33+
- windows
34+
stage: deploy
35+
script:
36+
- Set-Alias -Name matlab -Value "D:\MATLAB\$VERSION\bin\matlab-batch"
37+
- matlab "openProject(pwd); buildtool report -continueOnFailure"
38+
when: always
39+
allow_failure: true
40+
artifacts:
41+
paths:
42+
- public
43+
44+
file-test:
45+
variables:
46+
VERSION: "R2026a"
47+
tags:
48+
- training
49+
- windows
50+
stage: release
51+
script:
52+
- Set-Alias -Name matlab -Value "D:\MATLAB\$VERSION\bin\matlab-batch"
53+
- git clone https://insidelabs-git.mathworks.com/modular-curriculum-content/utilities.git ci_utilities
54+
- matlab "openProject(pwd); addpath(genpath(ci_utilities)); buildtool -buildFile ci-utilities\buildfile.m"
55+
rules:
56+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
57+
when: always
58+
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
59+
when: manual
60+
allow_failure: true

Images/TestedWith.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[![Ver en File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/173655-calculo-integrales) or [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Calculus-Integrals_es&project=Integrals.prj)
55

6-
![Versiones de MATLAB Probadas](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FMathWorks-Teaching-Resources%2FCalculus-Integrals_es%2Frelease%2FImages%2FTestedWith.json)
6+
![Versiones de MATLAB Probadas](https://img.shields.io/endpoint?url=https://mathworks-teaching-resources.github.io/Calculus-Integrals_es/TestedWith.json)](https://MathWorks-Teaching-Resources.github.io/Calculus-Integrals_es)
77

88
**Módulo Curricular**
99

SoftwareTests/CheckTestResults.m

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)