Repository navigation
ci: install pytest in GitHub test workflow - #2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8f268cf7e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| pip install pytest | ||
|
|
||
| - name: Run tests | ||
| run: python -m pytest |
There was a problem hiding this comment.
Prevent workflow from failing when no tests exist
This job unconditionally runs python -m pytest, but in the current repository there are no Python test files, so pytest exits with code 5 (no tests ran) and the workflow fails on every push/PR even when nothing is wrong with the code. I verified this against the repo contents (no test*.py files) and by reproducing pytest’s behavior in an empty directory, so the new workflow as written is self-failing until tests are added or the command is made tolerant of empty suites.
Useful? React with 👍 / 👎.
Motivation
python -m pytestbutpytestwas not installed in the workflow environment.pytest(and optionally other test deps) in the workflow to ensure tests can run reliably.Description
.github/workflows/tests.ymlthat runs onpushandpull_request.testjob that usesubuntu-latestand sets up Python 3.11 withactions/setup-python@v5.Install dependenciesstep that upgrades pip and installspytest(python -m pip install --upgrade pipandpip install pytest).python -m pytestin a separateRun testsstep.Testing
.github/workflows/tests.ymland confirmed it contains the install and run steps as intended, which succeeded.git diff --checkandgit status --shortlocally, both succeeded with no issues detected.pytestbefore test execution.Codex Task