diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 908f4d48..bb574046 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9bc86f5a..5f384934 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/tools/pagerduty-migrator/migrator/report.py b/tools/pagerduty-migrator/migrator/report.py index 39c769ca..4947a44f 100644 --- a/tools/pagerduty-migrator/migrator/report.py +++ b/tools/pagerduty-migrator/migrator/report.py @@ -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"] diff --git a/tools/pagerduty-migrator/requirements.txt b/tools/pagerduty-migrator/requirements.txt index 339e1095..8e7340c8 100644 --- a/tools/pagerduty-migrator/requirements.txt +++ b/tools/pagerduty-migrator/requirements.txt @@ -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 \ No newline at end of file