Skip to content
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
33 changes: 33 additions & 0 deletions .github/workflows/error_handling_utils_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Error Handling Utils Tests

on:
workflow_call:
inputs:
environment:
description: "Environment to run tests against"
type: string
required: false
default: "dev"

jobs:
error_handling_utils_tests:
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.13'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pyyaml requests boto3 flask jinja2 lxml werkzeug six python-dotenv

- name: Run error handling utils tests
env:
UNIT_TEST_ONLY: "true"
ENVIRONMENT: ${{ inputs.environment }}
run: pytest --env="$ENVIRONMENT" tests/test_error_handling_utils.py
28 changes: 28 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,31 @@ jobs:
id: "Run during opened pull request"
github_tag: ${{ github.event.pull_request.head.ref }}
secrets: inherit

error_handling_utils_changes:
if: >-
(github.event_name == 'pull_request' && github.event.pull_request.user.login != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.filter.outputs.error_handling_utils }}
steps:
- name: Detect relevant changes
id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
with:
filters: |
error_handling_utils:
- 'tests/test_error_handling_utils.py'
- 'utils/data_helper.py'
- 'utils/dynamo_helper.py'
- 'utils/eligibility_api_client.py'
- 'tests/performance_tests/validate_inputs.py'

error_handling_utils_tests:
if: >-
needs.error_handling_utils_changes.outputs.should_run == 'true' &&
((github.event_name == 'pull_request' && github.event.pull_request.user.login != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository))
needs: error_handling_utils_changes
uses: ./.github/workflows/error_handling_utils_tests.yml
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def eligibility_client():

@pytest.fixture(scope="session", autouse=True)
def upload_consumer_mapping_once():
if os.getenv("UNIT_TEST_ONLY", "").lower() == "true":
logger.info("Skipping consumer mapping upload for unit-test-only run")
return
upload_consumer_mapping_file_to_s3(test_config.CONSUMER_MAPPING_FILE)


Expand Down
9 changes: 7 additions & 2 deletions tests/performance_tests/validate_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ def parse_run_time_to_seconds(run_time: str) -> int:


def main() -> None:
users = int(get_env("USERS"))
spawn_rate = int(get_env("SPAWN_RATE"))
try:
users = int(get_env("USERS"))
spawn_rate = int(get_env("SPAWN_RATE"))
except ValueError:
fail("Invalid input", "USERS must be an integer.")
return

run_time = get_env("RUN_TIME")

validate_range("users", users, 1, MAX_USERS)
Expand Down
Loading