-
Notifications
You must be signed in to change notification settings - Fork 2
136 lines (112 loc) · 3.82 KB
/
tests.yml
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
125
126
127
128
129
130
131
132
133
134
135
136
# This is a basic workflow to help you get started with GitHub Actions
name: TESTS
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events
pull_request:
branches: [ main, develop ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# This workflow contains 3 jobs called:
# 1. pytest-and-pylint-windows-ubuntu-macos
# 2. code-cov-ubuntu-macos
# 3. code-cov-windows
jobs:
pytest-and-pylint-windows-ubuntu-macos:
# The type of runner that the job will run on
name: pytest-and-pylint-windows-ubuntu-macos
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
# 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
shell: bash -l {0}
run: |
pip3 install --break-system-packages -r requirements.txt
# pytest
- name: Run pytest
shell: bash -l {0}
run: |
pytest --cache-clear agents
# pylint
- name: Run pylint
shell: bash -l {0}
run: |
pylint --disable=R0801,W0613,W0221,R0913,W0237,W0122 agents
# code coverage job for ubuntu and macos
code-cov-ubuntu-macos:
name: code-coverage-ubuntu-macos
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-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 -m pytest --cache-clear
continue-on-error: true
- 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-windows
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.x
- name: Install dependencies
run: pip3 install -r requirements.txt # Adjust this according to your project
- name: Run tests with coverage
run: coverage run -m pytest
continue-on-error: true
- 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'