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

Run python unit tests in a github actions #2589

Merged

Conversation

yury-sannikov
Copy link
Contributor

hi @blakeblackshear

This is an alternative way of running Python unit tests with Pytest, keeping the old way of doing unit testing. It helps to run tests outside of the dev container.

This PR does:

  • add the tox support
  • add pytest runner and mock tflite and file system access
  • add github action to run python unit tests along with the UI tests on pull request
  • fix unit tests failures

The last point deserves your detailed review. The issue is how the create_ffmpeg_cmds() being called. I moved it under runtime_config property code, though I'm not sure what was your original intent.

@blakeblackshear
Copy link
Owner

My preference would be to build the container in the github workflow and run tests from there. I'm not it's really a valid "test" if the pip dependencies could be entirely different versions. It's probably fine for the existing unit tests around parsing the config, but I wouldn't trust it otherwise. I do want to eventually build and publish the containers from github actions, so it would be a step in that direction.

@yury-sannikov
Copy link
Contributor Author

Agree, building a docker image and running tests there would represent it better. What do you think would be the path forward for this PR?

@yury-sannikov
Copy link
Contributor Author

yury-sannikov commented Jan 5, 2022

What do you think about this?
image
https://github.com/yury-sannikov/frigate/pull/3/files#diff-a0fe23534b616d51ce686d2a1bcd1a78bc75074aef1a2f6ee96c9469991e1a4cR67

upd: actually added 3 platforms through buildx

@yury-sannikov
Copy link
Contributor Author

yury-sannikov commented Jan 5, 2022

@blakeblackshear as a bare minimum I would like to get your review on unit test fixes if possible. I'm blocked in my other PR by that since I'm touching the same code base and want to make sure I'm not breaking anything. Those are in the frigate/app.py and frigate/config.py

@blakeblackshear
Copy link
Owner

I would build the container and then execute the tests inside it rather than adding the tests to the dockerbuild. I haven't had a chance to look at this in detail yet.

@yury-sannikov
Copy link
Contributor Author

Hi @blakeblackshear, I made a Makefile command to run the docker build, which executes the unit test at the end. If tests fail, the build will also fail. I managed to reuse the same Dockerfile for each platform by sed-ing them in place.

this PR still contains the tox part to run tests on the local machine for folks like me. Do you think it makes sense to keep it or remove it?

@blakeblackshear
Copy link
Owner

I don't plan to maintain it, so I worry it will get out of date. Are you not using vscode with remote containers for development?

@yury-sannikov
Copy link
Contributor Author

I'm not using remote containers. I'm developing my Jetson Nano using VS Code Remote SSH. It seems it's not possible to use dev containers and remote SSH at the same time.
I think you're right, my use case is not pretty common. I removed tox & pytest setup from this PR.

@yury-sannikov
Copy link
Contributor Author

hi @blakeblackshear, do you have any plans of using pytest together with the unittest library? Parametrized tests with the unittest make test code pretty ugly.

@blakeblackshear
Copy link
Owner

I'm open to anything. Feel free to make a suggestion. I haven't invested heavily in writing tests as you can tell.

@yury-sannikov
Copy link
Contributor Author

@blakeblackshear I think I'm good. I just need your judgement on those changes to fix unit tests

@blakeblackshear blakeblackshear merged commit bd8e238 into blakeblackshear:release-0.10.0 Jan 14, 2022
blakeblackshear pushed a commit that referenced this pull request Feb 19, 2022
* tox tests initial commit

* run tests in the Dockerfile during the build phase

* remove local tests

Co-authored-by: YS <ys@gm.com>
NickM-27 pushed a commit to NickM-27/frigate that referenced this pull request Feb 20, 2022
* tox tests initial commit

* run tests in the Dockerfile during the build phase

* remove local tests

Co-authored-by: YS <ys@gm.com>
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.

2 participants