-
Notifications
You must be signed in to change notification settings - Fork 97
115 lines (98 loc) · 2.87 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
name: tests
on:
push:
paths-ignore:
- "README.md"
- "LICENSE"
- ".gitignore"
branches:
- main
pull_request:
paths-ignore:
- "README.md"
- "LICENSE"
- ".gitignore"
branches:
- main
env:
PYTHON_VERSION: "3.10"
NODE_VERSION: "20"
MODULE_NAME: clairvoyance
MIN_TEST_COV: 0
SERVER: http://localhost:4000
permissions:
contents: read
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ env.PYTHON_VERSION }} and resolve Poetry dependencies
uses: Privat33r-dev/pymonster@master
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Run tests
run: |
source .venv/bin/activate
pytest --cov=$MODULE_NAME --cov-report=xml --cov-fail-under=$MIN_TEST_COV tests
system-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ env.PYTHON_VERSION }} and resolve Poetry dependencies
uses: Privat33r-dev/pymonster@master
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: pnpm/action-setup@v3
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
cache-dependency-path: tests/apollo-server/
- name: Install deps and run server
run: |
cd tests/apollo-server/
pnpm install
node src/index.js &
- name: Wait for server
run: |
for i in {0..10}; do
echo "Sleep for 1 second ..."
sleep 1
if curl -s -o /dev/null "$SERVER"; then
echo "$SERVER returned HTTP response!"
break
fi
if [ $i -eq 10 ]; then
echo "Server did not respond after 10 seconds!"
exit 1
fi
done
- name: Test with pytest
run: |
source .venv/bin/activate
python -m unittest tests/system.py
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ env.PYTHON_VERSION }} and resolve Poetry dependencies
uses: Privat33r-dev/pymonster@master
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Run lint
# A few checks are skipped for now because the code can't pass them
# TODO: reactivate them
run: |
source .venv/bin/activate
isort -m 9 --line-length 160 $MODULE_NAME tests --gitignore --check-only
# pylint $MODULE_NAME tests
docformatter --wrap-summaries 160 --wrap-descriptions 160 -cr $MODULE_NAME tests
black --check $MODULE_NAME tests
mypy -V
# mypy $MODULE_NAME tests