From f170f51e3a4b7f3e4711c0de5291a7acd05410e9 Mon Sep 17 00:00:00 2001 From: Stephan Merker Date: Thu, 23 Jan 2025 16:09:42 +0100 Subject: [PATCH] Add CI workflow for org management - runs flake8, black and unit tests - fixed a black formatting issue --- .github/workflows/org-management-ci.yml | 26 +++++++++++++++++++++++++ org/org_management.py | 24 ++++++++++++----------- 2 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/org-management-ci.yml diff --git a/.github/workflows/org-management-ci.yml b/.github/workflows/org-management-ci.yml new file mode 100644 index 000000000..46da00cfa --- /dev/null +++ b/.github/workflows/org-management-ci.yml @@ -0,0 +1,26 @@ +name: 'Check Github Organization Settings PRs' +on: + pull_request: + paths: + - 'org/*.py' + - 'org/requirements*' + - 'org/pyproject.toml' + - '.github/workflows/org-management-ci.yml' +jobs: + org-config-generation-check: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v5 + with: + python-version: 3.9 + - uses: actions/checkout@v4 + with: + path: community + - name: Run flake8 and unittests + run: | + python -m pip install --upgrade pip + pip install -r community/org/requirements.txt + pip install -r community/org/requirements-dev.txt + cd community/org + python -m flake8 + python -m unittest discover -s . diff --git a/org/org_management.py b/org/org_management.py index d596dbc7d..fbc3a5fd4 100644 --- a/org/org_management.py +++ b/org/org_management.py @@ -444,17 +444,19 @@ def _generate_wb_branch_protection(self, wg) -> Dict[str, Any]: "required_pull_request_reviews": { "dismiss_stale_reviews": True, "require_code_owner_reviews": True, - "required_approving_review_count": 0 - if len( - { - u["github"] - for a in wg["areas"] - if OrgGenerator._CF_ORG_PREFIX + repo in a["repositories"] - for u in a["approvers"] - } - ) - < 4 - else 1, + "required_approving_review_count": ( + 0 + if len( + { + u["github"] + for a in wg["areas"] + if OrgGenerator._CF_ORG_PREFIX + repo in a["repositories"] + for u in a["approvers"] + } + ) + < 4 + else 1 + ), "bypass_pull_request_allowances": { "teams": [wg_bots] # wg bot team + [