From fdfef81dbbffde382d50c26aa3c2f5eac272a0bb Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 15:15:36 +0100 Subject: [PATCH 1/9] chore(IDX): update python to 3.12 --- .github/workflows/check_cla.yml | 2 +- .github/workflows/check_cla_signed.yml | 2 +- .github/workflows/python_lint_test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_cla.yml b/.github/workflows/check_cla.yml index 02bb714..331824f 100644 --- a/.github/workflows/check_cla.yml +++ b/.github/workflows/check_cla.yml @@ -29,7 +29,7 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.12' - name: Install Dependencies run: pip install -r requirements.txt diff --git a/.github/workflows/check_cla_signed.yml b/.github/workflows/check_cla_signed.yml index 4fe1b4f..e37c519 100644 --- a/.github/workflows/check_cla_signed.yml +++ b/.github/workflows/check_cla_signed.yml @@ -17,7 +17,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.12' - name: Install Dependencies run: pip install -q -r requirements.txt shell: bash diff --git a/.github/workflows/python_lint_test.yml b/.github/workflows/python_lint_test.yml index 3f57315..3f6c2f3 100644 --- a/.github/workflows/python_lint_test.yml +++ b/.github/workflows/python_lint_test.yml @@ -23,7 +23,7 @@ jobs: - name: Install Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.12' - name: Install Dependencies run: pip install -r requirements.txt From baf3a9ce6f64705d8f88f244809a5a2436582345 Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 15:21:39 +0100 Subject: [PATCH 2/9] update readme --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 0e407fe..9c228c1 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,15 @@ This repository contains a set of internal workflows used at DFINITY. So far thi 1. [CLA Workflow](CLA-workflow.md) This repository is not open to external contributions. + +## updating pip requirements +Start a venv: +``` +python -m venv .venv +source /path/to/venv/bin/activate +``` +Install pip-tools and run pip-compile: +``` +pip install pip-tools +pip-compile requirements.in +``` From 378f112b4b476717cd75e6210a159c2e2bb27560 Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 15:21:52 +0100 Subject: [PATCH 3/9] update requirements.txt --- requirements.txt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7d96686..86e1b24 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.9 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements.in @@ -18,8 +18,6 @@ click==8.1.3 # via black cryptography==43.0.1 # via pyjwt -exceptiongroup==1.2.0 - # via pytest flake8==6.0.0 # via -r requirements.in github3-py==3.2.0 @@ -64,15 +62,8 @@ requests==2.32.0 # via github3-py six==1.16.0 # via python-dateutil -tomli==2.0.1 - # via - # black - # mypy - # pytest typing-extensions==4.5.0 - # via - # black - # mypy + # via mypy uritemplate==4.1.1 # via github3-py urllib3==1.26.19 From f81b3bff9dd0c82bee373d73c7eee415bca2e56a Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 15:26:30 +0100 Subject: [PATCH 4/9] update ref --- reusable_workflows/tests/test_compliance_checks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reusable_workflows/tests/test_compliance_checks.py b/reusable_workflows/tests/test_compliance_checks.py index 031a98b..6771e97 100644 --- a/reusable_workflows/tests/test_compliance_checks.py +++ b/reusable_workflows/tests/test_compliance_checks.py @@ -171,7 +171,7 @@ def test_branch_protection_enabled(): branch_protection_check.check(helper) - assert repo.branch.called_with("main") + assert repo.branch.assert_called_with("main") assert branch_protection_check.name == "branch_protection" assert branch_protection_check.succeeds is True @@ -187,7 +187,7 @@ def test_branch_protection_disabled(): branch_protection_check.check(helper) - assert repo.branch.called_with("main") + assert repo.branch.assert_called_with("main") assert branch_protection_check.succeeds is False From ccab782fedbe2b2e1cd9a794df96854b717ef3fe Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 16:29:08 +0100 Subject: [PATCH 5/9] update --- reusable_workflows/tests/test_compliance_checks.py | 6 ++++-- reusable_workflows/tests/test_utils.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/reusable_workflows/tests/test_compliance_checks.py b/reusable_workflows/tests/test_compliance_checks.py index 6771e97..3cbeb98 100644 --- a/reusable_workflows/tests/test_compliance_checks.py +++ b/reusable_workflows/tests/test_compliance_checks.py @@ -166,12 +166,13 @@ def test_branch_protection_enabled(): repo.default_branch = "main" branch = mock.Mock() branch.protected = True + helper.repo = repo helper.repo.branch.return_value = branch branch_protection_check = BranchProtection() branch_protection_check.check(helper) - assert repo.branch.assert_called_with("main") + helper.repo.branch.assert_called_with("main") assert branch_protection_check.name == "branch_protection" assert branch_protection_check.succeeds is True @@ -182,12 +183,13 @@ def test_branch_protection_disabled(): repo.default_branch = "main" branch = mock.Mock() branch.protected = False + helper.repo = repo helper.repo.branch.return_value = branch branch_protection_check = BranchProtection() branch_protection_check.check(helper) - assert repo.branch.assert_called_with("main") + helper.repo.branch.assert_called_with("main") assert branch_protection_check.succeeds is False diff --git a/reusable_workflows/tests/test_utils.py b/reusable_workflows/tests/test_utils.py index b985549..d17a342 100644 --- a/reusable_workflows/tests/test_utils.py +++ b/reusable_workflows/tests/test_utils.py @@ -14,7 +14,7 @@ def test_download_file_succeeds_first_try(): data = download_gh_file(repo, "file_path") assert data == "file_contents" - assert repo.file_contents.called_with("file_path") + repo.file_contents.assert_called_with("file_path") assert repo.file_contents.call_count == 1 @@ -30,7 +30,7 @@ def test_download_file_succeeds_third_try(): data = download_gh_file(repo, "file_path") assert data == "file_contents" - assert repo.file_contents.called_with("file_path") + repo.file_contents.assert_called_with("file_path") assert repo.file_contents.call_count == 3 From 18b66a25a9166a7776677001026d0abf682a6b6f Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 16:42:01 +0100 Subject: [PATCH 6/9] update typing-extensions --- requirements.in | 3 ++- requirements.txt | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/requirements.in b/requirements.in index d701140..c10c206 100644 --- a/requirements.in +++ b/requirements.in @@ -2,4 +2,5 @@ github3.py mypy black flake8 -pytest \ No newline at end of file +pytest +typing-extensions>=4.6.0 diff --git a/requirements.txt b/requirements.txt index 86e1b24..0a57dbb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -62,8 +62,10 @@ requests==2.32.0 # via github3-py six==1.16.0 # via python-dateutil -typing-extensions==4.5.0 - # via mypy +typing-extensions==4.12.2 + # via + # -r requirements.in + # mypy uritemplate==4.1.1 # via github3-py urllib3==1.26.19 From b835d1862bd34d77b31d08667b6aec6ce71e16da Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 16:42:42 +0100 Subject: [PATCH 7/9] add comment --- requirements.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.in b/requirements.in index c10c206..b056daf 100644 --- a/requirements.in +++ b/requirements.in @@ -3,4 +3,4 @@ mypy black flake8 pytest -typing-extensions>=4.6.0 +typing-extensions>=4.6.0 # causes issues with python 3.12 if not specified From 44b1c8a738d6db9dbd6923bb2aa57e556d49e46f Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 16:44:34 +0100 Subject: [PATCH 8/9] linting --- reusable_workflows/tests/test_cla_pr.py | 2 ++ reusable_workflows/tests/test_membership.py | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reusable_workflows/tests/test_cla_pr.py b/reusable_workflows/tests/test_cla_pr.py index 2344eda..a6a0529 100644 --- a/reusable_workflows/tests/test_cla_pr.py +++ b/reusable_workflows/tests/test_cla_pr.py @@ -172,6 +172,7 @@ def test_handle_cla_signed_with_pending_label(): issue.remove_label.assert_called_once() issue.add_labels.assert_called_once() + def test_handle_cla_signed_with_new_pending_label(): issue = mock.Mock() label = mock.Mock() @@ -186,6 +187,7 @@ def test_handle_cla_signed_with_new_pending_label(): issue.remove_label.assert_called_once() issue.add_labels.assert_called_once() + def test_handle_cla_signed_with_no_label(capfd): issue = mock.Mock() issue.original_labels = [] diff --git a/reusable_workflows/tests/test_membership.py b/reusable_workflows/tests/test_membership.py index 1345132..12781b3 100644 --- a/reusable_workflows/tests/test_membership.py +++ b/reusable_workflows/tests/test_membership.py @@ -90,9 +90,7 @@ def test_end_to_end_api_fails(os_system, github_login_mock): os_system.assert_not_called() -@mock.patch.dict( - os.environ, {"GH_ORG": "my_org", "GH_TOKEN": "", "USER": "username"} -) +@mock.patch.dict(os.environ, {"GH_ORG": "my_org", "GH_TOKEN": "", "USER": "username"}) @mock.patch("github3.login") def test_github_token_not_passed_in(github_login_mock): github_login_mock.return_value = None From a002c2ed8295f351855cf10184e460fdd8df91a1 Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Thu, 28 Nov 2024 16:47:08 +0100 Subject: [PATCH 9/9] add exception --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index ce2267c..43f9140 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,4 +9,4 @@ ignore_missing_imports = True ignore_missing_imports = True [flake8] -ignore = E501 +ignore = E501, E701