Skip to content
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-46747 refactor pqserver per SQR-072 #65

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,30 @@ jobs:
contents: read

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

- name: Build hinfo
uses: lsst-sqre/build-and-push-to-ghcr@v1
with:
image: ${{ github.repository }}-hinfo
github_token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: Dockerfile.hinfo
- name: Extract Git Tag or Branch
id: git_info
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "GITHUB_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "GITHUB_TAG=noversion" >> $GITHUB_ENV
fi

- name: Build pqserver
uses: lsst-sqre/build-and-push-to-ghcr@v1
with:
image: ${{ github.repository }}-pq
github_token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: Dockerfile.pqserver
- name: Build hinfo
uses: lsst-sqre/build-and-push-to-ghcr@v1
with:
image: ${{ github.repository }}-hinfo
github_token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: Dockerfile.hinfo

- name: Build pqserver
uses: lsst-sqre/build-and-push-to-ghcr@v1
with:
image: ${{ github.repository }}-pq
github_token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: Dockerfile.pqserver
build-args: |
GITHUB_TAG=${{ env.GITHUB_TAG }}
20 changes: 19 additions & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,23 @@ jobs:
- name: Build docker image
run: docker build -f Dockerfile.pytest -t pytest_image .

- name: Create directory for coverage report
run: mkdir -p ${{ github.workspace }}/pytest_reports

- name: Set coverage report directory permissions
run: chmod -R 777 ${{ github.workspace }}/pytest_reports

- name: Run docker image
run: docker run --rm -e PYTEST_ADDOPTS="--color=yes" pytest_image
run: docker run --rm -v ${{ github.workspace }}/pytest_reports:/home/lsst/consdb/pytest_reports -e PYTEST_ADDOPTS="--color=yes" pytest_image

- name: Upload test report
uses: actions/upload-artifact@v4
with:
name: pytest_report
path: pytest_reports/pytest_report.html

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage_report
path: pytest_reports/htmlcov
19 changes: 18 additions & 1 deletion Dockerfile.pqserver
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
FROM python:3.11

ARG GITHUB_TAG
ENV VERSION=${GITHUB_TAG}

RUN pip install fastapi safir astropy uvicorn gunicorn sqlalchemy psycopg2
WORKDIR /
COPY python/lsst/consdb/__init__.py python/lsst/consdb/pqserver.py python/lsst/consdb/utils.py /consdb_pq/
COPY \
python/lsst/consdb/__init__.py \
python/lsst/consdb/pqserver.py \
python/lsst/consdb/cdb_schema.py \
python/lsst/consdb/config.py \
python/lsst/consdb/dependencies.py \
python/lsst/consdb/exceptions.py \
python/lsst/consdb/models.py \
/consdb_pq/
COPY \
python/lsst/consdb/handlers/external.py \
python/lsst/consdb/handlers/internal.py \
/consdb_pq/handlers/

# Environment variables that must be set:
# DB_HOST DB_PASS DB_USER DB_NAME or POSTGRES_URL

Expand Down
8 changes: 6 additions & 2 deletions Dockerfile.pytest
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ RUN yum install -y postgresql-server postgresql && rmdir /usr/local/bin && ln -s

USER lsst
RUN source loadLSST.bash && mamba install -y aiokafka httpx
RUN source loadLSST.bash && pip install kafkit aiokafka httpx pytest-asyncio testing.postgresql lsst-felis
RUN source loadLSST.bash && pip install kafkit aiokafka httpx pytest-asyncio pytest-cov pytest-html testing.postgresql lsst-felis safir

WORKDIR /home/lsst/

COPY --chown=lsst . ./consdb/
WORKDIR /home/lsst/consdb/
RUN source /opt/lsst/software/stack/loadLSST.bash && pip install -e .

ENTRYPOINT [ "/bin/bash", "-c", "source /opt/lsst/software/stack/loadLSST.bash; setup obs_lsst; setup felis; pytest ." ]
USER root
RUN mkdir -p /home/lsst/consdb/pytest_reports && chown lsst:lsst /home/lsst/consdb/pytest_reports
USER lsst

ENTRYPOINT [ "/bin/bash", "-c", "source /opt/lsst/software/stack/loadLSST.bash; setup obs_lsst; setup felis; pytest --cov=./ --cov-report=html:/home/lsst/consdb/pytest_reports/htmlcov --html=pytest_reports/pytest_report.html --self-contained-html ." ]
Loading
Loading