FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.92k stars 218 forks source link

Fix failing tests and improve CI #327

Open oakkitten opened 2 years ago

oakkitten commented 2 years ago

This is more like a task to myself but I need some opinion.

Currently tests are broken for Anki <= 2.1.49 because of protobuf update. It got a major version bump and does not accept files created with some earlier versions of itself. Packages anki and aqt which we are getting from pypi do not pin their dependencies. A simple solution would be to pin protobuf, but a proper solution would be to pin all dependencies of anki/aqt.

I found two ways to do this:

Both methods work. I am not sure which one is better. Edit: actually I think the time machine method is better. requirements.txt seems to be rather rarely updated.


A wise one will ask, what is this stuff about prerelease versions? Well, I think the best we can do with CI is to have an early warning when Anki breaks the addon. For this reason we should update CI with new versions of Anki. This may include prerelease versions.

I set up a dependabot-like system that makes PRs with new Anki versions to be included into tox.ini and tests.yml. Like this for “stable” versions and like this for pre-release onse. I don't know if the latter is a good idea. Perhaps it would be easier to just run daily CI tests with it. But if Anki doesn't get updated for a while, we might want to test new changes against the latest pre-release, if any. I'm not sure. Setting this up will require making (an empty) GitHub app by the owner of the project! It's not hard but it's a bit of work.

Also I set up a tiny build system that compiles the .ankiaddon file and makes a release. It also edits the config.md to put the exact version of the addon in there. This way we can troubleshoot. It's only run for version tags:

image

Oh yeah, and the matrix.

Also I threw in a way to fast-forward merging of PRs via adding a label since GitHub doesn't support that.


I can make a PR with any subset of these but I want some opinion:

oakkitten commented 2 years ago

Oh, and if setting up a job to build .ankiaddon, it would be neat to use tags that start with v, for instance, v1.2.3, then you can say startsWith(github.ref, 'refs/tags/v'). This is not ideal, but better than detecting if it starts with a number. Of course you can say startsWith(github.ref, 'refs/tags/') but this is a tad too wide