-
Notifications
You must be signed in to change notification settings - Fork 33
ci: verify the solution is correct #38
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
Conversation
Signed-off-by: Frost Ming <me@frostming.com>
519235c
to
7611fcb
Compare
Signed-off-by: Frost Ming <me@frostming.com>
CHALLENGES_DIR = Path(__file__).parent.parent / "challenges" | ||
ALL_SOLUTIONS = list(CHALLENGES_DIR.glob("**/solution.py")) | ||
|
||
|
||
@pytest.mark.parametrize("solution_file", ALL_SOLUTIONS, ids=lambda x: x.parent.name) | ||
def test_solution_valid(solution_file: Path): | ||
with solution_file.open() as f: | ||
code = f.read() | ||
result = ChallengeManager._type_check_with_pyright(code) | ||
assert result.passed, result.stdout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should test these cases in parallel to reduce the total time of CI. How about pytest-xdist? 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you go
Signed-off-by: Frost Ming <me@frostming.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
with solution_file.open() as f: | ||
code = f.read() | ||
result = ChallengeManager._type_check_with_pyright(code) | ||
assert result.passed, result.stdout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, is there a need to assert result.stdout
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will give the typecheck output when the test fails, which helps up debug the solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, makes sense.
Thanks, I always wanted to add this but don't have time. Overall LGTM. Some new solutions were just added, do you mind do a pull and test them? Appreciate it! |
You can rebase the main onto the pull requests after this is merged. New solutions will be automatically picked up for CI, and the author will know the status. |
I mean they've been added to the codebase but let me merge this and run it myself. |
Signed-off-by: Frost Ming me@frostming.com