-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (157 loc) · 5.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Tests
on: push
env:
BOT_CREDENTIALS: example.ru@6d624b45b67f843322ebaa1143132a24@7a1c7744-23c9-4ba9-a7dc-5381f090a52d
REDIS_DSN: redis://localhost:6379/0
POSTGRES_DSN: postgresql://postgres:postgres@localhost:5432/postgres
poetry_version: "1.4.0"
project_name: "async-box-bot"
PROD_SERVER_HOST: "prod.example.com"
DEV_SERVER_HOST: "dev.example.com"
BOTS_REGISTRY_URL: "registry.example.com/bots/"
jobs:
test-image:
name: Test app start
runs-on: ubuntu-20.04
services:
postgres:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:6
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install copier
run: |
pip install copier==7.1.0
pip install copier-templates-extensions
# hardcode pydantic version to avoid dependency conflict with copier
pip install pydantic==1.10.2
- name: Test image
env:
REDIS_DSN: ${{ env.REDIS_DSN }}
POSTGRES_DSN: ${{ env.POSTGRES_DSN }}
run: ./.github/scripts/test_image
test-template:
name: Test template
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
services:
postgres:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:6
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install copier
run: |
pip install copier==7.1.0
pip install copier-templates-extensions
# hardcode pydantic version to avoid dependency conflict with copier
pip install pydantic==1.10.2
python -m copier --defaults . async-box-bot
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Set up cache
id: cache
uses: actions/cache@v2
with:
path: |
~/.cache/pip
${{ env.project_name }}/.venv
key: venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
working-directory: ${{ env.project_name }}
run: |
pip install poetry==${{ env.poetry_version }}
poetry config virtualenvs.in-project true
poetry install
- name: Run tests
env:
BOT_CREDENTIALS: example.ru@6d624b45b67f843322ebaa1143132a24@7a1c7744-23c9-4ba9-a7dc-5381f090a52d
REDIS_DSN: redis://localhost:6379/0
POSTGRES_DSN: postgresql://postgres:postgres@localhost:5432/postgres
working-directory: ${{ env.project_name }}
run: |
poetry run ./scripts/test
lint:
name: Lint
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install copier
run: |
pip install copier==7.1.0
pip install copier-templates-extensions
# hardcode pydantic version to avoid dependency conflict with copier
pip install pydantic==1.10.2
python -m copier --defaults . async-box-bot
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Set up cache
id: cache
uses: actions/cache@v2
with:
path: |
~/.cache/pip
${{ env.project_name }}/.venv
key: venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
working-directory: ${{ env.project_name }}
run: |
pip install poetry==${{ env.poetry_version }}
poetry config virtualenvs.in-project true
poetry install
- name: Run linters
working-directory: ${{ env.project_name }}
run: |
poetry run ./scripts/lint