Skip to content

Commit 37ec5d4

Browse files
Logovskii DmitriiTheBits
authored andcommitted
unified tests run
1 parent a4ca026 commit 37ec5d4

File tree

13 files changed

+105
-99
lines changed

13 files changed

+105
-99
lines changed

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,6 @@ on:
66
branches: [main]
77

88
jobs:
9-
pytest:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v2
14-
- uses: actions/cache@v2
15-
with:
16-
path: ~/.cache/pip
17-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
18-
restore-keys: |
19-
${{ runner.os }}-pip-
20-
- name: Install dependencies
21-
run: |
22-
python -m pip install -r requirements.txt pytest
23-
python -m pip install -e .
24-
- name: Test with pytest
25-
run: |
26-
pytest
279
pre-commit:
2810
runs-on: ubuntu-latest
2911
steps:

.github/workflows/tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
env:
9+
DRIVER_TOKEN: github-actions
10+
TOX_PARALLEL_NO_SPINNER: 1
11+
12+
jobs:
13+
tox:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-python@v3
18+
- uses: actions/cache@v3
19+
with:
20+
path: |
21+
~/.cache/pip
22+
~/.cache/pre-commit
23+
.tox
24+
.mypy_cache
25+
${{ env.pythonLocation }}
26+
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements-tox.txt') }}
27+
- name: Install dependencies
28+
run: python -m pip install --progress-bar off tox
29+
- name: Run all envs
30+
run: tox -p auto -e 'libcloud{30,31,32,33,34,35},pre-commit'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ __pycache__/
55
.tox/
66
.vscode/
77
*.egg-info/
8+
.coverage
9+
bin/*

.pre-commit-config.yaml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ repos:
2525
- id: mixed-line-ending
2626
- id: name-tests-test
2727
- id: trailing-whitespace
28-
args: ['--markdown-linebreak-ext=md']
28+
args: ["--markdown-linebreak-ext=md"]
2929
- repo: https://github.com/asottile/add-trailing-comma
3030
rev: v2.2.3
3131
hooks:
3232
- id: add-trailing-comma
3333
- repo: https://github.com/asottile/pyupgrade
34-
rev: v2.32.0
34+
rev: v2.32.1
3535
hooks:
3636
- id: pyupgrade
37-
args: ['--py3-plus']
37+
args: ["--py3-plus"]
3838
- repo: https://gitlab.com/pycqa/flake8
3939
rev: 3.9.2
4040
hooks:
@@ -47,7 +47,7 @@ repos:
4747
- id: mypy
4848
additional_dependencies: [tokenize-rt]
4949
types: [python]
50-
args: ['--follow-imports=skip', '--ignore-missing-imports']
50+
args: ["--follow-imports=skip", "--ignore-missing-imports"]
5151
- repo: https://github.com/pre-commit/pygrep-hooks
5252
rev: v1.9.0
5353
hooks:
@@ -56,18 +56,8 @@ repos:
5656
- id: python-no-eval
5757
- id: python-no-log-warn
5858
- id: python-use-type-annotations
59-
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
60-
rev: v1.2.4
61-
hooks:
62-
- id: python-safety-dependencies-check
63-
stages: [manual]
64-
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
65-
rev: v1.0.6
66-
hooks:
67-
- id: python-bandit-vulnerability-check
68-
stages: [manual]
6959
- repo: https://github.com/Lucas-C/pre-commit-hooks
70-
rev: v1.1.13
60+
rev: v1.1.14
7161
hooks:
7262
- id: forbid-crlf
7363
- id: remove-crlf
@@ -83,11 +73,10 @@ repos:
8373
rev: 22.3.0
8474
hooks:
8575
- id: black
86-
args: ['--target-version', 'py35', '--line-length', '128']
87-
- repo: https://github.com/jazzband/pip-tools
88-
rev: 6.6.0
76+
args: ["--target-version", "py35", "--line-length", "128"]
77+
- repo: https://github.com/pre-commit/mirrors-prettier
78+
rev: v2.6.2
8979
hooks:
90-
- id: pip-compile
91-
name: pip-compile requirements-dev.in
92-
args: [requirements-dev.in]
93-
files: ^requirements-dev\.(in|txt)$
80+
- id: prettier
81+
types: [markdown, yaml]
82+
exclude: 'test/fixtures'

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ libcloud драйвер для сервиса vdsina.ru
278278

279279
## Разработка
280280

281-
В проекте настроена автоматическая проверка линтерами и тестами.
281+
Для запуска тестов настроен tox. Для проверки коммитов настроен pre-commit.
282+
Так же в проекте настроена автоматический запуск tox в GitHub Actions.
282283

283-
Линтеры запускаются в `pre-commit`, тесты в `pytest`.
284+
### Тесты
285+
286+
Тесты запускаются при помощи [pytest](https://pytest.org/).
287+
288+
### Линтеры и форматтеры
289+
290+
Для запуска линтеров необходимо установить [pre-commit](https://pre-commit.com/). Линтеры запускаются командой `$ pre-commit run -a`.
291+
292+
#### Настройка `pre-commit`
293+
294+
Github Actions запускаются в `stage: commit`, поэтому в `.pre-commit-config.yaml` проверка `id: no-commit-to-branch` установлена в `stage: push`. Что бы проверка запускалась локально и не срабатывала в CI. Локально надо установить pre-commit хуки на пуши и на коммиты следующей командой:
295+
296+
```bash
297+
$ pre-commit install --hook-type pre-commit --hook-type pre-push

requirements-dev.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

requirements-dev.txt

Lines changed: 0 additions & 42 deletions
This file was deleted.

requirements-tox.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# Файл для обновления/сброса кеша в actions/cache
3+
#
4+
# actions/cache не имеет ручного механизма очистки кеша.
5+
# Для сброса нужно менять ключ кеша, в качестве ключа кеширования
6+
# используется хеш этого файла. Для сброса обновите дату.
7+
#
8+
# Обновлено: 23 мая 2022
9+
10+
cryptography # используется в libcloud для ssh-key fingerprint
11+
pytest
12+
pytest-cov
13+
vcrpy

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",
1515
url="https://github.com/thebits/libcloud-vdsina",
16+
install_requires=["apache-libcloud>=3.0.0"],
1617
packages=setuptools.find_packages(),
1718
classifiers=[
1819
"Intended Audience :: System Administrators",

tests/fixtures/list_key_pairs.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ interactions:
1616
uri: https://userapi.vdsina.ru/v1/ssh-key
1717
response:
1818
body:
19-
string: '{"status":"ok","status_msg":"SSH keys list","data":[{"id":5496,"name":"barracude"}]}'
19+
string: '{"status":"ok","status_msg":"SSH keys list","data":[{"id":46329,"name":"x200s", "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLZvQS/4YLHQUKJJupgUuqP28ugEujpqRg7MBBTMRDdOdu+S8Qy0YZSURX6+/+OOXWvP0yICHaiNhyELOMFPXdOF33y1gYvm5YHVq+ehSEtJQQd0r6v+ngs/TEtM0hif7CvvGkVCCREkTV5sMW9agE8xmerlQIyEF280h0KrAemL9IKeVcpeEEF4uWUvElDcoUgOqY2Debwje4SWtfs7Ic73vmpZLJ7CPgxJVaEcLsjbdsm9TeJY7havDRldyh+QkGISyIYRHkxfSV3LA2Zv7I4Ckxx55ZegBwRRDbWALZp38FZ9NvdkbJMmcTM5P1HbNrKmgV/Rce9dtav8vuL2Xp
20+
thebits@x200s"}]}'
2021
headers:
2122
Access-Control-Allow-Headers:
2223
- Authorization,Keep-Alive,Content-Type,Origin
@@ -26,8 +27,8 @@ interactions:
2627
- '1728000'
2728
Connection:
2829
- keep-alive
29-
Content-Encoding:
30-
- gzip
30+
# Content-Encoding:
31+
# - gzip
3132
Content-Type:
3233
- application/json
3334
Date:

0 commit comments

Comments
 (0)