Skip to content
Closed
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
94 changes: 94 additions & 0 deletions .github/workflows/_reusable-unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Reusable Unit Test Workflow

on:
workflow_call:
inputs:
service_name:
required: true
type: string
description: "The name of the service to test"
timeout_minutes:
required: false
type: number
default: 18
description: "Timeout in minutes for the test job"
dependency_path:
required: false
type: string
default: "**/{service_name}/requirements/ci.txt"
description: "Path pattern for dependencies to cache"
test_mode:
required: false
type: string
default: "standard"
description: "Test mode to run (standard, isolated, with_db)"
test_shard:
required: false
type: string
default: ""
description: "Test shard to run (e.g., 01, 02, 03, 04 for webserver)"
pre_test_step:
required: false
type: string
default: ""
description: "Additional step to run before the test step"

jobs:
unit_test:
name: "[unit] ${{ inputs.service_name }}${{ inputs.test_shard != '' && ' ' || '' }}${{ inputs.test_shard }}"
timeout-minutes: ${{ inputs.timeout_minutes }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python: ["3.11"]
os: [ubuntu-24.04]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: setup docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: setup python environment
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.6.x"
enable-cache: false
cache-dependency-glob: ${{ format(inputs.dependency_path, inputs.service_name) }}
- name: show system version
run: ./ci/helpers/show_system_versions.bash
- name: install
run: ./ci/github/unit-testing/${{ inputs.service_name }}.bash install
- name: typecheck
run: ./ci/github/unit-testing/${{ inputs.service_name }}.bash typecheck
# Pre-test step if specified
- name: ${{ inputs.pre_test_step }}
if: ${{ inputs.pre_test_step != '' && !cancelled() }}
run: ./ci/github/unit-testing/${{ inputs.service_name }}.bash ${{ inputs.pre_test_step }}
# Test step with different modes
- name: test
if: ${{ inputs.test_mode == 'standard' && !cancelled() }}
run: ./ci/github/unit-testing/${{ inputs.service_name }}.bash test
- name: test isolated
if: ${{ inputs.test_mode == 'isolated' && !cancelled() }}
run: ./ci/github/unit-testing/${{ inputs.service_name }}.bash test_isolated
- name: test with db
if: ${{ inputs.test_mode == 'with_db' && !cancelled() }}
run: ./ci/github/unit-testing/${{ inputs.service_name }}.bash test_with_db ${{ inputs.test_shard }}
- name: upload failed tests logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}_docker_logs
path: ./services/${{ inputs.service_name }}/test_failures
- uses: codecov/codecov-action@v5
if: ${{ !cancelled() }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: unittests
Loading
Loading