test: read the instance library from a small library kept with the tests #633
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: Run tests | |
| on: | |
| # Triggers the workflow on push to any branch other than main or PR to main | |
| # This way tests will run on any push to a feature branch and when feature | |
| # branches are merged to main, but not repeated when PRs are actually merged. | |
| push: | |
| branches: [ "main" ] | |
| paths-ignore: | |
| - '*.md' | |
| - '.github/**' | |
| - '**/Contents.m' | |
| - '**/codemeta.json' | |
| pull_request: | |
| branches: [ "main" ] | |
| # Allows for manually running this workflow from the Actions tab | |
| workflow_dispatch: | |
| # Weekly full-model run, so the exhaustive round-trip sweep is exercised | |
| # even in weeks without a push to main | |
| schedule: | |
| - cron: '0 3 * * 1' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # This workflow contains a single job called "test" | |
| test: | |
| name: Test openMINDS_MATLAB (${{ matrix.MATLABVersion }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| MATLABVersion: [R2022a, R2026a] | |
| env: | |
| LatestMATLABVersion: R2026a | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it | |
| - name: Check out repo | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} | |
| - name: Set up MATLAB | |
| uses: matlab-actions/setup-matlab@v3 | |
| with: | |
| release: ${{ matrix.MATLABVersion }} | |
| # Check for MATLAB code issues in the project. | |
| - name: Check for MATLAB code issues | |
| if: matrix.MATLABVersion == env.LatestMATLABVersion | |
| uses: matlab-actions/run-command@v3 | |
| with: | |
| command: addpath(genpath("tools")); codecheckToolbox() | |
| # Upload code issues report | |
| - name: Upload SARIF file | |
| if: matrix.MATLABVersion == env.LatestMATLABVersion | |
| uses: github/codeql-action/upload-sarif@v3 | |
| with: | |
| # Path to SARIF file relative to the root of the repository | |
| sarif_file: docs/reports/code_issues.sarif | |
| # The interoperability test builds the same collection with the | |
| # Python reference implementation and compares the two exports. A | |
| # pull request runs against a pinned release, so it cannot go red | |
| # because of a change in the other repository. The weekly schedule | |
| # runs against main, so drift between the implementations is noticed. | |
| # | |
| # The package goes into a virtual environment made from the runner's | |
| # own Python, and the test calls that interpreter as a subprocess. | |
| # PATH is left alone on purpose: MATLAB resolves its in-process | |
| # Python (pyenv) from PATH, and the badge step depends on it. | |
| - name: Check out openMINDS_Python | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: openMetadataInitiative/openMINDS_Python | |
| ref: ${{ github.event_name == 'schedule' && 'main' || 'v0.6.0' }} | |
| path: openMINDS_Python | |
| - name: Install openMINDS_Python | |
| run: | | |
| python3 -m venv "${{ runner.temp }}/openminds-python" | |
| "${{ runner.temp }}/openminds-python/bin/python" -m pip install --quiet ./openMINDS_Python | |
| # Run all tests in the project. | |
| # The round-trip test covers every openMINDS type when | |
| # OPENMINDS_TEST_ALL_TYPES is set, which takes several minutes. Pull | |
| # requests run a representative sample instead. The full sweep runs | |
| # on push to main, which is where the openMINDS pipeline lands | |
| # regenerated type classes, and on the weekly schedule. | |
| - name: Run tests | |
| if: always() | |
| uses: matlab-actions/run-command@v3 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| OPENMINDS_TEST_ALL_TYPES: ${{ (github.event_name == 'pull_request') && '0' || '1' }} | |
| OPENMINDS_PYTHON: ${{ runner.temp }}/openminds-python/bin/python | |
| with: | |
| command: | | |
| addpath(genpath("tools")); | |
| doCreateBadge = "${{ matrix.MATLABVersion }}" == "${{ env.LatestMATLABVersion }}"; | |
| testToolbox("CreateBadge", doCreateBadge) | |
| # Commit updated SVG badges for the issues and tests (if changed). | |
| # Push events only, so badge commits land on main and nowhere else: | |
| # committing them on a pull_request event rewrites the PR head branch | |
| # and breaks any stack built on top of it. | |
| - name: Commit svg badges if updated | |
| if: matrix.MATLABVersion == env.LatestMATLABVersion && github.event_name == 'push' | |
| continue-on-error: true | |
| run: | | |
| git config user.name "${{ github.workflow }} by ${{ github.actor }}" | |
| git config user.email "${{ secrets.COMMIT_EMAIL_ADDRESS }}" | |
| git fetch | |
| if [[ $(git add .github/badges/* --dry-run | wc -l) -gt 0 ]]; then | |
| git add .github/badges/* | |
| git commit -m "Update code issues and tests badges" | |
| git push -f | |
| else | |
| echo "Nothing to commit" | |
| fi | |
| - name: Upload code coverage report to Codecov (https://app.codecov.io/gh/openMetadataInitiative/openMINDS_MATLAB) | |
| if: matrix.MATLABVersion == env.LatestMATLABVersion | |
| uses: codecov/codecov-action@v6 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: docs/reports/codecoverage.xml | |
| # Publish test results | |
| - name: Publish test results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| files: "docs/reports/test-results.xml" | |
| check_name: "Test Results (${{ matrix.MATLABVersion }})" | |
| # Save the contents of the reports directory as an artifact | |
| - name: Save reports directory | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: reports-${{ matrix.MATLABVersion }} | |
| path: docs/reports |