Add cross-language symmetry tests for MATLAB ↔ Python DID databases #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cross-Language Symmetry Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| # Step 1: Run MATLAB makeArtifact tests to generate artifacts | |
| matlab-make-artifacts: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out DID-matlab | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: VH-Lab/DID-matlab | |
| path: DID-matlab | |
| - name: Set up MATLAB | |
| uses: matlab-actions/setup-matlab@v2 | |
| with: | |
| release: latest | |
| cache: true | |
| products: Statistics_and_Machine_Learning_Toolbox | |
| - name: Install MatBox | |
| uses: ehennestad/matbox-actions/install-matbox@v1 | |
| - name: Install dependencies (mksqlite etc.) | |
| uses: matlab-actions/run-command@v2 | |
| with: | |
| command: | | |
| addpath(genpath("DID-matlab/src")); | |
| addpath(genpath("DID-matlab/tools")); | |
| matbox.installRequirements(fullfile(pwd, "DID-matlab")); | |
| - name: Run MATLAB makeArtifact symmetry tests | |
| uses: matlab-actions/run-command@v2 | |
| with: | |
| command: | | |
| addpath(genpath("DID-matlab/src")); | |
| addpath(genpath("DID-matlab/tests")); | |
| addpath(genpath("DID-matlab/tools")); | |
| import matlab.unittest.TestRunner; | |
| import matlab.unittest.TestSuite; | |
| runner = TestRunner.withTextOutput; | |
| makeSuite = TestSuite.fromPackage("did.symmetry.makeArtifacts", "IncludingSubpackages", true); | |
| makeResults = runner.run(makeSuite); | |
| disp(table(makeResults)); | |
| assert(all([makeResults.Passed]), "makeArtifacts tests failed"); | |
| - name: Upload MATLAB artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: matlab-artifacts | |
| path: ${{ runner.temp }}/DID/symmetryTest/matlabArtifacts/ | |
| retention-days: 1 | |
| # Step 2: Run Python makeArtifact tests, then readArtifact tests (which read both Python + MATLAB artifacts) | |
| python-symmetry: | |
| runs-on: ubuntu-latest | |
| needs: matlab-make-artifacts | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.12"] | |
| steps: | |
| - name: Check out DID-python | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Download MATLAB artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: matlab-artifacts | |
| path: ${{ runner.temp }}/DID/symmetryTest/matlabArtifacts/ | |
| - name: Run Python makeArtifact tests | |
| run: pytest -m make_artifacts -v | |
| - name: Run Python readArtifact tests | |
| run: pytest -m read_artifacts -v | |
| - name: Upload Python artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-artifacts | |
| path: ${{ runner.temp }}/DID/symmetryTest/pythonArtifacts/ | |
| retention-days: 1 | |
| # Step 3: Run MATLAB readArtifact tests (reads Python-created artifacts) | |
| matlab-read-artifacts: | |
| runs-on: ubuntu-latest | |
| needs: python-symmetry | |
| steps: | |
| - name: Check out DID-matlab | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: VH-Lab/DID-matlab | |
| path: DID-matlab | |
| - name: Set up MATLAB | |
| uses: matlab-actions/setup-matlab@v2 | |
| with: | |
| release: latest | |
| cache: true | |
| products: Statistics_and_Machine_Learning_Toolbox | |
| - name: Install MatBox | |
| uses: ehennestad/matbox-actions/install-matbox@v1 | |
| - name: Install dependencies (mksqlite etc.) | |
| uses: matlab-actions/run-command@v2 | |
| with: | |
| command: | | |
| addpath(genpath("DID-matlab/src")); | |
| addpath(genpath("DID-matlab/tools")); | |
| matbox.installRequirements(fullfile(pwd, "DID-matlab")); | |
| - name: Download Python artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-artifacts | |
| path: ${{ runner.temp }}/DID/symmetryTest/pythonArtifacts/ | |
| - name: Download MATLAB artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: matlab-artifacts | |
| path: ${{ runner.temp }}/DID/symmetryTest/matlabArtifacts/ | |
| - name: Run MATLAB readArtifact symmetry tests | |
| uses: matlab-actions/run-command@v2 | |
| with: | |
| command: | | |
| addpath(genpath("DID-matlab/src")); | |
| addpath(genpath("DID-matlab/tests")); | |
| addpath(genpath("DID-matlab/tools")); | |
| import matlab.unittest.TestRunner; | |
| import matlab.unittest.TestSuite; | |
| runner = TestRunner.withTextOutput; | |
| readSuite = TestSuite.fromPackage("did.symmetry.readArtifacts", "IncludingSubpackages", true); | |
| readResults = runner.run(readSuite); | |
| disp(table(readResults)); | |
| nFailed = sum([readResults.Failed]); | |
| nPassed = sum([readResults.Passed]); | |
| nSkipped = sum([readResults.Incomplete]); | |
| fprintf("Results: %d passed, %d failed, %d skipped\n", nPassed, nFailed, nSkipped); | |
| assert(nFailed == 0, "readArtifacts tests failed"); |