From 310113c888442c719fe162f0d9a6a699d833df9b Mon Sep 17 00:00:00 2001 From: Harrison Cook Date: Wed, 16 Oct 2024 22:16:16 +0100 Subject: [PATCH] Match upstream naming of organisation (organization) --- .github/workflows/contributors_report.yaml | 4 ++-- .../contributors_report_testing.yaml | 4 ++-- README.md | 20 +++++++++---------- contributors/__init__.py | 4 ++-- contributors/contributor_stats.py | 2 +- contributors/env.py | 16 +++++++-------- contributors/markdown.py | 20 +++++++++---------- tests/test_contributors.py | 6 +++--- tests/test_json_writer.py | 2 +- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.github/workflows/contributors_report.yaml b/.github/workflows/contributors_report.yaml index b97c5f8..a36d65b 100644 --- a/.github/workflows/contributors_report.yaml +++ b/.github/workflows/contributors_report.yaml @@ -32,12 +32,12 @@ jobs: echo "END_DATE=$end_date" >> "$GITHUB_ENV" - name: Run contributor action - uses: hcookie/organisational_contributors@1286dc8d6904a9a7f735e28b7503be164fb7d4b9 + uses: hcookie/organizational_contributors@1286dc8d6904a9a7f735e28b7503be164fb7d4b9 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} START_DATE: ${{ env.START_DATE }} END_DATE: ${{ env.END_DATE }} - REPOSITORY: hcookie/organisational_contributors + REPOSITORY: hcookie/organizational_contributors # SPONSOR_INFO: "true" - name: Show Contributor diff --git a/.github/workflows/contributors_report_testing.yaml b/.github/workflows/contributors_report_testing.yaml index 4040f93..4271e43 100644 --- a/.github/workflows/contributors_report_testing.yaml +++ b/.github/workflows/contributors_report_testing.yaml @@ -45,8 +45,8 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # START_DATE: ${{ env.START_DATE }} # END_DATE: ${{ env.END_DATE }} - REPOSITORY: hcookie/organisational_contributors - SHOW_ORGANISATIONS: [ecmwf] + REPOSITORY: hcookie/organizational_contributors + SHOW_ORGANIZATIONS: [ecmwf] # SPONSOR_INFO: "true" - name: Show Contributor diff --git a/README.md b/README.md index 785796d..76c78ff 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Contributors sorted by Organisation action +# Contributors sorted by Organization action [![Python package](https://github.com/hcookie/contributors/actions/workflows/python-ci.yml/badge.svg)](https://github.com/hcookie/contributors/actions/workflows/python-ci.yml) [![Docker Image CI](https://github.com/hcookie/contributors/actions/workflows/docker-ci.yml/badge.svg)](https://github.com/hcookie/contributors/actions/workflows/docker-ci.yml) [![CodeQL](https://github.com/hcookie/contributors/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/hcookie/contributors/actions/workflows/github-code-scanning/codeql)[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/github/contributors/badge)](https://scorecard.dev/viewer/?uri=github.com/github/contributors) -This is a GitHub Action that given an organization or specified repositories, produces information about the [contributors](https://chaoss.community/kb/metric-contributors/) sorted by organisation. +This is a GitHub Action that given an organization or specified repositories, produces information about the [contributors](https://chaoss.community/kb/metric-contributors/) sorted by organization. Similar actions to help you recognize contributors by putting them into a `README` or `CONTRIBUTORS.md` include: @@ -13,8 +13,8 @@ Similar actions to help you recognize contributors by putting them into a `READM ## Example use cases -- As a maintainer, you may want to acknowledge contributors from various organisations in a discussion post -- A repository wants to track contributions from organisations +- As a maintainer, you may want to acknowledge contributors from various organizations in a discussion post +- A repository wants to track contributions from organizations ## Support @@ -80,7 +80,7 @@ This action can be configured to authenticate with GitHub App Installation or Pe | `END_DATE` | False | Current Date | The date at which you want to stop gathering contributor information. Must be later than the `START_DATE`. ie. Aug 2nd, 2023 would be `2023-08-02` | | `SPONSOR_INFO` | False | False | If you want to include sponsor information in the output. This will include the sponsor count and the sponsor URL. This will impact action performance. ie. SPONSOR_INFO = "False" or SPONSOR_INFO = "True" | | `LINK_TO_PROFILE` | False | True | If you want to link usernames to their GitHub profiles in the output. ie. LINK_TO_PROFILE = "True" or LINK_TO_PROFILE = "False" | -| `SHOW_ORGANISATIONS` | False | [] | Organisations to show in the contributors table. Will be evaluated in order, and a user only added to only the first one they are a part of. Any contributors with no organisation will be shown in independent. Set to 'all' to show all organisations. +| `SHOW_ORGANIZATIONS` | False | [] | Organizations to show in the contributors table. Will be evaluated in order, and a user only added to only the first one they are a part of. Any contributors with no organization will be shown in independent. Set to 'all' to show all organizations. | `CONTRIB_FILENAME` | False | "contibutors" | Filename to add contributors to. Will create both an 'md', and 'json' file with contents. **Performance Note:** Using start and end dates will reduce speed of the action by approximately 63X. ie without dates if the action takes 1.7 seconds, it will take 1 minute and 47 seconds. @@ -121,13 +121,13 @@ jobs: echo "END_DATE=$end_date" >> "$GITHUB_ENV" - name: Run contributor action - uses: hcookie/organisational_contributors@v1 + uses: hcookie/organizational_contributors@v1 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} START_DATE: ${{ env.START_DATE }} END_DATE: ${{ env.END_DATE }} ORGANIZATION: - SHOW_ORGANISATIONS: [ORGANISATIONS_TO_SHOW_HERE] + SHOW_ORGANIZATIONS: [ORGANIZATIONS_TO_SHOW_HERE] CONTRIB_FILENAME: "contributors" - name: Show Contributor @@ -149,17 +149,17 @@ jobs: # Contributors - Date range for contributor list: 2021-01-01 to 2023-10-10 -- Organization: ORGANISATION_HERE +- Organization: ORGANIZATION_HERE | Total Contributors | Total Contributions | % new contributors | | ------------------ | ------------------- | ------------------ | | 1 | 143 | 0% | -## ORGANISATION_HERE +## ORGANIZATION_HERE | Username | All Time Contribution Count | New Contributor | Commits between 2021-01-01 and 2023-10-10 | | --------- | --------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -| @hcookie | 143 | False | [organisation/repo]() | +| @hcookie | 143 | False | [organization/repo]() | ``` ## Local usage without Docker diff --git a/contributors/__init__.py b/contributors/__init__.py index f8c9007..a8456e3 100644 --- a/contributors/__init__.py +++ b/contributors/__init__.py @@ -63,7 +63,7 @@ def main(): environment.repositories_list, environment.sponsor_info, environment.link_to_profile, - environment.show_organisations_list, + environment.show_organizations_list, ) # TODO HCookie Fix to json json_writer.write_to_json( @@ -165,7 +165,7 @@ def get_contributors( contribution_count=user.contributions_count, commit_url=commit_url, sponsor_info="", - organisations=list(map(lambda x: x.url.split("/")[-1], user.organizations())), + organizations=list(map(lambda x: x.url.split("/")[-1], user.organizations())), ) contributors.append(contributor) except Exception as e: diff --git a/contributors/contributor_stats.py b/contributors/contributor_stats.py index 7ed7bc6..137fc5c 100644 --- a/contributors/contributor_stats.py +++ b/contributors/contributor_stats.py @@ -39,7 +39,7 @@ class ContributorStats: contribution_count: int commit_url: str sponsor_info: str - organisations: list[str] = field(default_factory=list) + organizations: list[str] = field(default_factory=list) def is_new_contributor(username: str, returning_contributors: list) -> bool: diff --git a/contributors/env.py b/contributors/env.py index c5cbd18..e8d0bd2 100644 --- a/contributors/env.py +++ b/contributors/env.py @@ -86,7 +86,7 @@ class EnvironmentConfig: end_date: str sponsor_info: bool link_to_profile: bool - show_organisations_list: list[str] + show_organizations_list: list[str] filename: str = "contributors" @@ -123,8 +123,8 @@ def get_env_vars( whether to get sponsor information on the contributor link_to_profile, bool: whether to link username to Github profile in markdown output - show_organisations_list, list: - Organisations to show in order of preference + show_organizations_list, list: + Organizations to show in order of preference """ @@ -152,7 +152,7 @@ def get_env_vars( ghe = os.getenv("GH_ENTERPRISE_URL", default="").strip() filename = os.getenv("CONTRIB_FILENAME", default="contributors").strip() - show_organisations = os.getenv("SHOW_ORGANISATIONS", default="").strip() + show_organizations = os.getenv("SHOW_ORGANIZATIONS", default="").strip() start_date = validate_date_format("START_DATE") end_date = validate_date_format("END_DATE") @@ -165,9 +165,9 @@ def get_env_vars( if repositories_str: repositories_list = [repository.strip() for repository in repositories_str.split(",")] - show_organisations_list = [] - if show_organisations: - show_organisations_list = [org.strip() for org in show_organisations.split(",")] + show_organizations_list = [] + if show_organizations: + show_organizations_list = [org.strip() for org in show_organizations.split(",")] return EnvironmentConfig( organization, @@ -181,6 +181,6 @@ def get_env_vars( end_date, sponsor_info, link_to_profile, - show_organisations_list, + show_organizations_list, filename=filename, ) diff --git a/contributors/markdown.py b/contributors/markdown.py index 6cdea0a..8f10396 100644 --- a/contributors/markdown.py +++ b/contributors/markdown.py @@ -16,7 +16,7 @@ def write_to_markdown( repository, sponsor_info, link_to_profile, - show_organisations_list, + show_organizations_list, ): """ This function writes a list of collaborators to a markdown file in table format. @@ -32,7 +32,7 @@ def write_to_markdown( repository (str): The repository for which the contributors are being listed. sponsor_info (str): True if the user wants the sponsor_url shown in the report link_to_profile (str): True if the user wants the username linked to Github profile in the report - show_organisations_list (list): Organisations to show + show_organizations_list (list): Organizations to show Returns: None @@ -47,7 +47,7 @@ def write_to_markdown( repository, sponsor_info, link_to_profile, - show_organisations_list, + show_organizations_list, ) # Put together the summary table including # of new contributions, # of new contributors, % new contributors, % returning contributors @@ -148,7 +148,7 @@ def get_contributor_table( repository, sponsor_info, link_to_profile, - show_organisations_list, + show_organizations_list, ): """ This function returns a string containing a markdown table of the contributors and the total contribution count. @@ -183,7 +183,7 @@ def get_contributor_table( total_contributions = 0 - organisation_contributors = defaultdict(list) + organization_contributors = defaultdict(list) for collaborator in collaborators: total_contributions += collaborator.contribution_count @@ -215,16 +215,16 @@ def get_contributor_table( added_to_org: bool = False - for org in collaborator.organisations or []: - if org in show_organisations_list or "all" in show_organisations_list: - organisation_contributors[org].append(row) + for org in collaborator.organizations or []: + if org in show_organizations_list or "all" in show_organizations_list: + organization_contributors[org].append(row) added_to_org = True break if not added_to_org: - organisation_contributors["Independent"].append(row) + organization_contributors["Independent"].append(row) - tables = {org: headers + "".join(rows) for org, rows in organisation_contributors.items()} + tables = {org: headers + "".join(rows) for org, rows in organization_contributors.items()} # table += row return tables, total_contributions diff --git a/tests/test_contributors.py b/tests/test_contributors.py index 86a0a1d..6e15545 100644 --- a/tests/test_contributors.py +++ b/tests/test_contributors.py @@ -34,7 +34,7 @@ def test_get_contributors(self, mock_contributor_stats): contribution_count = 100, commit_url ='https://github.com/owner/repo/commits?author=user&since=2022-01-01&until=2022-12-31', sponsor_info='', - organisations=[] + organizations=[] ) @patch("contributors.get_contributors") @@ -71,7 +71,7 @@ def test_get_all_contributors_with_organization(self, mock_get_contributors): contribution_count=200, commit_url = "commit_url, commit_url", sponsor_info = "sponsor_url_1", - organisations= [], + organizations= [], ), ], ) @@ -142,7 +142,7 @@ def test_get_contributors_skip_users_with_no_commits(self, mock_contributor_stat contribution_count=100, commit_url="https://github.com/owner/repo/commits?author=user&since=2022-01-01&until=2022-12-31", sponsor_info='', - organisations=[], + organizations=[], ) diff --git a/tests/test_json_writer.py b/tests/test_json_writer.py index 37aff74..191330c 100644 --- a/tests/test_json_writer.py +++ b/tests/test_json_writer.py @@ -27,7 +27,7 @@ def setUp(self): "new_contributor": False, "avatar_url": "https://test_url.com", "contribution_count": 10, - 'organisations': [], + 'organizations': [], "commit_url": "https://test_commit_url.com", "sponsor_info": "", }