Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Add range of python version 3.8 to 3.13 for example tests #2065

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Nov 18, 2024

User description

Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.

Description

Range of support python versions will be tested in example tests

  • Stable version of [windows, macos, ubuntu] will be run with python 3.8, 3.9, 3.10
  • Nightly version of [windows, macos, ubuntu] will be run with python 3.11, 3.12, 3.13

Motivation and Context

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

PR Type

enhancement, configuration changes


Description

  • Updated the CI workflow to test a range of Python versions (3.8 to 3.13) across different operating systems and release types.
  • Increased the test timeout duration from 40 to 60 minutes to accommodate longer test runs.
  • Modified the test command to include pytest reruns for improved test reliability.
  • Added pytest-rerunfailures to the Python requirements to support test reruns.

Changes walkthrough 📝

Relevant files
Configuration changes
python-examples.yml
Update CI workflow to test multiple Python versions           

.github/workflows/python-examples.yml

  • Expanded the matrix strategy to include specific Python versions for
    different OS and release types.
  • Updated the Python setup to use the matrix-defined Python version.
  • Increased the test timeout from 40 to 60 minutes.
  • Added pytest reruns to the test command.
  • +22/-5   
    Enhancement
    requirements.txt
    Add pytest-rerunfailures to Python requirements                   

    examples/python/requirements.txt

    • Added pytest-rerunfailures to the requirements.
    +1/-0     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Test Coverage
    The matrix configuration only tests one Python version per OS/release combination. Consider adding more combinations to ensure broader test coverage.

    Resource Usage
    The combination of increased timeout (60 min), 3 retry attempts, and 3 pytest reruns could lead to very long running tests and excessive resource usage if tests are flaky.

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Add error tolerance for pre-release Python version testing to prevent workflow failures

    Consider adding a continue-on-error flag for Python 3.13 tests since it's a
    pre-release version that might be unstable.

    .github/workflows/python-examples.yml [44-46]

     - os: macos
       release: nightly
       python: '3.13'
    +  continue-on-error: true
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding continue-on-error for Python 3.13 tests is a crucial reliability improvement, as pre-release Python versions can be unstable and shouldn't block the entire workflow.

    8
    Possible issue
    Add timeout and verbosity settings to prevent test hangs and improve debugging

    Consider adding a maximum time limit for individual pytest reruns to prevent hanging
    tests.

    .github/workflows/python-examples.yml [104]

    -pytest --reruns 3
    +pytest --reruns 3 --reruns-delay 1 -v --timeout=300
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding timeout limits and verbosity flags is crucial for preventing indefinitely hanging tests and providing better debugging information when tests fail.

    8
    Enhancement
    Add delay between retry attempts to handle transient failures more effectively

    Consider adding a retry delay between test attempts to allow for transient issues to
    resolve.

    .github/workflows/python-examples.yml [97-101]

     - name: Run tests
       uses: nick-invision/[email protected]
       with:
         timeout_minutes: 60
         max_attempts: 3
    +    retry_wait_seconds: 30
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding retry_wait_seconds is a valuable enhancement that can help resolve transient issues by allowing system recovery time between attempts, improving test reliability.

    7

    💡 Need additional feedback ? start a PR chat

    Copy link

    netlify bot commented Nov 18, 2024

    Deploy Preview for selenium-dev ready!

    Name Link
    🔨 Latest commit dfa7d8a
    🔍 Latest deploy log https://app.netlify.com/sites/selenium-dev/deploys/673b20b8efe08c0008b94e28
    😎 Deploy Preview https://deploy-preview-2065--selenium-dev.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    Copy link
    Contributor

    codiumai-pr-agent-pro bot commented Nov 18, 2024

    CI Failure Feedback 🧐

    (Checks updated until commit dfa7d8a)

    Action: tests (macos, stable, 3.10)

    Failed stage: Run tests [❌]

    Failed test name: test_basic_options

    Failure summary:

    The action failed due to two test failures in the file tests/browsers/test_safari.py:

  • test_basic_options failed because the SafariRemoteConnection.init() method was called without
    the required positional argument remote_server_addr.
  • test_enable_logging also failed for the same reason as test_basic_options, missing the
    remote_server_addr argument in the SafariRemoteConnection.init() method.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  macOS
    ...
    
    283:  timeout_minutes: 60
    284:  max_attempts: 3
    285:  command: cd examples/python
    286:  pytest --reruns 3
    287:  
    288:  retry_wait_seconds: 10
    289:  polling_interval_seconds: 1
    290:  warning_on_retry: true
    291:  continue_on_error: false
    ...
    
    328:  tests/elements/test_file_upload.py .                                     [ 78%]
    329:  tests/interactions/test_alerts.py ...                                    [ 80%]
    330:  tests/interactions/test_print_options.py .......                         [ 85%]
    331:  tests/interactions/test_prints_page.py .                                 [ 86%]
    332:  tests/interactions/test_virtual_authenticator.py ..........              [ 93%]
    333:  tests/support/test_select_list.py ...                                    [ 95%]
    334:  tests/troubleshooting/test_logging.py .                                  [ 96%]
    335:  tests/waits/test_waits.py .....                                          [100%]
    336:  =================================== FAILURES ===================================
    337:  ______________________________ test_basic_options ______________________________
    338:  @pytest.mark.skipif(sys.platform != "darwin", reason="requires Mac")
    339:  def test_basic_options():
    340:  options = webdriver.SafariOptions()
    341:  >       driver = webdriver.Safari(options=options)
    342:  tests/browsers/test_safari.py:10: 
    343:  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    344:  self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x103af8d90>
    ...
    
    364:  self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
    365:  if not self.service.reuse_service:
    366:  self.service.start()
    367:  client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
    368:  >       executor = SafariRemoteConnection(
    369:  ignore_proxy=options._ignore_local_proxy,
    370:  client_config=client_config,
    371:  )
    372:  E       TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    373:  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/safari/webdriver.py:55: TypeError
    374:  _____________________________ test_enable_logging ______________________________
    375:  @pytest.mark.skipif(sys.platform != "darwin", reason="requires Mac")
    376:  def test_enable_logging():
    377:  service = webdriver.SafariService(service_args=["--diagnose"])
    378:  >       driver = webdriver.Safari(service=service)
    379:  tests/browsers/test_safari.py:19: 
    380:  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    381:  self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x103afb7c0>
    ...
    
    401:  self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
    402:  if not self.service.reuse_service:
    403:  self.service.start()
    404:  client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
    405:  >       executor = SafariRemoteConnection(
    406:  ignore_proxy=options._ignore_local_proxy,
    407:  client_config=client_config,
    408:  )
    409:  E       TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    410:  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/safari/webdriver.py:55: TypeError
    ...
    
    418:  tests/bidi/test_bidi_logging.py:30
    419:  /Users/runner/work/seleniumhq.github.io/seleniumhq.github.io/examples/python/tests/bidi/test_bidi_logging.py:30: PytestUnknownMarkWarning: Unknown pytest.mark.driver_type - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    420:  @pytest.mark.driver_type("bidi")
    421:  tests/bidi/test_bidi_logging.py:42
    422:  /Users/runner/work/seleniumhq.github.io/seleniumhq.github.io/examples/python/tests/bidi/test_bidi_logging.py:42: PytestUnknownMarkWarning: Unknown pytest.mark.driver_type - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    423:  @pytest.mark.driver_type("bidi")
    424:  -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
    425:  =========================== short test summary info ============================
    426:  FAILED tests/browsers/test_safari.py::test_basic_options - TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    427:  FAILED tests/browsers/test_safari.py::test_enable_logging - TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    428:  == 2 failed, 130 passed, 7 skipped, 4 warnings, 7 rerun in 506.90s (0:08:26) ===
    429:  ##[warning]Attempt 1 failed. Reason: Child_process exited with error code 1
    ...
    
    454:  tests/elements/test_file_upload.py .                                     [ 78%]
    455:  tests/interactions/test_alerts.py ...                                    [ 80%]
    456:  tests/interactions/test_print_options.py .......                         [ 85%]
    457:  tests/interactions/test_prints_page.py .                                 [ 86%]
    458:  tests/interactions/test_virtual_authenticator.py ..........              [ 93%]
    459:  tests/support/test_select_list.py ...                                    [ 95%]
    460:  tests/troubleshooting/test_logging.py .                                  [ 96%]
    461:  tests/waits/test_waits.py .....                                          [100%]
    462:  =================================== FAILURES ===================================
    463:  ______________________________ test_basic_options ______________________________
    464:  @pytest.mark.skipif(sys.platform != "darwin", reason="requires Mac")
    465:  def test_basic_options():
    466:  options = webdriver.SafariOptions()
    467:  >       driver = webdriver.Safari(options=options)
    468:  tests/browsers/test_safari.py:10: 
    469:  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    470:  self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x10343db40>
    ...
    
    490:  self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
    491:  if not self.service.reuse_service:
    492:  self.service.start()
    493:  client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
    494:  >       executor = SafariRemoteConnection(
    495:  ignore_proxy=options._ignore_local_proxy,
    496:  client_config=client_config,
    497:  )
    498:  E       TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    499:  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/safari/webdriver.py:55: TypeError
    500:  _____________________________ test_enable_logging ______________________________
    501:  @pytest.mark.skipif(sys.platform != "darwin", reason="requires Mac")
    502:  def test_enable_logging():
    503:  service = webdriver.SafariService(service_args=["--diagnose"])
    504:  >       driver = webdriver.Safari(service=service)
    505:  tests/browsers/test_safari.py:19: 
    506:  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    507:  self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x10343fee0>
    ...
    
    527:  self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
    528:  if not self.service.reuse_service:
    529:  self.service.start()
    530:  client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
    531:  >       executor = SafariRemoteConnection(
    532:  ignore_proxy=options._ignore_local_proxy,
    533:  client_config=client_config,
    534:  )
    535:  E       TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    536:  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/safari/webdriver.py:55: TypeError
    ...
    
    544:  tests/bidi/test_bidi_logging.py:30
    545:  /Users/runner/work/seleniumhq.github.io/seleniumhq.github.io/examples/python/tests/bidi/test_bidi_logging.py:30: PytestUnknownMarkWarning: Unknown pytest.mark.driver_type - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    546:  @pytest.mark.driver_type("bidi")
    547:  tests/bidi/test_bidi_logging.py:42
    548:  /Users/runner/work/seleniumhq.github.io/seleniumhq.github.io/examples/python/tests/bidi/test_bidi_logging.py:42: PytestUnknownMarkWarning: Unknown pytest.mark.driver_type - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    549:  @pytest.mark.driver_type("bidi")
    550:  -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
    551:  =========================== short test summary info ============================
    552:  FAILED tests/browsers/test_safari.py::test_basic_options - TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    553:  FAILED tests/browsers/test_safari.py::test_enable_logging - TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    554:  == 2 failed, 130 passed, 7 skipped, 4 warnings, 8 rerun in 786.58s (0:13:06) ===
    555:  ##[warning]Attempt 2 failed. Reason: Child_process exited with error code 1
    ...
    
    580:  tests/elements/test_file_upload.py .                                     [ 78%]
    581:  tests/interactions/test_alerts.py ...                                    [ 80%]
    582:  tests/interactions/test_print_options.py .......                         [ 85%]
    583:  tests/interactions/test_prints_page.py .                                 [ 86%]
    584:  tests/interactions/test_virtual_authenticator.py ..........              [ 93%]
    585:  tests/support/test_select_list.py ...                                    [ 95%]
    586:  tests/troubleshooting/test_logging.py .                                  [ 96%]
    587:  tests/waits/test_waits.py .....                                          [100%]
    588:  =================================== FAILURES ===================================
    589:  ______________________________ test_basic_options ______________________________
    590:  @pytest.mark.skipif(sys.platform != "darwin", reason="requires Mac")
    591:  def test_basic_options():
    592:  options = webdriver.SafariOptions()
    593:  >       driver = webdriver.Safari(options=options)
    594:  tests/browsers/test_safari.py:10: 
    595:  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    596:  self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x1029cb9a0>
    ...
    
    616:  self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
    617:  if not self.service.reuse_service:
    618:  self.service.start()
    619:  client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
    620:  >       executor = SafariRemoteConnection(
    621:  ignore_proxy=options._ignore_local_proxy,
    622:  client_config=client_config,
    623:  )
    624:  E       TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    625:  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/safari/webdriver.py:55: TypeError
    626:  _____________________________ test_enable_logging ______________________________
    627:  @pytest.mark.skipif(sys.platform != "darwin", reason="requires Mac")
    628:  def test_enable_logging():
    629:  service = webdriver.SafariService(service_args=["--diagnose"])
    630:  >       driver = webdriver.Safari(service=service)
    631:  tests/browsers/test_safari.py:19: 
    632:  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    633:  self = <[AttributeError("'WebDriver' object has no attribute 'session_id'") raised in repr()] WebDriver object at 0x1030ea4a0>
    ...
    
    653:  self.service.path = self.service.env_path() or DriverFinder(self.service, options).get_driver_path()
    654:  if not self.service.reuse_service:
    655:  self.service.start()
    656:  client_config = ClientConfig(remote_server_addr=self.service.service_url, keep_alive=keep_alive, timeout=120)
    657:  >       executor = SafariRemoteConnection(
    658:  ignore_proxy=options._ignore_local_proxy,
    659:  client_config=client_config,
    660:  )
    661:  E       TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    662:  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/safari/webdriver.py:55: TypeError
    ...
    
    670:  tests/bidi/test_bidi_logging.py:30
    671:  /Users/runner/work/seleniumhq.github.io/seleniumhq.github.io/examples/python/tests/bidi/test_bidi_logging.py:30: PytestUnknownMarkWarning: Unknown pytest.mark.driver_type - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    672:  @pytest.mark.driver_type("bidi")
    673:  tests/bidi/test_bidi_logging.py:42
    674:  /Users/runner/work/seleniumhq.github.io/seleniumhq.github.io/examples/python/tests/bidi/test_bidi_logging.py:42: PytestUnknownMarkWarning: Unknown pytest.mark.driver_type - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    675:  @pytest.mark.driver_type("bidi")
    676:  -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
    677:  =========================== short test summary info ============================
    678:  FAILED tests/browsers/test_safari.py::test_basic_options - TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    679:  FAILED tests/browsers/test_safari.py::test_enable_logging - TypeError: SafariRemoteConnection.__init__() missing 1 required positional argument: 'remote_server_addr'
    680:  == 2 failed, 130 passed, 7 skipped, 4 warnings, 6 rerun in 561.68s (0:09:21) ===
    681:  ##[error]Final attempt failed. Child_process exited with error code 1
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    @VietND96 VietND96 merged commit 9c3d182 into trunk Nov 18, 2024
    16 of 18 checks passed
    @VietND96 VietND96 deleted the py-version branch November 18, 2024 13:57
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant