Skip to content

Tests

Tests #227

Workflow file for this run

name: Tests
on:
# Allow to manually trigger through github API
workflow_dispatch:
# Triggers with push to master
push:
branches:
- master
# Triggers with push to a pr aimed at master
pull_request:
branches:
- master
schedule:
# https://crontab.guru/#42_2_3_*_*
# "At 02:42 on day-of-month 3"
# Put it at this odd time to reduce competing with load spikes on github action servers
- cron: '42 2 3 * *'
env:
import-package-name: grakel
extra-requires: "[dev]" # "" for no extra_requires
extra-requires-soft: "[test]" # "" for no extra_requires
test-dir: grakel/tests
# https://github.com/eddiebergman/GraKeL/blob/63a2723fc9488257a7c880fa9b5e5cc95ada9f42/ci_scripts/travis/install.sh#L8-L11
coverage-reqs: "networkx pandas"
codecov-py: "3.7"
codecov-args: >-
--cov=grakel
--cov-report=xml
jobs:
# General unit tests
source-test:
name: ${{ matrix.py }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash # Default to using bash on all
strategy:
fail-fast: false
matrix:
py: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
- name: Install ${{ env.import-package-name }}
run: |
python -m pip install --upgrade pip setuptools wheel
# escape for cvxopt
if ( [[ "${{ matrix.os }}" == "windows-latest" ]] && [[ "${{ matrix.py }}" == "3.7" ]] ) || [[ "${{ matrix.py }}" == "3.12" ]];then
python -m pip install -e ".${{ env.extra-requires-soft }}"
else
python -m pip install -e ".${{ env.extra-requires }}"
fi
- name: Tests
run: |
python -m pytest # ${{ env.test-dir }}
# Testing with codecov coverage uploaded
codecov-test:
name: codecov-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.codecov-py }}
- name: Install ${{ env.import-package-name }}
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -e ".${{ env.extra-requires }}"
- name: Tests
run: |
python -m pytest ${{ env.codecov-args }} ${{ env.test-dir }}
- name: Upload coverage
uses: codecov/codecov-action@v3
# Only upload coverage when it's **not** a scheduled test run
if: ${{ ! github.event.schedule }}
with:
fail_ci_if_error: true
verbose: true