|
| 1 | +name: Test Cross-Language Symmetry |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + symmetry: |
| 16 | + name: MATLAB ↔ Python symmetry tests |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + # ── Checkout both repos ──────────────────────────────────────────── |
| 21 | + - name: Check out NDI-python |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + path: NDI-python |
| 25 | + |
| 26 | + - name: Check out NDI-matlab |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + repository: VH-Lab/NDI-matlab |
| 30 | + path: NDI-matlab |
| 31 | + |
| 32 | + # ── Runtime setup ────────────────────────────────────────────────── |
| 33 | + - name: Start virtual display server |
| 34 | + run: | |
| 35 | + sudo apt-get install -y xvfb |
| 36 | + Xvfb :99 & |
| 37 | + echo "DISPLAY=:99" >> $GITHUB_ENV |
| 38 | +
|
| 39 | + - name: Set up MATLAB |
| 40 | + uses: matlab-actions/setup-matlab@v2 |
| 41 | + with: |
| 42 | + release: latest |
| 43 | + cache: true |
| 44 | + products: | |
| 45 | + Communications_Toolbox |
| 46 | + Statistics_and_Machine_Learning_Toolbox |
| 47 | + Signal_Processing_Toolbox |
| 48 | +
|
| 49 | + - name: Install MatBox |
| 50 | + uses: ehennestad/matbox-actions/install-matbox@v1 |
| 51 | + |
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v5 |
| 54 | + with: |
| 55 | + python-version: "3.12" |
| 56 | + |
| 57 | + - name: Install NDI-python |
| 58 | + working-directory: NDI-python |
| 59 | + run: | |
| 60 | + python -m pip install --upgrade pip |
| 61 | + python ndi_install.py --dev --no-validate --verbose |
| 62 | +
|
| 63 | + # ── Stage 1: MATLAB makeArtifacts ────────────────────────────────── |
| 64 | + - name: "Stage 1: MATLAB makeArtifacts" |
| 65 | + uses: matlab-actions/run-command@v2 |
| 66 | + with: |
| 67 | + command: | |
| 68 | + cd("NDI-matlab"); |
| 69 | + addpath(genpath("src")); |
| 70 | + addpath(genpath("tests")); |
| 71 | + addpath(genpath("tools")); |
| 72 | + matbox.installRequirements(fullfile(pwd, "tests")); |
| 73 | +
|
| 74 | + import matlab.unittest.TestSuite |
| 75 | + import matlab.unittest.TestRunner |
| 76 | +
|
| 77 | + suite = TestSuite.fromPackage("ndi.symmetry.makeArtifacts", "IncludingSubpackages", true); |
| 78 | + fprintf("\n=== MATLAB makeArtifacts: %d test(s) ===\n", numel(suite)); |
| 79 | + assert(~isempty(suite), "No MATLAB makeArtifacts tests found.") |
| 80 | +
|
| 81 | + runner = TestRunner.withTextOutput("Verbosity", "Detailed"); |
| 82 | + results = runner.run(suite); |
| 83 | +
|
| 84 | + fprintf("\n=== MATLAB makeArtifacts: %d passed, %d failed ===\n", ... |
| 85 | + nnz([results.Passed]), nnz([results.Failed])); |
| 86 | + assert(all(~[results.Failed]), "MATLAB makeArtifacts failed") |
| 87 | +
|
| 88 | + # ── Stage 2: Python makeArtifacts + readArtifacts ────────────────── |
| 89 | + - name: "Stage 2: Python symmetry tests (make + read)" |
| 90 | + working-directory: NDI-python |
| 91 | + run: | |
| 92 | + echo "=== Running Python makeArtifacts ===" |
| 93 | + pytest tests/symmetry/make_artifacts/ -v --tb=short |
| 94 | +
|
| 95 | + echo "" |
| 96 | + echo "=== Running Python readArtifacts (reads both MATLAB and Python artifacts) ===" |
| 97 | + pytest tests/symmetry/read_artifacts/ -v --tb=short |
| 98 | +
|
| 99 | + # ── Stage 3: MATLAB readArtifacts ────────────────────────────────── |
| 100 | + - name: "Stage 3: MATLAB readArtifacts (reads Python artifacts)" |
| 101 | + uses: matlab-actions/run-command@v2 |
| 102 | + with: |
| 103 | + command: | |
| 104 | + cd("NDI-matlab"); |
| 105 | + addpath(genpath("src")); |
| 106 | + addpath(genpath("tests")); |
| 107 | + addpath(genpath("tools")); |
| 108 | + matbox.installRequirements(fullfile(pwd, "tests")); |
| 109 | +
|
| 110 | + import matlab.unittest.TestSuite |
| 111 | + import matlab.unittest.TestRunner |
| 112 | +
|
| 113 | + suite = TestSuite.fromPackage("ndi.symmetry.readArtifacts", "IncludingSubpackages", true); |
| 114 | + fprintf("\n=== MATLAB readArtifacts: %d test(s) ===\n", numel(suite)); |
| 115 | + assert(~isempty(suite), "No MATLAB readArtifacts tests found.") |
| 116 | +
|
| 117 | + runner = TestRunner.withTextOutput("Verbosity", "Detailed"); |
| 118 | + results = runner.run(suite); |
| 119 | +
|
| 120 | + fprintf("\n=== MATLAB readArtifacts: %d passed, %d failed ===\n", ... |
| 121 | + nnz([results.Passed]), nnz([results.Failed])); |
| 122 | + assert(all(~[results.Failed]), "MATLAB readArtifacts failed") |
0 commit comments