diff --git a/.github/workflows/build_and_push.yaml b/.github/workflows/build_and_push.yaml index 70e23c40..1a5fca02 100644 --- a/.github/workflows/build_and_push.yaml +++ b/.github/workflows/build_and_push.yaml @@ -1,31 +1,28 @@ -# A workflow that builds and (optionally) pushes the Docker container image -# artifacts for the application. The build action occurs on pull request events -# that target the `main` branch, and the push action occurs only with tagged releases -# and ticket branches. +# A workflow that builds and pushes the Docker container image artifacts for +# the application. The action occurs on new tags and when called from another +# workflow. --- name: "Build and Push" "on": - pull_request: - branches: - - main - paths: - - 'src/lsst/cmservice/**' push: tags: - "*" + workflow_call: workflow_dispatch: jobs: - ci: - uses: - ./.github/workflows/ci.yaml build: name: "Build and Push Application Container Images" - needs: - - ci - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + strategy: + matrix: + include: + - target: cmservice + image: ${{ github.repository_owner }}/cm-service + - target: cmworker + image: ${{ github.repository_owner }}/cm-worker timeout-minutes: 20 steps: @@ -34,19 +31,10 @@ jobs: fetch-depth: 0 - uses: lsst-sqre/build-and-push-to-ghcr@v1 - id: build-service with: dockerfile: docker/Dockerfile - target: cmservice - image: ${{ github.repository }} + target: ${{ matrix.target }} + platforms: linux/amd64,linux/arm64 + image: ${{ matrix.image }} github_token: ${{ secrets.GITHUB_TOKEN }} - push: ${{ github.ref_type == 'tag' || (github.ref_type == 'branch' && startsWith(github.ref_name, 'tickets/DM-')) }} - - - uses: lsst-sqre/build-and-push-to-ghcr@v1 - id: build-worker - with: - dockerfile: docker/Dockerfile - target: cmworker - image: ${{ github.repository }} - github_token: ${{ secrets.GITHUB_TOKEN }} - push: ${{ github.ref_type == 'tag' || (github.ref_type == 'branch' && startsWith(github.ref_name, 'tickets/DM-')) }} + push: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 71d26bf4..f349e786 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,6 +2,7 @@ # and when called from another workflow. --- name: "CI" + "on": workflow_call: push: @@ -13,8 +14,14 @@ env: UV_FROZEN: "1" jobs: + rebase-checker: + uses: + ./.github/workflows/rebase_checker.yaml + lint: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04-arm + needs: + - rebase-checker steps: - name: Checkout Repository @@ -28,13 +35,14 @@ jobs: - name: Run pre-commit uses: pre-commit/action@v3.0.1 - test: - runs-on: ubuntu-latest + mypy: + runs-on: ubuntu-24.04 strategy: matrix: python-version: ["3.11"] + needs: + - rebase-checker steps: - - name: Checkout Repository uses: actions/checkout@v4 @@ -42,24 +50,25 @@ jobs: uses: astral-sh/setup-uv@v5 with: version: "0.5.x" - enable_cache: true + enable-cache: true python-version: ${{ matrix.python-version }} - name: Install packages for testing run: uv sync --dev --frozen - name: Run tests - run: | - uv run playwright install - uv run make test + run: uv run make typing - mypy: - runs-on: ubuntu-latest + test: + runs-on: ubuntu-24.04 strategy: matrix: python-version: ["3.11"] - + needs: + - lint + - mypy steps: + - name: Checkout Repository uses: actions/checkout@v4 @@ -67,11 +76,20 @@ jobs: uses: astral-sh/setup-uv@v5 with: version: "0.5.x" - enable_cache: true + enable-cache: true python-version: ${{ matrix.python-version }} - name: Install packages for testing run: uv sync --dev --frozen - name: Run tests - run: uv run make typing + run: | + uv run playwright install + uv run make test + + + build-and-push: + needs: + - test + if: ${{ startsWith(github.ref_name, 'tickets/DM-') }} + uses: ./.github/workflows/build_and_push.yaml diff --git a/.github/workflows/rebase_checker.yaml b/.github/workflows/rebase_checker.yaml index d281a8f7..8836098d 100644 --- a/.github/workflows/rebase_checker.yaml +++ b/.github/workflows/rebase_checker.yaml @@ -1,7 +1,8 @@ --- name: Rebase Checker -on: pull_request +"on": + workflow_call: jobs: call-workflow: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6efbf8ec..5f429dcf 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -17,7 +17,7 @@ env: jobs: release: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04-arm timeout-minutes: 10 if: >- github.event_name == 'pull_request' diff --git a/src/lsst/cmservice/client/queues.py b/src/lsst/cmservice/client/queues.py index 39a26557..c420c435 100644 --- a/src/lsst/cmservice/client/queues.py +++ b/src/lsst/cmservice/client/queues.py @@ -3,10 +3,10 @@ from __future__ import annotations from datetime import datetime, timedelta +from time import sleep from typing import TYPE_CHECKING import httpx -import pause from pydantic import TypeAdapter, ValidationError from .. import db, models @@ -133,7 +133,7 @@ def pause_until_next_check( # In unit tests we set queue.interval to zero # so don't ever get to these lines print("pausing") - pause.until(next_check) + sleep(sleep_time) def daemon( self, diff --git a/src/lsst/cmservice/handlers/jobs.py b/src/lsst/cmservice/handlers/jobs.py index 446b32be..92385e85 100644 --- a/src/lsst/cmservice/handlers/jobs.py +++ b/src/lsst/cmservice/handlers/jobs.py @@ -120,9 +120,7 @@ async def _write_script( pass # build up the bps wrapper script - command = ( - f"{config.bps.bps_bin} --log-file {json_url} --no-log-tty submit " f"{config_path} > {log_url}" - ) + command = f"{config.bps.bps_bin} --log-file {json_url} --no-log-tty submit {config_path} > {log_url}" prepend = bps_core_script_template_.data["text"].replace("{lsst_version}", lsst_version) # type: ignore prepend = prepend.replace("{lsst_distrib_dir}", lsst_distrib_dir) diff --git a/src/lsst/cmservice/main.py b/src/lsst/cmservice/main.py index 3f488818..cdbfb8c0 100644 --- a/src/lsst/cmservice/main.py +++ b/src/lsst/cmservice/main.py @@ -118,10 +118,10 @@ async def lifespan(app: FastAPI) -> AsyncGenerator: lifespan=lifespan, title=config.asgi.title, version=__version__, - openapi_url="/openapi.json", + openapi_url="/docs/openapi.json", openapi_tags=tags_metadata, docs_url="/docs", - redoc_url="/redoc", + redoc_url=None, ) app.add_middleware(XForwardedMiddleware) diff --git a/tests/cli/util_functions.py b/tests/cli/util_functions.py index 960c6e3f..293bcda8 100644 --- a/tests/cli/util_functions.py +++ b/tests/cli/util_functions.py @@ -237,10 +237,7 @@ def check_update_methods( ) -> None: result = runner.invoke( client_top, - f"{entry_class_name} update data_dict " - "--output yaml " - f"--row_id {entry.id} " - "--update_dict test:dummy", + f"{entry_class_name} update data_dict --output yaml --row_id {entry.id} --update_dict test:dummy", ) check = check_and_parse_result(result, dict) assert check["test"] == "dummy", "update_data_dict failed" @@ -267,10 +264,7 @@ def check_update_methods( result = runner.invoke( client_top, - f"{entry_class_name} update collections " - "--output yaml " - f"--row_id {entry.id} " - "--update_dict test:dummy", + f"{entry_class_name} update collections --output yaml --row_id {entry.id} --update_dict test:dummy", ) check = check_and_parse_result(result, dict) assert check["test"] == "dummy", "update_collections failed" @@ -303,20 +297,14 @@ def check_update_methods( result = runner.invoke( client_top, - f"{entry_class_name} update child_config " - f"--row_id {entry.id} " - "--output yaml " - "--update_dict test:dummy", + f"{entry_class_name} update child_config --row_id {entry.id} --output yaml --update_dict test:dummy", ) check = check_and_parse_result(result, dict) assert check["test"] == "dummy", "update_child_config failed" result = runner.invoke( client_top, - f"{entry_class_name} update child_config " - f"--row_id -1 " - "--output yaml " - "--update_dict test:dummy", + f"{entry_class_name} update child_config --row_id -1 --output yaml --update_dict test:dummy", ) expect_failed_result(result, 1) @@ -331,10 +319,7 @@ def check_update_methods( result = runner.invoke( client_top, - f"{entry_class_name} update spec_aliases " - "--output yaml " - f"--row_id {entry.id} " - "--update_dict test:dummy", + f"{entry_class_name} update spec_aliases --output yaml --row_id {entry.id} --update_dict test:dummy", ) # FIXME: is this the return type we want? check_spec = check_and_parse_result(result, entry_class) diff --git a/tests/db/test_pipetask_error_type.py b/tests/db/test_pipetask_error_type.py index 1674b8aa..62be7987 100644 --- a/tests/db/test_pipetask_error_type.py +++ b/tests/db/test_pipetask_error_type.py @@ -57,15 +57,15 @@ async def test_error_match_db(engine: AsyncEngine) -> None: # Here we test that the same error with a different pipetask name will # not match. Let's consider the same error, but on task "isr" - assert ( - e1.match("isr", known_error["diagnostic_message"]) is False - ), "Failure to identify non-matching pipetask name" + assert e1.match("isr", known_error["diagnostic_message"]) is False, ( + "Failure to identify non-matching pipetask name" + ) # Here we test that the same pipetask name but different error does not # match. - assert ( - e1.match(known_error["task_name"], "A different error message") is False - ), "Failure to identify separate errors with the same associated pipetask" + assert e1.match(known_error["task_name"], "A different error message") is False, ( + "Failure to identify separate errors with the same associated pipetask" + ) # Here we test that a different valid PipetaskError does not match to # the wrong PipetaskErrorType diff --git a/uv.lock b/uv.lock index 876f6755..b2824a14 100644 --- a/uv.lock +++ b/uv.lock @@ -983,7 +983,7 @@ wheels = [ [[package]] name = "lsst-cm-service" -version = "0.2.0rc1" +version = "0.2.0" source = { editable = "." } dependencies = [ { name = "alembic" },