Add compareFluxes: ranked comparison of two flux distributions #351
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: Tests | |
| on: [pull_request] | |
| # Needed for the test-results comment and check run on the PR. | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| jobs: | |
| function-tests: | |
| name: Function tests | |
| runs-on: ubuntu-latest | |
| # Bound the run so a hanging test fails the job in minutes instead of | |
| # blocking the runner for hours. | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up MATLAB | |
| uses: matlab-actions/setup-matlab@v2 | |
| with: | |
| release: R2024b | |
| - name: Run function tests | |
| uses: matlab-actions/run-command@v2 | |
| env: | |
| # Batch licensing token for running MATLAB on a GitHub-hosted | |
| # runner. Request one from MathWorks and store it as the | |
| # MATLAB_BATCH_TOKEN repository secret. | |
| MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }} | |
| with: | |
| # The function tests use a "t*" naming convention that MATLAB's | |
| # folder-based discovery does not recognise, so the suite is built | |
| # from the explicit file list. RavenTestCase is the abstract base | |
| # class and must be excluded. Results are written as JUnit XML for | |
| # the reporting step below; the run itself does not fail the step so | |
| # that the report is always produced. | |
| command: | | |
| root = pwd; | |
| addpath(genpath(root)); | |
| resultsDir = fullfile(root, 'test-results'); | |
| if ~isfolder(resultsDir); mkdir(resultsDir); end | |
| import matlab.unittest.TestRunner | |
| import matlab.unittest.plugins.XMLPlugin | |
| cd(fullfile('testing', 'function_tests')); | |
| files = string({dir('*.m').name}); | |
| files(files == "RavenTestCase.m") = []; | |
| files(files == "tBinaries.m") = []; % run separately by the binary-tests job (Linux + macOS) | |
| suite = testsuite(cellstr(files)); | |
| % Detailed output prints "Running <class>/<test>" before each test | |
| % so that, if a test hangs on the runner, the last such line names | |
| % the culprit. | |
| runner = TestRunner.withTextOutput('OutputDetail', ... | |
| matlab.unittest.Verbosity.Detailed); | |
| runner.addPlugin(XMLPlugin.producingJUnitFormat( ... | |
| fullfile(resultsDir, 'results.xml'))); | |
| run(runner, suite); | |
| - name: Publish test results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| check_name: Function test results | |
| comment_mode: always | |
| files: test-results/results.xml | |
| # Fail the workflow (and the PR check) when any test fails or errors. | |
| action_fail: true | |
| binary-tests: | |
| name: Binary download (${{ matrix.os }}) | |
| # Validate the on-demand fetch of the external binaries from raven-data on | |
| # Linux and macOS. Running the downloaded binaries also confirms the macOS | |
| # Gatekeeper quarantine is cleared so they can execute. | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up MATLAB | |
| uses: matlab-actions/setup-matlab@v2 | |
| with: | |
| release: R2024b | |
| - name: Test on-demand binary download | |
| uses: matlab-actions/run-command@v2 | |
| env: | |
| MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }} | |
| with: | |
| command: | | |
| addpath(genpath(pwd)); | |
| results = runtests('tBinaries'); | |
| disp(table(results)); | |
| nFailed = nnz([results.Failed]); | |
| if nFailed > 0 | |
| error('%d binary download test(s) failed on %s', nFailed, computer('arch')); | |
| end |