-
Notifications
You must be signed in to change notification settings - Fork 96
123 lines (116 loc) · 3.16 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
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: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Setup poetry
run: poetry install
- 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: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Setup poetry
run: poetry install
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: tests/apollo-server/
- name: Install deps and run server
run: |
cd tests/apollo-server/
npm ci
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
if: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Setup poetry
run: poetry install
- name: Run lint
if: always()
run: |
source .venv/bin/activate
isort -m 9 --line-length 160 $MODULE_NAME tests --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