-
Notifications
You must be signed in to change notification settings - Fork 1
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
DM-45314: add workflow for pytest #30
Changes from all commits
5c84b18
a2e7579
34ed60b
2b92bf5
499cbb9
a80e9cf
ba1cf1b
a5919e3
166d7db
25de2c2
2aa69a3
ccd6987
13f8274
fb8b28c
bb38146
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Run PyTest | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
run_pytest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
cache: "pip" | ||
|
||
- name: Editable mode install | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may want to consider separating the install of dependencies from the editable install of the package. |
||
run: | | ||
python -m pip install uv | ||
uv pip install --system pytest pytest-cov pytest-html | ||
uv pip install --system -e . | ||
- name: Test with pytest | ||
run: | | ||
pytest --cov=./ --cov-report=html --html=pytest_report.html --self-contained-html | ||
|
||
- name: Upload test report | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change to using codecov as discussed. I've added the secret to the repo. Example code at https://github.com/lsst/daf_butler/blob/main/.github/workflows/build.yaml#L92-L98 |
||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: pytest_report | ||
path: pytest_report.html | ||
|
||
- name: Upload coverage report | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage_report | ||
path: htmlcov | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
FROM python:3.11 | ||
RUN pip install flask gunicorn sqlalchemy psycopg2 | ||
WORKDIR /consdb-pq | ||
COPY python/lsst/consdb/pqserver.py python/lsst/consdb/utils.py /consdb-pq/ | ||
WORKDIR / | ||
COPY python/lsst/consdb/__init__.py python/lsst/consdb/pqserver.py python/lsst/consdb/utils.py /consdb-pq/ | ||
# Environment variables that must be set: | ||
# DB_HOST DB_PASS DB_USER DB_NAME or POSTGRES_URL | ||
|
||
# Expose the port. | ||
EXPOSE 8080 | ||
|
||
ENTRYPOINT [ "gunicorn", "-b", "0.0.0.0:8080", "-w", "2", "pqserver:app" ] | ||
ENTRYPOINT [ "gunicorn", "-b", "0.0.0.0:8080", "-w", "2", "consdb-pq.pqserver:app" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm kind of surprised that this works with a hyphen in the name. If it doesn't, changing to just |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ def db(tmpdir, scope="module"): | |
@pytest.fixture | ||
def app(db, scope="module"): | ||
os.environ["POSTGRES_URL"] = f"sqlite:///{db}" | ||
import pqserver | ||
from lsst.consdb import pqserver | ||
|
||
return pqserver.app | ||
|
||
|
@@ -198,16 +198,14 @@ def test_flexible_metadata(client): | |
assert result["required_keys"] == ["values"] | ||
|
||
response = client.post( | ||
"/consdb/insert/latiss", | ||
"/consdb/insert/latiss/exposure/obs/2024032100003", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A little weird to have this be different from the values, but perhaps that's an even better test. |
||
json={ | ||
"table": "exposure", | ||
"values": { | ||
"exposure_name": "AT_O_20240327_000002", | ||
"controller": "O", | ||
"day_obs": 20240327, | ||
"seq_num": 2, | ||
}, | ||
"obs_id": 2024032700002, | ||
}, | ||
) | ||
_assert_http_status(response, 200) | ||
|
@@ -216,6 +214,7 @@ def test_flexible_metadata(client): | |
"message": "Data inserted", | ||
"table": "cdb_latiss.exposure", | ||
"instrument": "latiss", | ||
"obs_id": 2024032100003, | ||
} | ||
|
||
response = client.post("/consdb/query", json={"query": "SELECT * FROM exposure ORDER BY day_obs;"}) | ||
|
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.
Doesn't this run the action twice on a push to a branch that's already in a PR?