Add PD migrator lint & test steps to CI (#1053)

# What this PR does

- Add PD migrator related hooks to `.pre-commit-config.yaml`
- Add Github Actions step for running PD migrator tests
This commit is contained in:
Vadim Stepanov 2022-12-30 16:03:39 +00:00 committed by GitHub
parent 282e58db7b
commit 1b67a8ec68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 6 deletions

View file

@ -151,6 +151,17 @@ jobs:
pip install -r requirements.txt
ONCALL_TESTING_RBAC_ENABLED=${{ matrix.rbac_enabled }} pytest -x
unit-test-pd-migrator:
runs-on: ubuntu-latest
container: python:3.9
steps:
- uses: actions/checkout@v2
- name: Unit Test PD Migrator
run: |
cd tools/pagerduty-migrator
pip install -r requirements.txt
pytest -x
docker-build:
runs-on: ubuntu-latest
steps:

View file

@ -5,6 +5,10 @@ repos:
- id: isort
files: ^engine
args: [--settings-file=engine/pyproject.toml, --filter-files]
- id: isort
name: isort - pd-migrator
files: ^tools/pagerduty-migrator
args: [--settings-file=tools/pagerduty-migrator/.isort.cfg, --filter-files]
- repo: https://github.com/psf/black
rev: 22.3.0
@ -12,6 +16,9 @@ repos:
- id: black
files: ^engine
args: [--config=engine/pyproject.toml]
- id: black
name: black - pd-migrator
files: ^tools/pagerduty-migrator
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
@ -21,6 +28,12 @@ repos:
args: [--config=engine/tox.ini]
additional_dependencies:
- flake8-tidy-imports
- id: flake8
name: flake8 - pd-migrator
files: ^tools/pagerduty-migrator
# Make sure config is compatible with black
# https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
args: [--max-line-length=88, "--select=C,E,F,W,B,B950", "--extend-ignore=E203,E501"]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.25.0

View file

@ -105,13 +105,13 @@ def escalation_policy_report(policies: list[dict]) -> str:
for policy in sorted(
policies, key=lambda p: bool(p["unmatched_users"] or p["flawed_schedules"])
):
result += f"\n" + TAB + format_escalation_policy(policy)
result += "\n" + TAB + format_escalation_policy(policy)
for user in policy["unmatched_users"]:
result += f"\n" + TAB * 2 + format_user(user)
result += "\n" + TAB * 2 + format_user(user)
for schedule in policy["flawed_schedules"]:
result += f"\n" + TAB * 2 + format_schedule(schedule)
result += "\n" + TAB * 2 + format_schedule(schedule)
if (
not policy["unmatched_users"]
@ -135,7 +135,7 @@ def integration_report(integrations: list[dict]) -> str:
key=lambda i: bool(i["oncall_type"] and not i["is_escalation_policy_flawed"]),
reverse=True,
):
result += f"\n" + TAB + format_integration(integration)
result += "\n" + TAB + format_integration(integration)
if (
integration["oncall_type"]
and not integration["is_escalation_policy_flawed"]

View file

@ -1,6 +1,4 @@
requests==2.27.1
pdpyras==4.5.0
isort==5.10.1
black==22.3.0
pytest==7.1.2
pytest-env==0.6.2