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

DST-258: deploy infra- enable tests #11

Merged
merged 8 commits into from
Jun 26, 2024
Merged
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
15 changes: 7 additions & 8 deletions .github/workflows/cd-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ name: Deploy App
run-name: Deploy ${{ github.ref_name }} to App ${{ inputs.environment || 'dev' }}

on:
# !! Uncomment the following lines once you've set up the dev environment and ready to turn on continuous deployment
# push:
# branches:
# - "main"
# paths:
# - "app/**"
# - "bin/**"
# - "infra/**"
push:
branches:
- "main"
paths:
- "app/**"
- "bin/**"
- "infra/**"
workflow_dispatch:
inputs:
environment:
Expand Down
29 changes: 14 additions & 15 deletions .github/workflows/ci-infra-service.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: CI Infra Service Checks

on:
# !! Uncomment to trigger automated infra tests once dev environment is set up
# push:
# branches:
# - main
# paths:
# - infra/*/service/**
# - infra/modules/**
# - infra/test/**
# - .github/workflows/ci-infra-service.yml
# pull_request:
# paths:
# - infra/*/service/**
# - infra/modules/**
# - infra/test/**
# - .github/workflows/ci-infra-service.yml
push:
branches:
- main
paths:
- infra/*/service/**
- infra/modules/**
- infra/test/**
- .github/workflows/ci-infra-service.yml
pull_request:
paths:
- infra/*/service/**
- infra/modules/**
- infra/test/**
- .github/workflows/ci-infra-service.yml
workflow_dispatch:

jobs:
Expand Down
15 changes: 15 additions & 0 deletions app/src/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ class HealthCheck(BaseModel):
hostname: str


@healthcheck_router.get(
"/",
tags=["health"],
summary="Perform a Health Check",
response_description="Return HTTP Status Code 200 (OK)",
status_code=status.HTTP_200_OK,
response_model=HealthCheck,
)
@healthcheck_router.head(
"/health",
tags=["health"],
summary="Perform a Health Check",
response_description="Return HTTP Status Code 200 (OK)",
status_code=status.HTTP_200_OK,
)
@healthcheck_router.get(
"/health",
tags=["health"],
Expand Down
12 changes: 12 additions & 0 deletions app/tests/src/test_healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ def test_get_healthcheck_200(self, caplog, test_client):
assert response.status_code == 200
assert response_data["status"] == "OK"
assert "Healthy" in caplog.messages[1]

def test_head_healthcheck_200(self, caplog, test_client):
response = test_client.head("/health")
assert response.status_code == 200

# This endpoint is only required by the infra CI "Test Service"
# Adding test coverage to document this requirement -- this
# test can be removed if we later add a page at '/'
def test_get_root_200(self, caplog, test_client):
with caplog.at_level(logging.INFO):
response = test_client.get("/")
assert response.status_code == 200
Loading