[3af7d7]: / .github / workflows / tests_talk2cells.yml

Download this file

125 lines (102 with data), 3.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# This is a basic workflow to help you get started with GitHub Actions
name: TESTS Talk2Cells
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events
pull_request:
branches: [ main ]
paths:
- 'aiagents4pharma/talk2cells/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# This workflow contains jobs covering linting and code coverage (along with testing).
jobs:
pylint-windows-ubuntu-macos:
# The type of runner that the job will run on
name: pylint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-13]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
# install requirements
- name: Install the requirements
run: |
pip3 install --break-system-packages -r requirements.txt
# pylint
- name: Run pylint
run: |
pylint --disable=R0801,R0902,W0221,W0122 aiagents4pharma/talk2cells
# code coverage job for ubuntu and macos
code-cov-ubuntu-macos:
name: code-coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: pip3 install -r requirements.txt # Adjust this according to your project
- name: Run tests with coverage
run: coverage run --include=aiagents4pharma/talk2cells/* -m pytest --cache-clear aiagents4pharma/talk2cells/tests/
- name: Check coverage
run: |
coverage report -m
TOTAL_COVERAGE=$(coverage report -m | awk 'END {print int($NF)}')
if [[ $TOTAL_COVERAGE -ne 100 ]]; then
echo "Code coverage is not 100%. Please check the coverage report."
exit 1
fi
env:
COVERAGE_FILE: './.coverage'
# code coverage job for windows
code-cov-windows:
name: code-coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: pip3 install -r requirements.txt # Adjust this according to your project
- name: Run tests with coverage
run: coverage run --include=aiagents4pharma/talk2cells/* -m pytest --cache-clear aiagents4pharma/talk2cells/tests/
- name: Check coverage
run: |
coverage report -m
# $TOTAL_COVERAGE=(& coverage report -m | Select-Object -Last 1) -replace "[^\d]" # Extract the last line and remove non-numeric characters
$TOTAL_COVERAGE=(& coverage report -m | Select-Object -Last 1)
# split and extract the last element
$TOTAL_COVERAGE=($TOTAL_COVERAGE -split " ")[-1]
# remove non-numeric characters
$TOTAL_COVERAGE=($TOTAL_COVERAGE -replace "[^\d]")
# convert to int
$TOTAL_COVERAGE=[int]$TOTAL_COVERAGE
echo "Total coverage: $TOTAL_COVERAGE"
if ($TOTAL_COVERAGE -ne 100) {
Write-Host "Code coverage is not 100%. Please check the coverage report."
exit 1
}
env:
COVERAGE_FILE: './.coverage'