Changing workflow file and moving runTestAndGenerateReports.m to test folder #50
This file contains 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: MATLAB Tests and Coverage | |
on: | |
pull_request: | |
branches: | |
- '**' | |
jobs: # jobs | |
build: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Clone COBRA Toolbox | |
run: | | |
git clone https://github.com/opencobra/cobratoolbox.git cobratoolbox | |
- name: Run MATLAB tests and generate coverage | |
run: | | |
matlab -batch "run('cobratoolbox/initCobraToolbox.m'); diary('test_results.txt'); \ | |
coverageFile = fullfile('coverage', 'coverage.xml'); \ | |
mkdir('coverage'); \ | |
run('cobratoolbox/test/runTestAndGenerateReport.m'); \ | |
coverageResults = matlab.unittest.TestSuite.fromFile('cobratoolbox/test/testall_ghActions.m'); \ | |
results = run(coverageResults); \ | |
xmlwrite(coverageFile, results.generateCoverageReport('cobertura')); \ | |
diary off;" | |
- name: Upload Test Report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-report | |
path: test_results.txt | |
- name: Upload Coverage Report to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage/coverage.xml | |
flags: unittests | |
token: ${{ secrets.CODECOV_TOKEN }} # Add your Codecov token to the repo secrets |