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

Make sure pytest actually fails CI on windows #780

Merged
merged 3 commits into from
Oct 5, 2023

Conversation

nwithan8
Copy link
Contributor

@nwithan8 nwithan8 commented Oct 3, 2023

For whatever reason, the error code from coverage run is not surfacing to the Windows runner, and therefore the CI is passing despite several unit tests failing.

Using pytest directly does surface the proper error code and halt CI if any tests fail, so that has been added as a step.

coverage run is still executed, after pytest, to generate the necessary information needed for coverage xml and coverage report. Because pytest runs first, the false-negative tests in coverage run will never be encountered.

This fails as expected:
image

Closes #777

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #780 (79099bc) into master (4ae2ffe) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #780   +/-   ##
=======================================
  Coverage   21.51%   21.51%           
=======================================
  Files          63       63           
  Lines        8542     8542           
  Branches     1572     1572           
=======================================
  Hits         1838     1838           
- Misses       6680     6682    +2     
+ Partials       24       22    -2     

see 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@oddstr13
Copy link
Member

oddstr13 commented Oct 3, 2023

I think it would be worth testing whether coverage run in a separate step properly fails the test
(are tests on windows only failing based on the exit code of the last command?)

Copy link
Member

@oddstr13 oddstr13 left a comment

Choose a reason for hiding this comment

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

Looks like my suspicion about only last command's exit code being used is likely correct, see nedbat/coveragepy#1003 and https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference

For now, just move coverage run to a separate step, naming it Run tests and collect coverage, and rename the existing one Generate coverage reports.

That should fix pytest not erroring (via coverage) on Windows.


We likely have similar issues all over CI, but that can be fixed properly in a separate PR, preferably by having multi-line test steps error out properly.

@oddstr13 oddstr13 added the ci label Oct 4, 2023
@oddstr13
Copy link
Member

oddstr13 commented Oct 4, 2023

It is also possible, but not guaranteed that explicitly setting shell: bash on the run step(s) fixes the issue.

@nwithan8
Copy link
Contributor Author

nwithan8 commented Oct 4, 2023

It is also possible, but not guaranteed that explicitly setting shell: bash on the run step(s) fixes the issue.

I don't believe that would work, trying to run a Bash shell on a Windows machine.

@nwithan8
Copy link
Contributor Author

nwithan8 commented Oct 4, 2023

Looks like my suspicion about only last command's exit code being used is likely correct, see nedbat/coveragepy#1003 and https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference

For now, just move coverage run to a separate step, naming it Run tests and collect coverage, and rename the existing one Generate coverage reports.

That should fix pytest not erroring (via coverage) on Windows.

We likely have similar issues all over CI, but that can be fixed properly in a separate PR, preferably by having multi-line test steps error out properly.

Better Google-fu than me!

@oddstr13
Copy link
Member

oddstr13 commented Oct 4, 2023

It is also possible, but not guaranteed that explicitly setting shell: bash on the run step(s) fixes the issue.

I don't believe that would work, trying to run a Bash shell on a Windows machine.

That shouldn't be a problem, as git is available (which depend on and include bash), and possibly also msys2/mingw (see actions/runner#497)

Your current change should be fine tho, but the xml and report steps should be in the same steps, as I don't expect either of those to ever fail

@oddstr13 oddstr13 changed the title - Add pytest to test CI Make sure pytest actually fails CI on windows Oct 4, 2023
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@oddstr13 oddstr13 merged commit 099a319 into jellyfin:master Oct 5, 2023
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytest on windows does not actually fail the CI run on errors
2 participants