-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (127 loc) · 4.37 KB
/
test.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Tests
on:
push:
branches:
- develop
pull_request:
branches-ignore:
- master
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
DEFAULT_PYTHON: '3.12'
jobs:
tests:
name: Run ${{ matrix.mark }} tests (Python ${{ matrix.python-version }}, Pydantic v${{ matrix.pydantic-version }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.12']
pydantic-version: [1, 2]
os: [ubuntu-latest]
env:
POETRY_VERSION: ${{ matrix.python-version == '3.7' && '1.5.1' || '1.7.1' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Backend Container
uses: docker/build-push-action@v5
with:
tags: mtsrus/horizon-backend:${{ github.sha }}
context: .
file: docker/Dockerfile.backend
push: false
load: true
- name: Start Backend Container
run: |
docker compose -f docker-compose.test.yml down -v --remove-orphans
docker compose -f docker-compose.test.yml up --wait-timeout 5 -d
env:
COMPOSE_PROJECT_NAME: ${{ github.run_id }}-backend
TAG: ${{ github.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
# this step is needed for successful installation of "bonsai" library in python dependencies
run: sudo apt-get update && sudo apt-get install -y libldap2-dev libsasl2-dev
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
- name: Cache poetry
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-codeql-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-codeql-${{ hashFiles('**/poetry.lock') }}
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-codeql-
${{ runner.os }}-python
${{ runner.os }}-
- name: Install dependencies
run: |
poetry install --no-root --all-extras --with test
if [ "${{ matrix.pydantic-version }}" == "1" ]; then
pip install "pydantic<2.0.0"
fi
- name: Run Tests
run: |
source .env.local
mkdir -p reports/
poetry run coverage run -m pytest
- name: Upload Coverage Results
uses: actions/upload-artifact@v4
with:
name: raw-coverage-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
path: reports/.coverage*
- name: Shutdown Backend Container
if: always()
run: |
docker compose -f docker-compose.test.yml down -v --remove-orphans
env:
COMPOSE_PROJECT_NAME: ${{ github.run_id }}-backend
all_done:
name: Tests done
runs-on: ubuntu-latest
needs: [tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-coverage
- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: pip install -I coverage pytest
- name: Download all raw coverage data
uses: actions/download-artifact@v4
with:
path: coverage-data
- name: Combine Coverage Data
run: |
coverage combine coverage-data/*
coverage xml -o combined_coverage.xml
- name: Check Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./combined_coverage.xml
fail_ci_if_error: true
- name: All done
run: echo 1