Skip to content

Build triggered by workflow dispatch #109

Build triggered by workflow dispatch

Build triggered by workflow dispatch #109

Workflow file for this run

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:
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: [R2021b, R2024b]
env:
LatestMATLABVersion: R2024b
# 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@v4
with:
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
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@v2
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
# Run all tests in the project.
- name: Run tests
if: always()
uses: matlab-actions/run-command@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
command: |
doCreateBadge = "${{ matrix.MATLABVersion }}" == "${{ env.LatestMATLABVersion }}";
addpath(genpath("tools")); testToolbox("CreateBadge", doCreateBadge)
# Commit updated SVG badges for the issues and tests (if changed)
- name: Commit svg badges if updated
if: matrix.MATLABVersion == env.LatestMATLABVersion
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@v4
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@v4
if: always()
with:
name: reports-${{ matrix.MATLABVersion }}
path: docs/reports