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 fixes and updates #454

Closed
wants to merge 3 commits into from
Closed

Conversation

Lord-Kamina
Copy link
Contributor

This branch updates the CI stack a bit in different ways.

  1. It updates the workflow version of several actions that were crying due to Node 16 actions being deprecated.
  2. It adds builds newer versions of python, so now it's built on 3.7, 3.9 and 3.10 (not using newer versions due to unavailability of newer libtorrent wheels on pypi)
  3. Uses an updated gvsbuild-release for newer python versions.
  4. Fixes console tests on test_ui_entry.py hanging, which allows us to unpin the pytest version used.

Notes:

@cas--
Copy link
Member

cas-- commented Aug 26, 2024

I'm afraid there are too many changes here and not enough details in the commits about why the change is required. If possible, can you split these up into more concise PRs it will help reviewing and merging

@Lord-Kamina Lord-Kamina force-pushed the ci_fixes branch 2 times, most recently from 1e247aa to 4e1acbe Compare September 2, 2024 14:44
@Lord-Kamina
Copy link
Contributor Author

I'm afraid there are too many changes here and not enough details in the commits about why the change is required. If possible, can you split these up into more concise PRs it will help reviewing and merging

I hadn't seen this comment, sorry for not answering before.

I'd rather not split it (although it IS true that there are some not-strictly related things here) because then we'll never get it merged. However, I'm more than happy to amend commit messages and/or explain why I've made each change.

from twisted.internet.error import ReactorAlreadyInstalledError
from twisted.internet.task import LoopingCall

try:
# Install twisted reactor, before any other modules import reactor.
reactor = gtk3reactor.install()
reactor = gireactor.install()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to avoid using a deprecated class name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We support a minimum version of Twisted and afaik this would break that so needs to be reverted, I don't think they are actually removing it anytime soon. We could add a Twisted version check for the import but would need a comment to explain why gireactor is being used since the Twisted docs are now contradictory about not using it for UI.

Copy link
Contributor Author

@Lord-Kamina Lord-Kamina Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it though? the current requirement spec is:

twisted[tls]>=17.1; sys_platform != 'win32'
twisted[tls]<23,>=17.1; sys_platform == 'win32'

And the Twisted api documentation for 16.4.1, a full major version earlier (https://twisted.org/documents/16.4.1/api/twisted.internet.gireactor.html), already has the gireactor, with an API that I think is identical?

@@ -1,4 +1,4 @@
-r requirements.txt
-r requirements-tests.txt
libtorrent==2.0.7
pytest==7.4.2
pytest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, pytest is pinned due to console tests failing, which is fixed by this PR.

libtorrent==2.0.7
pytest==7.4.2
pytest
libtorrent<2.0.9
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libtorrent is pinned also due to a test failure, but the change was introduced in 2.0.9. We should eventually fix our test rather than keep pinning, but we can still update libtorrent even if just a bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are pinned to avoid breaking the CI over time so can be version bumped but must still be pinned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are pinned to avoid breaking the CI over time so can be version bumped but must still be pinned

For now, I'm happy to change it to libtorrent==2.0.8, but I think there's a discussion to be had about this (not in the context of this PR): I can understand the desire for the CI to not break easily, especially if you have little time as-is, but IMO a CI shouldn't easily break (if at all) due to a dependency publishing new bug-fix level releases.

You're pinned to a two-year old version of what is quite probably your most important dependency. There has to be a better way to approach it (I have a few different ideas, but I don't really know where is the best place to start a discussion such as this?)

@@ -76,7 +76,7 @@ def test_set_config(self):
assert config['pwd_sha1'] != web_config['pwd_sha1']
assert config['sessions'] != web_config['sessions']

@defer.inlineCallbacks
@pytest_twisted.inlineCallbacks
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are due to the pytest developers recommending that twisted not be used directly in tests with fixtures. From the pytest-twisted docs:

Using twisted.internet.defer.inlineCallbacks as a decorator for test functions, which use fixtures, does not work. Please use pytest_twisted.inlineCallbacks instead.

def test_console_command_config_set_download_location(self):
fd = StringFileDescriptor(sys.stdout)
self.patch_arg_command(['config --set download_location /downloads'])
self.patch(sys, 'stdout', fd)

yield self.exec_command()
with mock.patch('deluge.ui.console.main.ConsoleUI.quit', autospec=True):
Copy link
Contributor Author

@Lord-Kamina Lord-Kamina Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was calling the real ConsoleUI.quit(), which was stopping the reactor and thus making the tests go boom.

@@ -174,7 +174,7 @@ def handle_alerts(self):
d = task.deferLater(reactor, 0, handler, alert)
on_handler_timeout = partial(
self.on_delayed_call_timeout,
handler=handler.__qualname__,
handler=handler.__class__.__qualname__,
Copy link
Contributor Author

@Lord-Kamina Lord-Kamina Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flat-out produces an error, because __qualname__ is an attribute that classes (not their instances) have.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does it raise an error? Handlers are functions or methods not class instances so handle.__class__.__qualname__ does not make seem to make sense here?

Copy link
Contributor Author

@Lord-Kamina Lord-Kamina Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does it raise an error? Handlers are functions or methods not class instances so handle.__class__.__qualname__ does not make seem to make sense here?

See this log, for an example:

https://github.com/Lord-Kamina/deluge/actions/runs/10050873417/job/27779525108

EDIT (copied the error here for ease):

deluge/tests/test_alertmanager.py::TestAlertManager::test_pop_alert
  /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/_pytest/threadexception.py:82: PytestUnhandledThreadExceptionWarning: Exception in thread alert-poller
  
  Traceback (most recent call last):
    File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
      self.run()
    File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/threading.py", line 953, in run
      self._target(*self._args, **self._kwargs)
    File "/home/runner/work/deluge/deluge/deluge/core/alertmanager.py", line 93, in wait_for_alert_in_thread
      threads.blockingCallFromThread(reactor, self.maybe_handle_alerts)
    File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/twisted/internet/threads.py", line 135, in blockingCallFromThread
      result.raiseException()
    File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/twisted/python/failure.py", line 505, in raiseException
      raise self.value.with_traceback(self.tb)
    File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/twisted/internet/defer.py", line 212, in maybeDeferred
      result = f(*args, **kwargs)
    File "/home/runner/work/deluge/deluge/deluge/core/alertmanager.py", line 113, in maybe_handle_alerts
      self.handle_alerts()
    File "/home/runner/work/deluge/deluge/deluge/core/alertmanager.py", line 177, in handle_alerts
      handler=handler.__qualname__,
    File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/unittest/mock.py", line 645, in __getattr__
      raise AttributeError(name)
  AttributeError: __qualname__

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although now... reading that again, it might be an issue specific to running the tests.

Copy link
Contributor Author

@Lord-Kamina Lord-Kamina Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cas-- I have reverted that change and implemented a proper fix in the actual test now.

@Lord-Kamina
Copy link
Contributor Author

@cas-- Using libtorrent==2.0.8fails because for some reason that version is missing from pip. I think that's why I had done <2.0.9

@zakkarry
Copy link
Contributor

zakkarry commented Sep 6, 2024

@cas-- Using libtorrent==2.0.8fails because for some reason that version is missing from pip. I think that's why I had done <2.0.9

The publishing to pip seems to be intermittent, I've made an issue on libtorrent a little over a week ago about pip builds, but I haven't seen any update. There is a open PR that seems to address some of the builds/CI for libtorrent, but I'm not sure if this directly address this concern.

You can see my issue and the linked PR here

@DjLegolas
Copy link
Contributor

@zakkarry there were several issues with the pypi publish process for libtorrent...
i hope the fixes will work on the next release, as py3.13 is about to be released

@Lord-Kamina please revert the change to Install GTK step as it will always fail until we have a newer release for it.

@zakkarry
Copy link
Contributor

zakkarry commented Sep 6, 2024

@zakkarry there were several issues with the pypi publish process for libtorrent... i hope the fixes will work on the next release, as py3.13 is about to be released

@Lord-Kamina please revert the change to Install GTK step as it will always fail until we have a newer release for it.

As I've found out recently heh.

A user on the forums was asking about 3.13 support, and I told him to make an issue or PR, and he made #462 for it - it's failing some tests though it seems.

@Lord-Kamina
Copy link
Contributor Author

@zakkarry there were several issues with the pypi publish process for libtorrent...

i hope the fixes will work on the next release, as py3.13 is about to be released

@Lord-Kamina please revert the change to Install GTK step as it will always fail until we have a newer release for it.

The change to gvsbuild-release was already commited, all that's missing is for the workflow to run, which is only on a manual trigger. However, that would break the current CI. The idea would be to run it just before this PR is ready to be merged.

@Lord-Kamina
Copy link
Contributor Author

@cas-- Using libtorrent==2.0.8fails because for some reason that version is missing from pip. I think that's why I had done <2.0.9

The publishing to pip seems to be intermittent, I've made an issue on libtorrent a little over a week ago about pip builds, but I haven't seen any update. There is a open PR that seems to address some of the builds/CI for libtorrent, but I'm not sure if this directly address this concern.

You can see my issue and the linked PR here

I know and I was inquiring about it as well a while ago. Thing is, even if that's fixed, I doubt we'll get retroactive releases for an old version, so the point stands in that we need to be able to 1) update libtorrent and 2) have at least some CI workflow that fails anf alerts us when newer versions break, because else we're putting ourselves in the same position the folks at twisted did, which is essentially forgetting it's an issue.

Of course, I'm willing to help however I can but I have essentially no experience working with libtorrent so I'm not sure that really amounts to much.

What do you think @DjLegolas?

@Lord-Kamina Lord-Kamina force-pushed the ci_fixes branch 3 times, most recently from 76c9772 to a26d731 Compare September 8, 2024 00:34
@Lord-Kamina
Copy link
Contributor Author

@zakkarry there were several issues with the pypi publish process for libtorrent... i hope the fixes will work on the next release, as py3.13 is about to be released
@Lord-Kamina please revert the change to Install GTK step as it will always fail until we have a newer release for it.

As I've found out recently heh.

A user on the forums was asking about 3.13 support, and I told him to make an issue or PR, and he made #462 for it - it's failing some tests though it seems.

I don't think that's at all related?
What was merged (and still is not really reflecting anywhere) is a change in the way gvsbuild is built for newer releases to be used in Deluge.

@zakkarry
Copy link
Contributor

zakkarry commented Sep 8, 2024

I wasn't saying it was related necessarily, but you mentioned 3.13, so I informed you of a relevant PR to the version, that's all.

Clarified a little what this commit actually does.
@Lord-Kamina
Copy link
Contributor Author

Closing this as per #466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants