From 56c95fcf8320348089c41323859a16f25afd15e8 Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Fri, 30 Aug 2024 17:50:50 -0400 Subject: [PATCH 01/12] Add tests for parsing Conference Issues --- tests/test.py | 148 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 130 insertions(+), 18 deletions(-) diff --git a/tests/test.py b/tests/test.py index 2653cb3..c3c8023 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,6 +1,8 @@ import pytest from playwright.sync_api import Page, expect +from _conferences.__main__ import parse_conference_details + live_server_url = "http://127.0.0.1:4000" routes = [ @@ -13,8 +15,8 @@ @pytest.mark.parametrize("url", routes) def test_destination( - page: Page, - url: str, + page: Page, + url: str, ) -> None: """Test that the destinations page loads with seeded data""" # Create a destination @@ -26,11 +28,11 @@ def test_destination( @pytest.mark.parametrize( "title, url", ( - ("Acerca de", "/es/about/"), - ("Inicio", "/es/"), - ("Eventos", "/es/events/"), - ("Comunidad", "/es/community/"), - ("Conferencias", "/es/conferences/"), + ("Acerca de", "/es/about/"), + ("Inicio", "/es/"), + ("Eventos", "/es/events/"), + ("Comunidad", "/es/community/"), + ("Conferencias", "/es/conferences/"), ), ) def test_headers_in_language(page: Page, title: str, url: str) -> None: @@ -55,11 +57,11 @@ def test_switching_lang_es_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Kutuhusu", "/sw/about/"), - ("Nyumbani", "/sw/"), - ("Matukio", "/sw/events/"), - ("Jumuiya", "/sw/community/"), - ("Mikutano", "/sw/conferences/"), + ("Kutuhusu", "/sw/about/"), + ("Nyumbani", "/sw/"), + ("Matukio", "/sw/events/"), + ("Jumuiya", "/sw/community/"), + ("Mikutano", "/sw/conferences/"), ), ) def test_headers_in_sw(page: Page, title: str, url: str) -> None: @@ -84,12 +86,12 @@ def test_switching_lang_sw_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Black Python Devs | Home", "/"), - ("Black Python Devs | Blog", "/blog"), - ("Black Python Devs | About Us", "/about/"), - ("Black Python Devs | Events", "/events/"), - ("Black Python Devs | Conferences", "/conferences/"), - ("Black Python Devs | Community", "/community/"), + ("Black Python Devs | Home", "/"), + ("Black Python Devs | Blog", "/blog"), + ("Black Python Devs | About Us", "/about/"), + ("Black Python Devs | Events", "/events/"), + ("Black Python Devs | Conferences", "/conferences/"), + ("Black Python Devs | Community", "/community/"), ), ) def test_bpdevs_title_en(page: Page, title: str, url: str) -> None: @@ -101,3 +103,113 @@ def test_mailto_bpdevs(page: Page) -> None: page.goto(f"{live_server_url}") mailto = page.get_by_role("link", name="email") expect(mailto).to_have_attribute("href", "mailto:contact@blackpythondevs.com") + + +def test_conference_parsing_valid_url(): + example_conf_issue = """### Conference Name + +Test Conference Title + +### URL + +https://microsoft.com + +### Conference Dates + +10 - 15 Sep 2050 + +### Conference Type + +both + +### Conference Location + +Redmond, WA, USA + +### Summary + +Test Conference Summary + +### Speaking + +* [Satya Nadella](https://www.linkedin.com/in/satyanadella/) +""" + expected_name = "Test Conference Title" + expected_url = "https://microsoft.com" + parsed_conf = parse_conference_details(issue_body=example_conf_issue) + + assert parsed_conf["name"] == expected_name + assert parsed_conf["url"] == expected_url + + +def test_conference_parsing_logic_no_url_scheme(): + example_conf_issue = """### Conference Name + +Test Conference Title + +### URL + +microsoft.com + +### Conference Dates + +10 - 15 Sep 2050 + +### Conference Type + +both + +### Conference Location + +Redmond, WA, USA + +### Summary + +Test Conference Summary + +### Speaking + +* [Satya Nadella](https://www.linkedin.com/in/satyanadella/) +""" + expected_name = "Test Conference Title" + expected_url = "https://microsoft.com" + parsed_conf = parse_conference_details(issue_body=example_conf_issue) + + assert parsed_conf["name"] == expected_name + assert parsed_conf["url"] == expected_url + + +def test_conference_parsing_logic_no_url(): + example_conf_issue = """### Conference Name + +Test Conference Title + +### URL + + +### Conference Dates + +10 - 15 Sep 2050 + +### Conference Type + +both + +### Conference Location + +Redmond, WA, USA + +### Summary + +Test Conference Summary + +### Speaking + +* [Satya Nadella](https://www.linkedin.com/in/satyanadella/) +""" + expected_name = "Test Conference Title" + expected_url = None + parsed_conf = parse_conference_details(issue_body=example_conf_issue) + + assert parsed_conf["name"] == expected_name + assert parsed_conf["url"] == expected_url From 5c3f9c13634b71b11d4d779bff190d24bb0c2209 Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Fri, 30 Aug 2024 17:51:34 -0400 Subject: [PATCH 02/12] Refactor top-level logic into testable functions --- _conferences/__main__.py | 159 +++++++++++++++++++++++---------------- 1 file changed, 94 insertions(+), 65 deletions(-) diff --git a/_conferences/__main__.py b/_conferences/__main__.py index 4ff4d38..5540445 100644 --- a/_conferences/__main__.py +++ b/_conferences/__main__.py @@ -6,6 +6,8 @@ import yaml from github import Auth, Github +from github.Issue import Issue +from github.PaginatedList import PaginatedList TOKEN = os.getenv("GITHUB_TOKEN", "") ROOT = Path(__file__).parent.parent @@ -14,68 +16,95 @@ auth = Auth.Token(TOKEN) g = Github(auth=auth) -repo = g.get_repo("BlackPythonDevs/blackpythondevs.github.io") -open_issues = repo.get_issues(state="open", labels=["conference"]) -conferences = [] -today = datetime.combine(datetime.now(), time()) - -for issue in open_issues: - if "conference" in [label.name for label in issue.labels]: - # Extract fields from issue body - name_match = re.search( - r"Conference Name(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue.body - ) - url_match = re.search(r"URL(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue.body) - dates_match = re.search( - r"Conference Dates(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue.body - ) - type_match = re.search( - r"Conference Type(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue.body - ) - location_match = re.search( - r"Conference Location(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue.body - ) - summary_match = re.search( - r"Summary(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", - issue.body, - re.DOTALL, - ) - speaking_match = re.search( - r"Speaking(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}### Code of Conduct(?:\r\n|\n){2}", - issue.body, - re.DOTALL, - ) - - # Set a default value of None for when the url field isn't as expected - valid_url = None - - # Ensure the url field is not blank and the url matches the regex - if url_match is not None and url_match[1].strip() != "": - # Parse the url and see if a scheme (`https`) is included in it - # If not, then prepend `https` to the url from the issue body - # This guards against the website thinking the passed in url is another page on https://blackpythondevs.com/ - parsed_url = urlparse(url_match[1]) - if "http" not in parsed_url.scheme.casefold(): - valid_url = f"https://{url_match[1]}" - - if dates_match: - conferenceDates = dates_match[1] - # Parse the end date of the conference - endDateStr = conferenceDates.split("-")[1].strip() - endDate = datetime.strptime(endDateStr, "%d %b %Y") - # Check if the conference end date is greater than today - if endDate >= today: - conference = { - "name": name_match[1], - "url": valid_url, - "dates": dates_match[1], - "type": type_match[1], - "location": location_match[1], - "summary": summary_match[1], - "speaking": speaking_match[1] if speaking_match else "", - } - conferences.append(conference) - -# Write the conferences to the _data/conferences.yml file -with conferences_path.open("w") as f: - yaml.dump(conferences, f) + +def get_open_issues() -> PaginatedList[Issue]: + repo = g.get_repo("BlackPythonDevs/blackpythondevs.github.io") + issues = repo.get_issues(state="open", labels=["conference"]) + return issues + + +def parse_conference_details(issue_body: str) -> dict | None: + # Extract fields from issue body + name_match = re.search( + r"Conference Name(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue_body + ) + url_match = re.search(r"URL(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue_body) + dates_match = re.search( + r"Conference Dates(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue_body + ) + type_match = re.search( + r"Conference Type(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue_body + ) + location_match = re.search( + r"Conference Location(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", issue_body + ) + summary_match = re.search( + r"Summary(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}", + issue_body, + re.DOTALL, + ) + speaking_match = re.search( + r"Speaking(?:\r\n|\n){2}(.*?)(?:\r\n|\n){2}### Code of Conduct(?:\r\n|\n){2}", + issue_body, + re.DOTALL, + ) + + # Set a default value of None for when the url field isn't as expected + valid_url = normalize_url() if not url_match else normalize_url(url_match[1]) + + if dates_match: + conferenceDates = dates_match[1] + # Parse the end date of the conference + endDateStr = conferenceDates.split("-")[1].strip() + endDate = datetime.strptime(endDateStr, "%d %b %Y") + # Check if the conference end date is greater than today + today = datetime.combine(datetime.now(), time()) + + if endDate >= today: + conference = { + "name": name_match[1], + "url": valid_url, + "dates": dates_match[1], + "type": type_match[1], + "location": location_match[1], + "summary": summary_match[1], + "speaking": speaking_match[1] if speaking_match else "", + } + return conference + return None + + +def normalize_url(url_match: str = None): + valid_url = None + # Ensure the url field is not blank and the url matches the regex + if url_match is not None and url_match.strip() != "": + # Parse the url and see if a scheme (`https`) is included in it + # If not, then prepend `https` to the url from the issue body + # This guards against the website thinking the passed in url is another page on https://blackpythondevs.com/ + parsed_url = urlparse(url_match) + if "http" not in parsed_url.scheme.casefold(): + valid_url = f"https://{url_match}" + else: + valid_url = url_match + return valid_url + + +def write_conferences_to_file(confs: list[dict]): + # Write the conferences to the _data/conferences.yml file + with conferences_path.open("w") as f: + yaml.dump(confs, f) + + +if __name__ == '__main__': + conferences = [] + + # Get open issues from repo + open_issues: PaginatedList[Issue] = get_open_issues() + + # Parse each conference issue so long as it has the "conference" label + for issue in open_issues: + if "conference" in [label.name for label in issue.labels]: + parsed_conf = parse_conference_details(issue_body=issue.body) + conferences.append(parsed_conf) + + write_conferences_to_file(conferences) From 3fd523610a44ff204c68f701f923cc8ae1546ecc Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Fri, 30 Aug 2024 18:46:00 -0400 Subject: [PATCH 03/12] Run pre-commit linters --- _conferences/__main__.py | 2 +- tests/test.py | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/_conferences/__main__.py b/_conferences/__main__.py index 5540445..89cc402 100644 --- a/_conferences/__main__.py +++ b/_conferences/__main__.py @@ -95,7 +95,7 @@ def write_conferences_to_file(confs: list[dict]): yaml.dump(confs, f) -if __name__ == '__main__': +if __name__ == "__main__": conferences = [] # Get open issues from repo diff --git a/tests/test.py b/tests/test.py index c3c8023..d599431 100644 --- a/tests/test.py +++ b/tests/test.py @@ -15,8 +15,8 @@ @pytest.mark.parametrize("url", routes) def test_destination( - page: Page, - url: str, + page: Page, + url: str, ) -> None: """Test that the destinations page loads with seeded data""" # Create a destination @@ -28,11 +28,11 @@ def test_destination( @pytest.mark.parametrize( "title, url", ( - ("Acerca de", "/es/about/"), - ("Inicio", "/es/"), - ("Eventos", "/es/events/"), - ("Comunidad", "/es/community/"), - ("Conferencias", "/es/conferences/"), + ("Acerca de", "/es/about/"), + ("Inicio", "/es/"), + ("Eventos", "/es/events/"), + ("Comunidad", "/es/community/"), + ("Conferencias", "/es/conferences/"), ), ) def test_headers_in_language(page: Page, title: str, url: str) -> None: @@ -57,11 +57,11 @@ def test_switching_lang_es_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Kutuhusu", "/sw/about/"), - ("Nyumbani", "/sw/"), - ("Matukio", "/sw/events/"), - ("Jumuiya", "/sw/community/"), - ("Mikutano", "/sw/conferences/"), + ("Kutuhusu", "/sw/about/"), + ("Nyumbani", "/sw/"), + ("Matukio", "/sw/events/"), + ("Jumuiya", "/sw/community/"), + ("Mikutano", "/sw/conferences/"), ), ) def test_headers_in_sw(page: Page, title: str, url: str) -> None: @@ -86,12 +86,12 @@ def test_switching_lang_sw_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Black Python Devs | Home", "/"), - ("Black Python Devs | Blog", "/blog"), - ("Black Python Devs | About Us", "/about/"), - ("Black Python Devs | Events", "/events/"), - ("Black Python Devs | Conferences", "/conferences/"), - ("Black Python Devs | Community", "/community/"), + ("Black Python Devs | Home", "/"), + ("Black Python Devs | Blog", "/blog"), + ("Black Python Devs | About Us", "/about/"), + ("Black Python Devs | Events", "/events/"), + ("Black Python Devs | Conferences", "/conferences/"), + ("Black Python Devs | Community", "/community/"), ), ) def test_bpdevs_title_en(page: Page, title: str, url: str) -> None: From 29bde6fa87ed36bf4e8cb0042fdb84ab8c5d790e Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 00:29:17 -0400 Subject: [PATCH 04/12] Only add to conference list if the conference details could actually be parse --- _conferences/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_conferences/__main__.py b/_conferences/__main__.py index 89cc402..790b790 100644 --- a/_conferences/__main__.py +++ b/_conferences/__main__.py @@ -105,6 +105,7 @@ def write_conferences_to_file(confs: list[dict]): for issue in open_issues: if "conference" in [label.name for label in issue.labels]: parsed_conf = parse_conference_details(issue_body=issue.body) - conferences.append(parsed_conf) + if parsed_conf: + conferences.append(parsed_conf) write_conferences_to_file(conferences) From 46bc982f6fc78b8c812e2be6dbf177543a483cee Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 09:05:28 -0400 Subject: [PATCH 05/12] Move gh token env var to function We don't always need to use the GITHUB_TOKEN during tests, so let's make it an explicit call if we need it --- _conferences/__main__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/_conferences/__main__.py b/_conferences/__main__.py index 790b790..ae2a8bf 100644 --- a/_conferences/__main__.py +++ b/_conferences/__main__.py @@ -9,16 +9,19 @@ from github.Issue import Issue from github.PaginatedList import PaginatedList -TOKEN = os.getenv("GITHUB_TOKEN", "") ROOT = Path(__file__).parent.parent conferences_path = ROOT / "_data/conferences.yml" -auth = Auth.Token(TOKEN) -g = Github(auth=auth) +def create_github_client(): + gh_token = os.getenv("GITHUB_TOKEN", "") + auth = Auth.Token(gh_token) + g = Github(auth=auth) + return g -def get_open_issues() -> PaginatedList[Issue]: - repo = g.get_repo("BlackPythonDevs/blackpythondevs.github.io") + +def get_open_issues(gh: Github) -> PaginatedList[Issue]: + repo = gh.get_repo("BlackPythonDevs/blackpythondevs.github.io") issues = repo.get_issues(state="open", labels=["conference"]) return issues @@ -98,8 +101,11 @@ def write_conferences_to_file(confs: list[dict]): if __name__ == "__main__": conferences = [] + # Create Github client object + gh_client = create_github_client() + # Get open issues from repo - open_issues: PaginatedList[Issue] = get_open_issues() + open_issues: PaginatedList[Issue] = get_open_issues(gh_client) # Parse each conference issue so long as it has the "conference" label for issue in open_issues: From 464f58979d96cf8fcb38d9d3caf54cd669fca287 Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 09:56:38 -0400 Subject: [PATCH 06/12] Add sleep command to playwright tests This should allow playwright to finish setting up before running tests --- .github/workflows/playwright.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 42849a7..ff0b875 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -31,5 +31,11 @@ jobs: bundler-cache: true - name: Jekyll detached and pytest run: | + # Start up local copy of site bundle exec jekyll serve --detach + + # Sleep for 10 secs to allow Jekyll to start + sleep 10 + + # Run tests python -m pytest From 2ff406d633401fa591008b7db4a6c5a3cd3a0328 Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 10:10:59 -0400 Subject: [PATCH 07/12] Add delay between each test to make CI tests more consistent --- tests/test.py | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/tests/test.py b/tests/test.py index d599431..8b36ed1 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,3 +1,5 @@ +import time + import pytest from playwright.sync_api import Page, expect @@ -12,11 +14,17 @@ ("events"), ] +# Add a delay to each test to help with playwright race conditions +@pytest.fixture(autouse=True) +def slow_down_tests(): + yield + time.sleep(2) + @pytest.mark.parametrize("url", routes) def test_destination( - page: Page, - url: str, + page: Page, + url: str, ) -> None: """Test that the destinations page loads with seeded data""" # Create a destination @@ -28,11 +36,11 @@ def test_destination( @pytest.mark.parametrize( "title, url", ( - ("Acerca de", "/es/about/"), - ("Inicio", "/es/"), - ("Eventos", "/es/events/"), - ("Comunidad", "/es/community/"), - ("Conferencias", "/es/conferences/"), + ("Acerca de", "/es/about/"), + ("Inicio", "/es/"), + ("Eventos", "/es/events/"), + ("Comunidad", "/es/community/"), + ("Conferencias", "/es/conferences/"), ), ) def test_headers_in_language(page: Page, title: str, url: str) -> None: @@ -57,11 +65,11 @@ def test_switching_lang_es_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Kutuhusu", "/sw/about/"), - ("Nyumbani", "/sw/"), - ("Matukio", "/sw/events/"), - ("Jumuiya", "/sw/community/"), - ("Mikutano", "/sw/conferences/"), + ("Kutuhusu", "/sw/about/"), + ("Nyumbani", "/sw/"), + ("Matukio", "/sw/events/"), + ("Jumuiya", "/sw/community/"), + ("Mikutano", "/sw/conferences/"), ), ) def test_headers_in_sw(page: Page, title: str, url: str) -> None: @@ -86,12 +94,12 @@ def test_switching_lang_sw_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Black Python Devs | Home", "/"), - ("Black Python Devs | Blog", "/blog"), - ("Black Python Devs | About Us", "/about/"), - ("Black Python Devs | Events", "/events/"), - ("Black Python Devs | Conferences", "/conferences/"), - ("Black Python Devs | Community", "/community/"), + ("Black Python Devs | Home", "/"), + ("Black Python Devs | Blog", "/blog"), + ("Black Python Devs | About Us", "/about/"), + ("Black Python Devs | Events", "/events/"), + ("Black Python Devs | Conferences", "/conferences/"), + ("Black Python Devs | Community", "/community/"), ), ) def test_bpdevs_title_en(page: Page, title: str, url: str) -> None: From 6183797919ec37be67ce8826ad816e5a097fba0b Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 10:16:21 -0400 Subject: [PATCH 08/12] Linter fixes --- tests/test.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/tests/test.py b/tests/test.py index 8b36ed1..9239788 100644 --- a/tests/test.py +++ b/tests/test.py @@ -14,6 +14,7 @@ ("events"), ] + # Add a delay to each test to help with playwright race conditions @pytest.fixture(autouse=True) def slow_down_tests(): @@ -23,8 +24,8 @@ def slow_down_tests(): @pytest.mark.parametrize("url", routes) def test_destination( - page: Page, - url: str, + page: Page, + url: str, ) -> None: """Test that the destinations page loads with seeded data""" # Create a destination @@ -36,11 +37,11 @@ def test_destination( @pytest.mark.parametrize( "title, url", ( - ("Acerca de", "/es/about/"), - ("Inicio", "/es/"), - ("Eventos", "/es/events/"), - ("Comunidad", "/es/community/"), - ("Conferencias", "/es/conferences/"), + ("Acerca de", "/es/about/"), + ("Inicio", "/es/"), + ("Eventos", "/es/events/"), + ("Comunidad", "/es/community/"), + ("Conferencias", "/es/conferences/"), ), ) def test_headers_in_language(page: Page, title: str, url: str) -> None: @@ -65,11 +66,11 @@ def test_switching_lang_es_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Kutuhusu", "/sw/about/"), - ("Nyumbani", "/sw/"), - ("Matukio", "/sw/events/"), - ("Jumuiya", "/sw/community/"), - ("Mikutano", "/sw/conferences/"), + ("Kutuhusu", "/sw/about/"), + ("Nyumbani", "/sw/"), + ("Matukio", "/sw/events/"), + ("Jumuiya", "/sw/community/"), + ("Mikutano", "/sw/conferences/"), ), ) def test_headers_in_sw(page: Page, title: str, url: str) -> None: @@ -94,12 +95,12 @@ def test_switching_lang_sw_about(page: Page) -> None: @pytest.mark.parametrize( "title, url", ( - ("Black Python Devs | Home", "/"), - ("Black Python Devs | Blog", "/blog"), - ("Black Python Devs | About Us", "/about/"), - ("Black Python Devs | Events", "/events/"), - ("Black Python Devs | Conferences", "/conferences/"), - ("Black Python Devs | Community", "/community/"), + ("Black Python Devs | Home", "/"), + ("Black Python Devs | Blog", "/blog"), + ("Black Python Devs | About Us", "/about/"), + ("Black Python Devs | Events", "/events/"), + ("Black Python Devs | Conferences", "/conferences/"), + ("Black Python Devs | Community", "/community/"), ), ) def test_bpdevs_title_en(page: Page, title: str, url: str) -> None: From f27a37363d7e3a5e36b8a992c924b0359c47d4de Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 10:17:55 -0400 Subject: [PATCH 09/12] Reduce startup time so tests don't take as long to run --- .github/workflows/playwright.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ff0b875..29a543f 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -34,8 +34,10 @@ jobs: # Start up local copy of site bundle exec jekyll serve --detach - # Sleep for 10 secs to allow Jekyll to start - sleep 10 + # Sleep for 5 secs to allow Jekyll to start + startup_wait=5 + echo "Sleeping for $startup_wait seconds" + sleep $startup_wait # Run tests python -m pytest From 657b2fdd73000235f3369a86ce74a820046432c3 Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 10:28:05 -0400 Subject: [PATCH 10/12] Reduce delay between tests to 1 second --- tests/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.py b/tests/test.py index 9239788..b31a506 100644 --- a/tests/test.py +++ b/tests/test.py @@ -19,7 +19,7 @@ @pytest.fixture(autouse=True) def slow_down_tests(): yield - time.sleep(2) + time.sleep(1) @pytest.mark.parametrize("url", routes) From bb95b024107e43a7cc419b3431bf4e707d9d1669 Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 19:20:56 -0400 Subject: [PATCH 11/12] Update _conferences/__main__.py Co-authored-by: Jay Miller --- _conferences/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/_conferences/__main__.py b/_conferences/__main__.py index ae2a8bf..8dcad83 100644 --- a/_conferences/__main__.py +++ b/_conferences/__main__.py @@ -16,8 +16,9 @@ def create_github_client(): gh_token = os.getenv("GITHUB_TOKEN", "") auth = Auth.Token(gh_token) - g = Github(auth=auth) - return g + client = Github(auth=auth) + return client + def get_open_issues(gh: Github) -> PaginatedList[Issue]: From cd33ed6546a8f583d4c68d21fc19cf2b0bb4bfcb Mon Sep 17 00:00:00 2001 From: Alex Oladele Date: Sat, 31 Aug 2024 20:12:28 -0400 Subject: [PATCH 12/12] Fix linter issues --- _conferences/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/_conferences/__main__.py b/_conferences/__main__.py index 8dcad83..8aee6f6 100644 --- a/_conferences/__main__.py +++ b/_conferences/__main__.py @@ -20,7 +20,6 @@ def create_github_client(): return client - def get_open_issues(gh: Github) -> PaginatedList[Issue]: repo = gh.get_repo("BlackPythonDevs/blackpythondevs.github.io") issues = repo.get_issues(state="open", labels=["conference"])