You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run pytest in GitHub Actions on pull requests to master ✨ Enhancement⚙️ Configuration changes🧪 Tests🕐 10-20 Minutes
Description
• Trigger the GitHub Actions workflow on pull requests targeting master.
• Add a Python 3.11 setup step and install test dependencies.
• Run pytest in CI before the Docker build step.
Diagram
graph TD
A{{"Pull request to master"}} --> B["GitHub Actions workflow"] --> C["Setup Python 3.11"] --> D["Install deps"] --> E["Run pytest"] --> F["Docker build"]
subgraph Legend
direction LR
_evt{{"Event"}} ~~~ _job["Workflow/Job"] ~~~ _step["Step"]
end
Loading
High-Level Assessment
The following are alternative approaches to this PR:
1. Split CI into separate workflows (tests vs build/push)
➕ Avoids running Docker build/push logic on PRs if not needed
➕ Clearer separation of responsibilities and permissions (e.g., no registry creds on PRs)
➕ Faster feedback by running only tests on PRs
➖ More workflow files to maintain
➖ Requires some duplication (checkout/setup steps) unless using reusable workflows
2. Use a matrix for Python versions (e.g., 3.10/3.11/3.12)
➕ Catches compatibility issues earlier
➕ Future-proofs releases across supported runtimes
➖ Longer CI runtime and higher GitHub Actions usage
➖ May require dependency pinning fixes
Recommendation: Current approach is a solid incremental improvement (adds PR gating with pytest) and is appropriate if Docker build should still occur on PRs. If the intent is purely test gating (and to avoid privileged build/push steps on PRs), prefer splitting into a dedicated test workflow and keeping build/push limited to pushes/tags.
Files changed (1) +16 / -0
Other (1) +16 / -0
.github-ci.ymlTrigger workflow on PRs and run pytest with Python 3.11+16/-0
Trigger workflow on PRs and run pytest with Python 3.11
• Adds a pull_request trigger targeting master. Introduces steps to set up Python 3.11, install requirements plus pytest, and run pytest before the existing Docker build step.
1. Missing test dependencies✓ Resolved🐞 Bug≡ Correctness
Description
The workflow runs pytest after installing only requirements.txt and pytest, but the test suite
imports torch and pydantic, which are not listed in requirements.txt, so CI will fail during
test collection with ModuleNotFoundError. This makes the new PR test run non-functional as-is.
The workflow only installs requirements.txt plus pytest, but requirements.txt does not include
torch or pydantic, while the test files import them unconditionally. Therefore a clean CI runner
will fail on pytest collection due to missing modules.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
CI installs `requirements.txt` + `pytest` and then runs `pytest -q`, but the repository tests import `torch` and `pydantic`. Since those packages aren’t installed by the workflow (and aren’t in `requirements.txt`), pytest will error during import/collection.
## Issue Context
Several tests under `tests/` have unconditional imports of `torch` and `pydantic`.
## Fix Focus Areas
- Add missing runtime test dependencies (at minimum `torch` and `pydantic`) to an installed requirements set.
- Prefer introducing a `requirements-dev.txt` / `requirements-test.txt` and installing it in CI (instead of mixing dev/test deps into prod deps if that’s undesirable).
### Suggested implementation
- Create `requirements-test.txt` (or `requirements-dev.txt`) containing at least: `pytest`, `torch`, `pydantic`.
- Update workflow to run:
- `pip install -r requirements.txt -r requirements-test.txt`
- then `pytest -q`
## Fix Focus Areas (code pointers)
- .github/workflows/.github-ci.yml[17-29]
- requirements.txt[1-22]
- tests/test_batch_agg.py[1-4]
- tests/test_pooling.py[1-4]
- tests/test_longest_substring.py[1-4]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
2. PRs run Docker push✓ Resolved🐞 Bug⛨ Security
Description
Adding a pull_request trigger causes the existing Docker Hub login/push steps to run on PRs, which
will fail on forked PRs (secrets unavailable) and can publish unreviewed PR code to
dchou1618/pyeng:latest for same-repo PRs. This creates both CI reliability failures and a
supply-chain/release integrity risk.
The workflow is now configured to run on PRs, and the same job definition includes Docker Hub
authentication using secrets and a docker push to the :latest tag—so PR-triggered runs will
reach those deployment steps unless explicitly gated.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The workflow now triggers on `pull_request`, but the job still includes Docker Hub authentication and `docker push` to the `:latest` tag. This makes PR validation runs attempt deployment steps, which (a) fail on forked PRs due to missing secrets and (b) can publish unreviewed code to Docker Hub for same-repo PRs.
## Issue Context
The deployment steps already exist in the workflow; the PR adds the `pull_request` trigger, expanding when those steps execute.
## Fix Focus Areas
- Add an `if:` guard (or split jobs) so Docker login/push only runs on trusted events (e.g., `push` to `master`).
- Ensure PR runs only execute safe steps (checkout, install, test, build).
- Prefer `docker login --password-stdin` to avoid passing secrets via CLI args.
### Suggested implementation
- Add `if: github.event_name == 'push' && github.ref == 'refs/heads/master'` to **Authenticate** and **Push** steps, or move them into a separate job that only runs on push.
- Optionally tag images with `github.sha` and only update `latest` on push to `master`.
## Fix Focus Areas (code pointers)
- .github/workflows/.github-ci.yml[3-8]
- .github/workflows/.github-ci.yml[31-38]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.