fix lock #1369
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unit Tests | |
| on: | |
| pull_request: | |
| branches: | |
| - dev | |
| - main | |
| - 'REL*' | |
| push: | |
| branches: | |
| - dev | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: unit-tests-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| bcs: | |
| name: BCS unit tests | |
| runs-on: ubuntu-latest | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # PR: actions/checkout checks out the synthetic merge commit, so compare | |
| # against its first parent (the exact base tree used for that merge). | |
| # push/dispatch: compare against dev (repo default branch) instead. | |
| BCS_BASE_REF: ${{ github.event_name == 'pull_request' && 'HEAD^1' || 'origin/dev' }} | |
| defaults: | |
| run: | |
| working-directory: src/bcs | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Validate unit-test diff behavior | |
| working-directory: ${{ github.workspace }} | |
| run: python3 scripts/ci/tests/test_unit_test_workflow_diff.py | |
| - name: Detect BCS changes vs base | |
| id: changes | |
| # Run from the repo root: all git-diff pathspecs here are repo-relative | |
| # ("-- src/bcs"), which only resolve correctly from the root. The job default | |
| # working-directory is src/bcs, so override to the workspace root. | |
| working-directory: ${{ github.workspace }} | |
| shell: bash | |
| run: | | |
| # Make sure the base ref is present locally (shallow clones may not have it). | |
| git fetch --no-tags --depth=1 origin "${BCS_BASE_REF#origin/}" 2>/dev/null || true | |
| # Compare the base ref against the working tree (not HEAD). PR runs check out a | |
| # merge commit as HEAD, for which "<base>...HEAD" collapses to nothing (merge-base | |
| # == base) and would wrongly report zero changes. Diffing base against the tree | |
| # instead sees all PR-introduced changes regardless of merge-commit checkout. | |
| mapfile -t files < <(git diff --name-only "${BCS_BASE_REF}" -- src/bcs || true) | |
| n=${#files[@]} | |
| echo "bcs-changed-files-count=${n}" >> "$GITHUB_OUTPUT" | |
| if [ "$n" -eq 0 ]; then | |
| echo "skip-bcs=true" >> "$GITHUB_OUTPUT" | |
| echo "No changes under src/bcs vs ${BCS_BASE_REF}; skipping BCS tests." | |
| else | |
| echo "skip-bcs=false" >> "$GITHUB_OUTPUT" | |
| echo "Detected ${n} changed file(s) under src/bcs vs ${BCS_BASE_REF}." | |
| printf '%s\n' "${files[@]}" | sed 's/^/ - /' | |
| fi | |
| - name: Install system dependencies | |
| if: steps.changes.outputs.skip-bcs != 'true' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| - name: Install Rust toolchain | |
| if: steps.changes.outputs.skip-bcs != 'true' | |
| run: | | |
| rustup toolchain install stable --profile minimal | |
| rustup default stable | |
| rustup component add llvm-tools | |
| rustc --version | |
| cargo --version | |
| - name: Install cargo-nextest and cargo-llvm-cov | |
| if: steps.changes.outputs.skip-bcs != 'true' | |
| run: | | |
| cargo install cargo-nextest --locked | |
| cargo install cargo-llvm-cov --locked | |
| - name: Cache Cargo registry and target | |
| if: steps.changes.outputs.skip-bcs != 'true' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| src/bcs/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('src/bcs/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Run unit tests with coverage | |
| if: steps.changes.outputs.skip-bcs != 'true' | |
| run: bash scripts/ci_test.sh --coverage | |
| - name: Enforce coverage gates | |
| if: steps.changes.outputs.skip-bcs != 'true' | |
| env: | |
| BCS_BASE_REF: ${{ env.BCS_BASE_REF }} | |
| working-directory: ${{ github.workspace }}/src/bcs | |
| run: | | |
| python3 scripts/cov_gate.py \ | |
| --base-ref "$BCS_BASE_REF" \ | |
| --bcs-dir "$PWD" \ | |
| --pass-rate-min 100 \ | |
| --overall-line-min 70 \ | |
| --changed-line-min 80 | |
| - name: Upload BCS test results | |
| if: always() && steps.changes.outputs.skip-bcs != 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bcs-testresult | |
| path: src/bcs/testresult/ | |
| if-no-files-found: ignore | |
| backend: | |
| name: Backend unit tests | |
| runs-on: ubuntu-latest | |
| env: | |
| # PR: compare against the checked-out merge commit's exact base tree. | |
| # push/dispatch: compare against dev (repo default branch) instead. | |
| BACKEND_BASE_REF: ${{ github.event_name == 'pull_request' && 'HEAD^1' || 'origin/dev' }} | |
| defaults: | |
| run: | |
| working-directory: src/backend | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect backend changes vs base | |
| id: changes | |
| # Run from the repo root so the "-- src/backend" pathspec resolves; the job | |
| # default working-directory is src/backend, so override to the workspace root. | |
| working-directory: ${{ github.workspace }} | |
| shell: bash | |
| run: | | |
| # Make sure the base ref is present locally (shallow clones may not have it). | |
| git fetch --no-tags --depth=1 origin "${BACKEND_BASE_REF#origin/}" 2>/dev/null || true | |
| # Diff the base ref against the working tree. PR runs check out a merge commit, | |
| # for which "<base>...HEAD" collapses to nothing; diffing base against the tree | |
| # sees all PR-introduced changes regardless of the merge-commit checkout. | |
| mapfile -t files < <(git diff --name-only "${BACKEND_BASE_REF}" -- src/backend || true) | |
| n=${#files[@]} | |
| if [ "$n" -eq 0 ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "No changes under src/backend vs ${BACKEND_BASE_REF}; skipping backend tests." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| echo "Detected ${n} changed file(s) under src/backend vs ${BACKEND_BASE_REF}." | |
| printf '%s\n' "${files[@]}" | sed 's/^/ - /' | |
| fi | |
| - name: Set up Python | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| # Backend targets Python >=3.12,<3.13 (see src/backend/pyproject.toml). | |
| python-version: '3.12' | |
| - name: Install uv | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: src/backend/uv.lock | |
| - name: Run unit tests with coverage | |
| if: steps.changes.outputs.skip != 'true' | |
| # ci_test.sh runs pytest with coverage and enforces the case-pass-rate / | |
| # line-coverage / changed-line-coverage gates via scripts/ci/report_check.py. | |
| run: bash scripts/ci_test.sh --base "$BACKEND_BASE_REF" | |
| - name: Upload backend test results | |
| if: always() && steps.changes.outputs.skip != 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-testresult | |
| path: src/backend/pytest_report/ | |
| if-no-files-found: ignore | |
| engine: | |
| name: Engine unit tests | |
| runs-on: ubuntu-latest | |
| env: | |
| ENGINE_BASE_REF: ${{ github.event_name == 'pull_request' && 'HEAD^1' || 'origin/dev' }} | |
| defaults: | |
| run: | |
| working-directory: src/engine | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect engine changes vs base | |
| id: changes | |
| working-directory: ${{ github.workspace }} | |
| shell: bash | |
| run: | | |
| git fetch --no-tags --depth=1 origin "${ENGINE_BASE_REF#origin/}" 2>/dev/null || true | |
| mapfile -t files < <(git diff --name-only "${ENGINE_BASE_REF}" -- src/engine || true) | |
| n=${#files[@]} | |
| if [ "$n" -eq 0 ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "No changes under src/engine vs ${ENGINE_BASE_REF}; skipping engine tests." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| echo "Detected ${n} changed file(s) under src/engine vs ${ENGINE_BASE_REF}." | |
| printf '%s\n' "${files[@]}" | sed 's/^/ - /' | |
| fi | |
| - name: Set up Python | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| # Engine targets Python >=3.12 (see src/engine/pyproject.toml). | |
| python-version: '3.12' | |
| - name: Install uv | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: src/engine/uv.lock | |
| - name: Run unit tests with coverage | |
| if: steps.changes.outputs.skip != 'true' | |
| run: bash scripts/ci_test.sh --base "$ENGINE_BASE_REF" | |
| - name: Upload engine test results | |
| if: always() && steps.changes.outputs.skip != 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: engine-testresult | |
| path: src/engine/pytest_report/ | |
| if-no-files-found: ignore | |
| baas: | |
| name: BaaS unit tests | |
| runs-on: ubuntu-latest | |
| env: | |
| # PR: compare against the checked-out merge commit's exact base tree. | |
| # push/dispatch: compare against dev (repo default branch) instead. | |
| BAAS_BASE_REF: ${{ github.event_name == 'pull_request' && 'HEAD^1' || 'origin/dev' }} | |
| defaults: | |
| run: | |
| working-directory: src/baas | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect baas changes vs base | |
| id: changes | |
| # Run from the repo root so the "-- src/baas" pathspec resolves; the job | |
| # default working-directory is src/baas, so override to the workspace root. | |
| working-directory: ${{ github.workspace }} | |
| shell: bash | |
| run: | | |
| # Make sure the base ref is present locally (shallow clones may not have it). | |
| git fetch --no-tags --depth=1 origin "${BAAS_BASE_REF#origin/}" 2>/dev/null || true | |
| # Diff the base ref against the working tree. PR runs check out a merge commit, | |
| # for which "<base>...HEAD" collapses to nothing; diffing base against the tree | |
| # sees all PR-introduced changes regardless of the merge-commit checkout. | |
| mapfile -t files < <(git diff --name-only "${BAAS_BASE_REF}" -- src/baas || true) | |
| n=${#files[@]} | |
| if [ "$n" -eq 0 ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "No changes under src/baas vs ${BAAS_BASE_REF}; skipping baas tests." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| echo "Detected ${n} changed file(s) under src/baas vs ${BAAS_BASE_REF}." | |
| printf '%s\n' "${files[@]}" | sed 's/^/ - /' | |
| fi | |
| - name: Set up Python | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| # Baas targets Python >=3.12,<3.13 (see src/baas/pyproject.toml). | |
| python-version: '3.12' | |
| - name: Install uv | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: src/baas/uv.lock | |
| - name: Run unit tests with coverage | |
| if: steps.changes.outputs.skip != 'true' | |
| # ci_test.sh runs pytest with coverage and enforces the case-pass-rate / | |
| # line-coverage / changed-line-coverage gates via scripts/ci/report_check.py. | |
| run: DEPLOY_ENV=dev bash scripts/ci_test.sh --base "${BAAS_BASE_REF}" | |
| - name: Upload baas test results | |
| if: always() && steps.changes.outputs.skip != 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: baas-testresult | |
| path: src/baas/pytest_report/ | |
| if-no-files-found: ignore | |
| gateway: | |
| name: Gateway unit tests | |
| runs-on: ubuntu-latest | |
| env: | |
| # PR: compare against the checked-out merge commit's exact base tree. | |
| # push/dispatch: compare against dev (repo default branch) instead. | |
| GATEWAY_BASE_REF: ${{ github.event_name == 'pull_request' && 'HEAD^1' || 'origin/dev' }} | |
| defaults: | |
| run: | |
| working-directory: src/gateway | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect gateway changes vs base | |
| id: changes | |
| # Run from the repo root so the "-- src/gateway" pathspec resolves; the job | |
| # default working-directory is src/gateway, so override to the workspace root. | |
| working-directory: ${{ github.workspace }} | |
| shell: bash | |
| run: | | |
| # Make sure the base ref is present locally (shallow clones may not have it). | |
| git fetch --no-tags --depth=1 origin "${GATEWAY_BASE_REF#origin/}" 2>/dev/null || true | |
| # Diff the base ref against the working tree. PR runs check out a merge commit, | |
| # for which "<base>...HEAD" collapses to nothing; diffing base against the tree | |
| # sees all PR-introduced changes regardless of the merge-commit checkout. | |
| mapfile -t files < <(git diff --name-only "${GATEWAY_BASE_REF}" -- src/gateway || true) | |
| n=${#files[@]} | |
| if [ "$n" -eq 0 ]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "No changes under src/gateway vs ${GATEWAY_BASE_REF}; skipping gateway tests." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| echo "Detected ${n} changed file(s) under src/gateway vs ${GATEWAY_BASE_REF}." | |
| printf '%s\n' "${files[@]}" | sed 's/^/ - /' | |
| fi | |
| - name: Set up Python | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| # Gateway targets Python >=3.12 (see src/gateway/pyproject.toml). | |
| python-version: '3.12' | |
| - name: Install uv | |
| if: steps.changes.outputs.skip != 'true' | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: src/gateway/uv.lock | |
| - name: Run unit tests with coverage | |
| if: steps.changes.outputs.skip != 'true' | |
| # ci_test.sh runs ruff lint + pytest with coverage and produces JUnit XML | |
| # and HTML reports under pytest_report/. | |
| run: bash scripts/ci_test.sh --base "${GATEWAY_BASE_REF}" | |
| - name: Upload gateway test results | |
| if: always() && steps.changes.outputs.skip != 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gateway-testresult | |
| path: src/gateway/pytest_report/ | |
| if-no-files-found: ignore |