-
-
Notifications
You must be signed in to change notification settings - Fork 9
117 lines (113 loc) · 3.98 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
name: tests
on:
push:
branches: main
pull_request:
branches: main
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.3.0"
- name: Resolve dependencies
run: |
poetry export -f requirements.txt --without-hashes --output src/app/requirements.txt
poetry export -f requirements.txt --without-hashes --with dev --output src/requirements-dev.txt
- name: Build & run docker
env:
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
BUCKET_MEDIA_FOLDER: ${{ secrets.BUCKET_MEDIA_FOLDER }}
S3_ENDPOINT_URL: ${{ secrets.S3_ENDPOINT_URL }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
S3_REGION: ${{ secrets.S3_REGION }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_TEST_CHAT_ID: ${{ secrets.TELEGRAM_TEST_CHAT_ID }}
run: |
docker build src/. -t pyroapi:python3.8-alpine3.10
docker-compose -f docker-compose-dev.yml up -d --build
- name: Run docker test
run: |
docker-compose -f docker-compose-dev.yml exec -T backend coverage --version
docker-compose -f docker-compose-dev.yml exec -T backend coverage run -m pytest tests/
docker-compose -f docker-compose-dev.yml exec -T backend coverage xml -o coverage-src.xml
docker cp pyro-api_backend_1:/app/coverage-src.xml .
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage-src.xml
flags: unittests
fail_ci_if_error: true
pytest-client:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: [3.8]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.3.0"
- name: Resolve dependencies
run: poetry export -f requirements.txt --without-hashes --output src/app/requirements.txt
- name: Build & run API server
env:
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
BUCKET_MEDIA_FOLDER: ${{ secrets.BUCKET_MEDIA_FOLDER }}
S3_ENDPOINT_URL: ${{ secrets.S3_ENDPOINT_URL }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
S3_REGION: ${{ secrets.S3_REGION }}
run: |
docker volume prune -f
docker-compose up -d --build
docker ps
- name: Cache python modules
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('client/pyproject.toml') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e "client/.[test]"
- name: Run client unittests
run: |
coverage --version
sleep 15
cd client && coverage run -m pytest tests/ && coverage xml -o coverage-client.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./client/coverage-client.xml
flags: client
fail_ci_if_error: true
headers:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Check the headers
uses: frgfm/validate-python-headers@main
with:
license: 'Apache-2.0'
owner: 'Pyronear'
starting-year: 2020
folders: 'src,client,.github'
ignore-files: 'version.py,__init__.py'
ignore-folders: 'client/tests/,src/tests/'