Skip to content

update ci to run tests - #35

Merged
dchou1618 merged 5 commits into
masterfrom
feature/update_ci
Jun 19, 2026
Merged

dchou1618 merged 5 commits into
masterfrom
feature/update_ci

Conversation

@dchou1618

Copy link
Copy Markdown
Owner

No description provided.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Run pytest in GitHub Actions on pull requests to master
✨ Enhancement ⚙️ Configuration changes 🧪 Tests 🕐 10-20 Minutes

Grey Divider

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.

.github/workflows/.github-ci.yml

@qodo-code-review

qodo-code-review Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

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.
Code

.github/workflows/.github-ci.yml[R17-29]

+      - name: Set up Python
+        uses: actions/setup-python@v5
+        with:
+          python-version: "3.11"
+
+      - name: Install dependencies
+        run: |
+          pip install --upgrade pip
+          pip install -r requirements.txt
+          pip install pytest
+
+      - name: Run tests
+        run: pytest -q
Evidence
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.

.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]

Agent prompt
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.
Code

.github/workflows/.github-ci.yml[R6-7]

+  pull_request:
+    branches: [ master ]
Evidence
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.

.github/workflows/.github-ci.yml[3-8]
.github/workflows/.github-ci.yml[31-38]

Agent prompt
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


Grey Divider

Qodo Logo

Comment thread .github/workflows/.github-ci.yml Outdated
Comment thread .github/workflows/.github-ci.yml Outdated
Comment on lines +11 to +32
name: Run Tests (CI)
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install pytest

- name: Run tests
run: pytest -q

build_and_push:
Comment thread .github/workflows/cicd.yml Fixed
@dchou1618 dchou1618 self-assigned this Jun 19, 2026
@dchou1618
dchou1618 merged commit b63bf15 into master Jun 19, 2026
5 checks passed
@dchou1618
dchou1618 deleted the feature/update_ci branch June 19, 2026 19:15
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