Skip to content

Merge pull request #3 from Maxengw/ivo/forktomain #2

Merge pull request #3 from Maxengw/ivo/forktomain

Merge pull request #3 from Maxengw/ivo/forktomain #2

Workflow file for this run

name: Running tests
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
code-checks-and-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies from pyproject.toml
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Ruff Linting
run: |
pip install ruff==0.11.2
ruff check leakpro --exclude examples,leakpro/tests
- name: Install PDF compiling tool
run: |
sudo apt update ; sudo apt install -y texlive-latex-base
- name: Install pytest and pytest-cov
run: |
pip install pytest pytest-cov pytest-mock coverage-badge
- name: Run tests with pytest
run: |
pytest --cov=leakpro --cov-report=term-missing:skip-covered --cov-report=xml --cov-report=html leakpro/tests/
cat ./coverage.xml
- name: Check if running in a fork
id: check_fork
run: |
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]; then
echo "Skipping coverage badge generation because this is a forked PR."
echo "is_fork=true" >> $GITHUB_ENV
else
echo "is_fork=false" >> $GITHUB_ENV
fi
- name: Create Coverage Badge
if: env.is_fork == 'false'
run: |
mkdir -p badges
coverage-badge -o badges/coverage.svg -f
- name: Deploy Coverage Badge to GitHub Pages
if: env.is_fork == 'false'
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: badges