gitconsensus / GithubOrganizer

Github App for making Organizations easier to manage
https://organizer.gitconsensus.com/
MIT License
36 stars 11 forks source link

organizer.yaml contents not being updated #16

Closed tobes64 closed 2 years ago

tobes64 commented 2 years ago

Hi Ted,

I've been trying to get the GitHub Organizer working locally for a while now and have been partially successful in terms of updating certain configurations. This includes:

The issue is that these seem to be the api webhook requests being made when it should also be updating to include the teams section within the organizer.yaml file.

Example:

  Admin:
    members:
      - test-user-1
      - test-user-2

repositories:
  default:
    branches:
      master:
        dismiss_stale_reviews: true
        required_approving_review_count: 1
        require_code_owner_reviews: true
        required_pull_request_reviews: true
    dependency_security:
      alerts: true
      automatic_fixes: true
      teams_clean: true
    features:
      has_downloads: false
      has_issues: false
      has_projects: false
      has_wiki: false
    merges:
      allow_merge_commit: false
      allow_rebase_merge: false
      allow_squash_merge: true
      delete_branch_on_merge: true
    teams:
      Admin: admin
      Dev: push
      DevOps: push
      Service Accounts: push

From the log output it seems that the default repository is having its configurations updated, but it is completely missing out updating the team related to the organization.

Log output:

[2022-01-28 12:38:50,083: INFO/ForkPoolWorker-5] Building a url from ('https://api.github.com/repos/octocat/.github', 'topics')
[2022-01-28 12:38:50,102: INFO/ForkPoolWorker-6] JSON was returned
[2022-01-28 12:38:50,103: INFO/ForkPoolWorker-6] Building a url from ('https://api.github.com/repos/octocat/.github', 'topics')
[2022-01-28 12:38:50,103: INFO/ForkPoolWorker-6] Missed the cache building the url
[2022-01-28 12:38:50,114: INFO/ForkPoolWorker-4] JSON was returned
[2022-01-28 12:38:50,114: INFO/ForkPoolWorker-4] Building a url from ('https://api.github.com/repos/octocat/.github', 'topics')
[2022-01-28 12:38:50,316: INFO/ForkPoolWorker-5] JSON was returned
[2022-01-28 12:38:50,355: INFO/ForkPoolWorker-4] JSON was returned
[2022-01-28 12:38:50,367: INFO/ForkPoolWorker-6] JSON was returned
[2022-01-28 12:38:50,368: INFO/ForkPoolWorker-6] Building a url from ('https://api.github.com/repos/octocat/.github', 'topics')
[2022-01-28 12:38:50,618: INFO/ForkPoolWorker-6] JSON was returned
[2022-01-28 12:38:50,664: INFO/ForkPoolWorker-6] Task githuborganizer.tasks.github.update_repo_branch_protection[fc51cd5d-553e-405c-a92e-644e8ec8337b] succeeded in 1.3411427661776543s: None
[2022-01-28 12:38:50,665: INFO/MainProcess] Received task: githuborganizer.tasks.github.update_branch_protection[bb135a4e-ba19-4130-a988-4625d303d324]  
[2022-01-28 12:38:50,703: INFO/ForkPoolWorker-5] JSON was returned
[2022-01-28 12:38:50,705: INFO/ForkPoolWorker-5] Task githuborganizer.tasks.github.update_repository_settings[f2ee1a7a-8b64-4c28-bb81-d6201fb88650] succeeded in 1.38410172611475s: None
[2022-01-28 12:38:50,965: INFO/ForkPoolWorker-4] Task githuborganizer.tasks.github.update_repository_security_settings[233e495d-7942-43e7-8c60-109b27a63968] succeeded in 1.6433063223958015s: None
[2022-01-28 12:38:51,147: INFO/ForkPoolWorker-7] Building a url from ('https://api.github.com', 'repos', 'octocat', '.github')
[2022-01-28 12:38:51,148: INFO/ForkPoolWorker-7] Missed the cache building the url
[2022-01-28 12:38:51,450: INFO/ForkPoolWorker-7] JSON was returned
[2022-01-28 12:38:51,452: INFO/ForkPoolWorker-7] Building a url from ('https://api.github.com/repos/octocat/.github', 'topics')
[2022-01-28 12:38:51,452: INFO/ForkPoolWorker-7] Missed the cache building the url
[2022-01-28 12:38:51,680: INFO/ForkPoolWorker-7] JSON was returned
[2022-01-28 12:38:51,680: INFO/ForkPoolWorker-7] Building a url from ('https://api.github.com/repos/octocat/.github', 'topics')
[2022-01-28 12:38:51,908: INFO/ForkPoolWorker-7] JSON was returned
[2022-01-28 12:38:51,909: WARNING/ForkPoolWorker-7] Updating branch protection for master in octocat/.github.
[2022-01-28 12:38:51,909: WARNING/ForkPoolWorker-7] {"required_status_checks": {"contexts": ["Semantic Pull Request"], "strict": false}, "enforce_admins": false, "required_pull_request_reviews": null, "restrictions": null, "required_linear_history": false, "allow_force_pushes": false, "allow_deletions": false}
[2022-01-28 12:38:52,287: INFO/ForkPoolWorker-7] Task githuborganizer.tasks.github.update_branch_protection[bb135a4e-ba19-4130-a988-4625d303d324] succeeded in 1.6207495890557766s: None
[2022-01-28 12:39:28,375: INFO/MainProcess] Scaling down 2 processes.

The repo name has been changed. Is there something I am missing in the configuration file itself?

Looking at the www.py file and the function github_webhook it looks as if though the header only accepts installation, issues, repository and installation_repositories which all have their own corresponding functions.

Each one of these calls functions within the tasks/github.py file are being called by the functions listed above, but the two functions not being called are update_organization_team_members or update_team_members which seem to update the list of team members able to access repos and providing organization users etc.

Any assistance on this would be greatly appreciated.

tobes64 commented 2 years ago

Fixed. The update_organization_team_members function wasn't being used until now.

githuborganizer/tasks/github.py

            update_organization_settings(organization)
            update_organization_teams(organization)
+          update_organization_team_members(organization)
        else:
            update_organization_settings.delay(organization)
            update_organization_teams.delay(organization)
+          update_organization_team_members.delay(organization)

@celery.task(max_retries=0)

githuborganizer/www.py

        install_id = payload['installation']['id']
        install = ghapp.get_installation(install_id)
        organization = install.get_organization()
        tasks.update_team_members.delay(organization)
        tasks.update_organization_settings.delay(organization)
+      tasks.update_organization_teams.delay(organization)
+      tasks.update_organization_team_members.delay(organization)
        return 'Processing organization %s.' % organization