Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update codecov.yml #2401

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,55 @@ jobs:
runs-on: self-hosted
steps:
- name: Checkout PR Code
uses: actions/checkout@v4 # Fetches the PR branch
uses: actions/checkout@v4

- name: Rebase PR Branch on Top of Develop
- name: Connect to King Server & Setup Rebase
run: |
git fetch origin develop # Fetch latest develop
if [[ "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
# PR is from the same repo
git fetch origin ${{ github.event.pull_request.head.ref }}
git checkout ${{ github.event.pull_request.head.ref }}
else
# PR is from a forked repo
git remote add pr_repo ${{ github.event.pull_request.head.repo.clone_url }}
git fetch pr_repo ${{ github.event.pull_request.head.ref }}
git checkout -b test-rebase FETCH_HEAD
ssh saleh@king << 'EOF'
# Navigate to home directory
cd ~

# Clone or update COBRA Toolbox
if [ ! -d "cobratoolbox" ]; then
git clone https://github.com/opencobra/cobratoolbox.git
fi
git rebase origin/develop
git push origin +HEAD:test-rebase --force # Push rebased branch
cd cobratoolbox

- name: Clone Rebased Branch on King Server
run: |
ssh saleh@king "rm -rf cobratoolbox && git clone -b test-rebase https://github.com/opencobra/cobratoolbox.git cobratoolbox"
# Ensure develop is up-to-date
git fetch origin develop
git checkout develop
git reset --hard origin/develop

- name: Run MATLAB Tests on King Server
run: |
ssh saleh@king "matlab -batch \"run('cobratoolbox/initCobraToolbox.m'); diary('test_results.txt'); run('cobratoolbox/test/testAll.m'); diary off;\""
# Fetch and rebase the PR branch
git fetch origin ${{ github.event.pull_request.head.ref }}
git checkout -b pr-rebase FETCH_HEAD
git rebase develop

- name: Retrieve Test Results from Server
run: |
scp saleh@king:cobratoolbox/test_results.txt .
# If rebase fails, abort and exit
if [ $? -ne 0 ]; then
git rebase --abort
exit 1
fi

# Run MATLAB tests
matlab -batch "run('cobratoolbox/initCobraToolbox.m'); diary('test_results.txt'); run('cobratoolbox/test/testAll.m'); diary off;"

# Exit SSH session
exit
EOF

- name: Upload Test Report
uses: actions/upload-artifact@v4
with:
name: test-report
path: test_results.txt
path: ~/cobratoolbox/test_results.txt

- name: Upload Coverage to Codecov
if: always()
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/CodeCovTestResults.xml
files: ~/cobratoolbox/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 }}

- name: Cleanup Temporary Rebased Branch
if: always()
run: |
git push origin --delete test-rebase || true # Delete the test-rebase branch after tests
Loading