Add dataset symmetry tests for artifact generation and verification #152
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install linting tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff black | |
| - name: Check formatting with black | |
| run: black --check src/ tests/ | |
| - name: Lint with ruff | |
| run: ruff check src/ tests/ | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install with ndi_install.py | |
| run: | | |
| python -m pip install --upgrade pip | |
| python ndi_install.py --dev --no-validate --verbose | |
| - name: Validate installation | |
| run: python -m ndi check | |
| - name: Run tests with coverage | |
| run: | | |
| # Use sys.monitoring (PEP 669) on Python 3.12+ for faster coverage. | |
| # CTracer (sys.settrace) is catastrophically slow on 3.12 when | |
| # importing large packages like openminds (~6 min vs ~2 sec). | |
| COVERAGE_CORE=$(python -c "import sys; print('sysmon' if sys.version_info >= (3,12) else 'ctrace')") | |
| export COVERAGE_CORE | |
| pytest tests/ -v --tb=short --cov=src/ndi --cov-report=term-missing | |
| symmetry: | |
| name: MATLAB <-> Python symmetry tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out NDI-python | |
| uses: actions/checkout@v4 | |
| - name: Check out NDI-matlab | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: VH-Lab/NDI-matlab | |
| path: NDI-matlab | |
| # --- MATLAB setup --- | |
| - name: Start virtual display server | |
| run: | | |
| sudo apt-get install -y xvfb | |
| Xvfb :99 & | |
| echo "DISPLAY=:99" >> $GITHUB_ENV | |
| - name: Set up MATLAB | |
| uses: matlab-actions/setup-matlab@v2 | |
| with: | |
| release: latest | |
| cache: true | |
| products: | | |
| Communications_Toolbox | |
| Statistics_and_Machine_Learning_Toolbox | |
| Signal_Processing_Toolbox | |
| - name: Install MatBox | |
| uses: ehennestad/matbox-actions/install-matbox@v1 | |
| - name: Install MATLAB dependencies | |
| uses: matlab-actions/run-command@v2 | |
| with: | |
| command: | | |
| addpath(genpath("NDI-matlab/src")); | |
| addpath(genpath("NDI-matlab/tests")); | |
| addpath(genpath("NDI-matlab/tools")); | |
| matbox.installRequirements(fullfile(pwd, "NDI-matlab")); | |
| # --- Python setup --- | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install NDI-python | |
| run: | | |
| python -m pip install --upgrade pip | |
| python ndi_install.py --dev --no-validate --verbose | |
| # --- Step 1: MATLAB makeArtifacts --- | |
| - name: "Step 1: MATLAB makeArtifact tests" | |
| uses: matlab-actions/run-command@v2 | |
| with: | |
| command: | | |
| addpath(genpath("NDI-matlab/src")); | |
| addpath(genpath("NDI-matlab/tests")); | |
| addpath(genpath("NDI-matlab/tools")); | |
| matbox.installRequirements(fullfile(pwd, "NDI-matlab")); | |
| import matlab.unittest.TestRunner; | |
| import matlab.unittest.TestSuite; | |
| runner = TestRunner.withTextOutput("Verbosity", "Detailed"); | |
| makeSuite = TestSuite.fromPackage("ndi.symmetry.makeArtifacts", "IncludingSubpackages", true); | |
| fprintf("\n=== Discovered %d MATLAB makeArtifact test(s) ===\n", numel(makeSuite)); | |
| makeResults = runner.run(makeSuite); | |
| fprintf("\n=== makeArtifacts: %d passed, %d failed ===\n", ... | |
| nnz([makeResults.Passed]), nnz([makeResults.Failed])); | |
| disp(table(makeResults)); | |
| assert(all([makeResults.Passed]), "MATLAB makeArtifacts tests failed"); | |
| # --- Step 2: Python makeArtifacts + readArtifacts --- | |
| - name: "Step 2: Python makeArtifact tests" | |
| run: pytest tests/symmetry/make_artifacts/ -v --tb=short | |
| - name: "Step 2: Python readArtifact tests" | |
| run: pytest tests/symmetry/read_artifacts/ -v --tb=short | |
| # --- Step 3: MATLAB readArtifacts --- | |
| - name: "Step 3: MATLAB readArtifact tests" | |
| uses: matlab-actions/run-command@v2 | |
| with: | |
| command: | | |
| addpath(genpath("NDI-matlab/src")); | |
| addpath(genpath("NDI-matlab/tests")); | |
| addpath(genpath("NDI-matlab/tools")); | |
| matbox.installRequirements(fullfile(pwd, "NDI-matlab")); | |
| import matlab.unittest.TestRunner; | |
| import matlab.unittest.TestSuite; | |
| runner = TestRunner.withTextOutput("Verbosity", "Detailed"); | |
| readSuite = TestSuite.fromPackage("ndi.symmetry.readArtifacts", "IncludingSubpackages", true); | |
| fprintf("\n=== Discovered %d MATLAB readArtifact test(s) ===\n", numel(readSuite)); | |
| readResults = runner.run(readSuite); | |
| nFailed = sum([readResults.Failed]); | |
| nPassed = sum([readResults.Passed]); | |
| nSkipped = sum([readResults.Incomplete]); | |
| fprintf("\n=== readArtifacts: %d passed, %d failed, %d skipped ===\n", nPassed, nFailed, nSkipped); | |
| disp(table(readResults)); | |
| assert(nFailed == 0, "MATLAB readArtifacts tests failed"); |