Merge pull request #2394 from farid-zare/CI #118
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 Code Coverage | ||
on: | ||
pull_request: | ||
branches: | ||
- '**' | ||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
steps: | ||
- name: Checkout PR Code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive # Ensures GitHub Actions checks out submodules properly | ||
- name: Initialize and Update Submodules | ||
run: | | ||
git submodule deinit --all --force # Remove broken submodules | ||
git submodule update --init --recursive --force | ||
git submodule sync --recursive | ||
- name: Merge PR with Develop | ||
run: | | ||
git fetch origin develop | ||
git checkout -b test-branch | ||
git merge origin/develop --allow-unrelated-histories --no-edit | ||
- name: Clone COBRA Toolbox | ||
run: | | ||
git clone https://github.com/opencobra/cobratoolbox.git cobratoolbox | ||
- name: Run MATLAB Tests | ||
run: | | ||
matlab -batch "run('cobratoolbox/initCobraToolbox.m'); diary('test_results.txt'); run('cobratoolbox/testAll.m'); diary off;" | ||
- name: Debug: Check If Coverage File Exists | ||
run: | | ||
ls -l $(pwd) | ||
find . -name "CodeCovTestResults.xml" | ||
- name: Upload Test Report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-report | ||
path: test_results.txt | ||
- name: Upload Coverage to Codecov | ||
if: always() # Ensure it runs even if tests fail | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ${{ github.workspace }}/CodeCovTestResults.xml | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
fail_ci_if_error: true | ||
flags: matlab | ||
comment: true | ||
- name: Upload Test Results to Codecov | ||
if: always() | ||
uses: codecov/test-results-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |