mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
623 lines
21 KiB
YAML
623 lines
21 KiB
YAML
---
|
|
name: PR CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: read
|
|
pull-requests: read
|
|
|
|
env:
|
|
NPM_CONFIG_STORE_DIR: .pnpm-store
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
frontend-quality:
|
|
name: Frontend Quality (typecheck, lint, format)
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Cache pnpm store
|
|
id: pnpm-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
pnpm-store-${{ runner.os }}-
|
|
|
|
- name: Install dependencies
|
|
run: bash scripts/ci-cancel-aware.sh pnpm install --frozen-lockfile
|
|
|
|
- name: Save pnpm store cache
|
|
if: always() && steps.pnpm-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ steps.pnpm-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Type check TypeScript files
|
|
run: bash scripts/ci-cancel-aware.sh pnpm --filter openhuman-app compile
|
|
env:
|
|
NODE_ENV: test
|
|
|
|
- name: Check Prettier formatting
|
|
run: bash scripts/ci-cancel-aware.sh pnpm --filter openhuman-app format:check
|
|
env:
|
|
NODE_ENV: test
|
|
|
|
- name: Run ESLint
|
|
run: bash scripts/ci-cancel-aware.sh pnpm --filter openhuman-app lint
|
|
env:
|
|
NODE_ENV: test
|
|
|
|
i18n-coverage:
|
|
name: i18n Coverage (parity)
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Cache pnpm store
|
|
id: pnpm-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
pnpm-store-${{ runner.os }}-
|
|
|
|
- name: Install dependencies
|
|
run: bash scripts/ci-cancel-aware.sh pnpm install --frozen-lockfile
|
|
|
|
- name: Save pnpm store cache
|
|
if: always() && steps.pnpm-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ steps.pnpm-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Verify i18n coverage (missing / extra / drifted keys across locales)
|
|
run: bash scripts/ci-cancel-aware.sh pnpm i18n:check
|
|
|
|
rust-quality:
|
|
name: Rust Quality (fmt, clippy)
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
|
|
env:
|
|
CARGO_INCREMENTAL: "0"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
|
|
- name: Cache Rust build artifacts
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: |
|
|
. -> target
|
|
cache-on-failure: true
|
|
# shared-key (not key) so the cache name is stable and not suffixed
|
|
# with the job id. Swatinem caches the full target/, which is why we
|
|
# no longer layer sccache on top (it logged 0% hits under a warm
|
|
# rust-cache and just doubled the cache footprint).
|
|
shared-key: pr-rust-quality
|
|
|
|
- name: Check Rust formatting
|
|
run: bash scripts/ci-cancel-aware.sh cargo fmt --all -- --check
|
|
|
|
- name: Run clippy (core crate)
|
|
run: bash scripts/ci-cancel-aware.sh cargo clippy -p openhuman
|
|
|
|
build-playwright-e2e-artifact:
|
|
name: Build Playwright E2E Artifact
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:latest
|
|
timeout-minutes: 45
|
|
env:
|
|
CARGO_INCREMENTAL: "0"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
|
|
- name: Cache pnpm store
|
|
id: pnpm-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
pnpm-store-${{ runner.os }}-
|
|
|
|
- name: Cache Rust build artifacts
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: . -> target
|
|
cache-on-failure: true
|
|
# Shared with rust-e2e (same image + env): both compile the openhuman
|
|
# crate's non-instrumented dependency tree, so one cache entry serves
|
|
# both instead of two ~1GB copies competing for the repo cache budget.
|
|
shared-key: pr-rust-core
|
|
|
|
- name: Restore cached Playwright E2E artifact
|
|
id: playwright-artifact-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .ci/artifacts/e2e-playwright-linux.tar.gz
|
|
key: e2e-playwright-linux-${{ hashFiles('src/**', 'Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml', 'app/src/**', 'app/public/**', 'app/index.html', 'app/vite.config.*', 'app/tailwind.config.*', 'app/postcss.config.*', 'app/package.json', 'pnpm-lock.yaml', 'app/scripts/e2e-web-build.sh') }}
|
|
|
|
- name: Install dependencies
|
|
if: steps.playwright-artifact-cache.outputs.cache-hit != 'true'
|
|
run: bash scripts/ci-cancel-aware.sh pnpm install --frozen-lockfile
|
|
|
|
- name: Save pnpm store cache
|
|
if: always() && steps.pnpm-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ steps.pnpm-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Ensure .env exists for E2E build
|
|
if: steps.playwright-artifact-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
touch .env
|
|
touch app/.env
|
|
|
|
- name: Build and package Playwright E2E artifact
|
|
if: steps.playwright-artifact-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
set -euo pipefail
|
|
bash scripts/ci-cancel-aware.sh pnpm --filter openhuman-app test:e2e:web:build
|
|
|
|
RUST_HOST_TRIPLE="$(rustc -vV | awk '/^host: / { print $2 }')"
|
|
WEB_CORE_TARGET_DIR="target/e2e-web-${RUST_HOST_TRIPLE}"
|
|
STAGE="$(mktemp -d)"
|
|
mkdir -p "$STAGE/repo/app/dist-web"
|
|
mkdir -p "$STAGE/repo/$WEB_CORE_TARGET_DIR/debug"
|
|
mkdir -p .ci/artifacts
|
|
|
|
cp -a app/dist-web/. "$STAGE/repo/app/dist-web/"
|
|
cp -a "$WEB_CORE_TARGET_DIR/debug/openhuman-core" "$STAGE/repo/$WEB_CORE_TARGET_DIR/debug/"
|
|
tar -czf .ci/artifacts/e2e-playwright-linux.tar.gz -C "$STAGE" repo
|
|
ls -lh .ci/artifacts/e2e-playwright-linux.tar.gz
|
|
|
|
- name: Verify build artifact exists
|
|
run: |
|
|
set -euo pipefail
|
|
test -f .ci/artifacts/e2e-playwright-linux.tar.gz
|
|
|
|
- name: Save Playwright E2E artifact cache
|
|
if: always() && steps.playwright-artifact-cache.outputs.cache-hit != 'true' && hashFiles('.ci/artifacts/e2e-playwright-linux.tar.gz') != ''
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: .ci/artifacts/e2e-playwright-linux.tar.gz
|
|
key: ${{ steps.playwright-artifact-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Upload Playwright E2E artifact
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: e2e-playwright-linux-${{ github.run_id }}
|
|
path: .ci/artifacts/e2e-playwright-linux.tar.gz
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
|
|
frontend-coverage:
|
|
name: Frontend Coverage (Vitest)
|
|
needs: [frontend-quality]
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Cache pnpm store
|
|
id: pnpm-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
pnpm-store-${{ runner.os }}-
|
|
|
|
- name: Install dependencies
|
|
run: bash scripts/ci-cancel-aware.sh pnpm install --frozen-lockfile
|
|
|
|
- name: Save pnpm store cache
|
|
if: always() && steps.pnpm-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ steps.pnpm-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Run Vitest with coverage
|
|
run: bash ../scripts/ci-cancel-aware.sh pnpm test:coverage
|
|
working-directory: app
|
|
env:
|
|
NODE_ENV: test
|
|
|
|
- name: Normalize lcov source paths to repo root
|
|
run: |
|
|
set -euo pipefail
|
|
test -f app/coverage/lcov.info
|
|
sed -i -E 's#^SF:(src/)#SF:app/\1#' app/coverage/lcov.info
|
|
sed -i -E 's#^SF:(\./src/)#SF:app/src/#' app/coverage/lcov.info
|
|
|
|
- name: Upload frontend lcov
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: lcov-frontend
|
|
path: app/coverage/lcov.info
|
|
retention-days: 7
|
|
if-no-files-found: error
|
|
|
|
rust-core-coverage:
|
|
name: Rust Core Coverage (cargo-llvm-cov)
|
|
needs: [rust-quality]
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 45
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
|
|
env:
|
|
CARGO_INCREMENTAL: "0"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
|
|
- name: Cache Rust build artifacts
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: . -> target
|
|
cache-on-failure: true
|
|
# Coverage uses instrumented builds (-C instrument-coverage), whose
|
|
# rustflags hash to a different Swatinem key than the plain builds, so
|
|
# it gets its own cache and cannot reuse pr-rust-core. It still reuses
|
|
# the (non-instrumented) dependency tree run-over-run.
|
|
shared-key: pr-rust-core-cov
|
|
|
|
- name: Install cargo-llvm-cov
|
|
uses: taiki-e/install-action@cargo-llvm-cov
|
|
|
|
- name: Run cargo llvm-cov for openhuman core
|
|
run: bash scripts/ci-cancel-aware.sh cargo llvm-cov --no-fail-fast -p openhuman --lcov --output-path lcov-core.info
|
|
env:
|
|
CARGO_BUILD_JOBS: "2"
|
|
|
|
- name: Upload core lcov
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: lcov-rust-core
|
|
path: lcov-core.info
|
|
retention-days: 7
|
|
if-no-files-found: error
|
|
|
|
rust-tauri-coverage:
|
|
name: Rust Tauri Coverage (cargo-llvm-cov)
|
|
needs: [rust-quality]
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 45
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
|
|
env:
|
|
CARGO_INCREMENTAL: "0"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
|
|
- name: Cache Rust build artifacts
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: |
|
|
. -> target
|
|
app/src-tauri -> target
|
|
cache-on-failure: true
|
|
# Tauri shell coverage (instrumented) — its own stable cache; reuses
|
|
# its warm dependency tree run-over-run.
|
|
shared-key: pr-rust-tauri-cov
|
|
|
|
- name: Cache CEF binary distribution
|
|
id: cef-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: |
|
|
~/Library/Caches/tauri-cef
|
|
~/.cache/tauri-cef
|
|
key: cef-x86_64-unknown-linux-gnu-v2-${{ hashFiles('app/src-tauri/Cargo.toml') }}
|
|
restore-keys: |
|
|
cef-x86_64-unknown-linux-gnu-v2-
|
|
|
|
- name: Install cargo-llvm-cov
|
|
uses: taiki-e/install-action@cargo-llvm-cov
|
|
|
|
- name: Run cargo llvm-cov for Tauri shell
|
|
run: bash scripts/ci-cancel-aware.sh cargo llvm-cov --manifest-path app/src-tauri/Cargo.toml --lcov --output-path lcov-tauri.info
|
|
|
|
- name: Save CEF binary distribution cache
|
|
if: always() && steps.cef-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: |
|
|
~/Library/Caches/tauri-cef
|
|
~/.cache/tauri-cef
|
|
key: ${{ steps.cef-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Upload tauri lcov
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: lcov-rust-tauri
|
|
path: lcov-tauri.info
|
|
retention-days: 7
|
|
if-no-files-found: error
|
|
|
|
rust-e2e:
|
|
name: Rust E2E (mock backend)
|
|
needs: [rust-quality]
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:latest
|
|
timeout-minutes: 60
|
|
env:
|
|
CARGO_INCREMENTAL: "0"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
|
|
- name: Cache pnpm store
|
|
id: pnpm-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
pnpm-store-${{ runner.os }}-
|
|
|
|
- name: Cache Rust build artifacts
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
workspaces: . -> target
|
|
cache-on-failure: true
|
|
# Shared with build-playwright (same image + env): one non-instrumented
|
|
# core cache serves both lanes instead of two competing copies.
|
|
shared-key: pr-rust-core
|
|
|
|
- name: Install dependencies
|
|
run: bash scripts/ci-cancel-aware.sh pnpm install --frozen-lockfile
|
|
|
|
- name: Save pnpm store cache
|
|
if: always() && steps.pnpm-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ steps.pnpm-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Ensure .env exists for tests
|
|
run: |
|
|
touch .env
|
|
touch app/.env
|
|
|
|
- name: Run Rust E2E suite
|
|
run: bash scripts/ci-cancel-aware.sh pnpm test:rust:e2e
|
|
env:
|
|
RUST_BACKTRACE: "1"
|
|
|
|
playwright-e2e:
|
|
name: E2E (Playwright / web lane ${{ matrix.shard }}/4)
|
|
needs: [frontend-quality, rust-quality, build-playwright-e2e-artifact]
|
|
runs-on: ubuntu-22.04
|
|
container:
|
|
image: ghcr.io/tinyhumansai/openhuman_ci:latest
|
|
timeout-minutes: 30
|
|
# Sharded 4 ways: each shard is a separate runner that boots its OWN backend
|
|
# stack (mock + core + web on fixed ports) and runs playwright --shard=i/4.
|
|
# Because each shard is an isolated machine there is no shared mock-state
|
|
# race, so this parallelises safely despite the suite's workers:1 design.
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2, 3, 4]
|
|
# TODO(ci-flaky): the web lane currently times out on ~7 specs under CI
|
|
# contention (accounts-provider-modal, connector-gmail-composio, gmail-flow,
|
|
# harness-cron-prompt-flow, insights-dashboard, skills-registry). Run it but
|
|
# don't block the merge until those flakes are fixed — remove this then.
|
|
continue-on-error: true
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 1
|
|
persist-credentials: false
|
|
submodules: recursive
|
|
|
|
- name: Cache pnpm store
|
|
id: pnpm-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
pnpm-store-${{ runner.os }}-
|
|
|
|
- name: Install JS dependencies (test harness)
|
|
run: bash scripts/ci-cancel-aware.sh pnpm install --frozen-lockfile
|
|
|
|
- name: Save pnpm store cache
|
|
if: always() && steps.pnpm-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ steps.pnpm-cache.outputs.cache-primary-key }}
|
|
|
|
- name: Download Playwright E2E artifact
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: e2e-playwright-linux-${{ github.run_id }}
|
|
path: .
|
|
|
|
- name: Restore Playwright E2E artifact
|
|
run: |
|
|
set -euo pipefail
|
|
tar -xzf e2e-playwright-linux.tar.gz
|
|
cp -a repo/app/dist-web app/
|
|
mkdir -p target
|
|
cp -a repo/target/. target/
|
|
rm -rf repo e2e-playwright-linux.tar.gz
|
|
chmod +x target/e2e-web-*/debug/openhuman-core
|
|
|
|
- name: Install Playwright Chromium headless shell
|
|
run: bash scripts/ci-cancel-aware.sh pnpm --filter openhuman-app exec playwright install chromium-headless-shell
|
|
|
|
- name: Run Playwright web E2E suite (shard ${{ matrix.shard }}/4)
|
|
env:
|
|
OPENHUMAN_WORKSPACE: ${{ runner.temp }}/openhuman-playwright-workspace
|
|
run: |
|
|
mkdir -p "$OPENHUMAN_WORKSPACE"
|
|
bash scripts/ci-cancel-aware.sh bash app/scripts/e2e-web-session.sh \
|
|
--shard=${{ matrix.shard }}/4
|
|
|
|
- name: Upload Playwright E2E failure artifacts
|
|
if: failure()
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: e2e-playwright-failure-logs-${{ github.run_id }}-shard${{ matrix.shard }}
|
|
path: |
|
|
${{ runner.temp }}/openhuman-playwright-workspace/**
|
|
retention-days: 7
|
|
if-no-files-found: ignore
|
|
|
|
playwright-e2e-gate:
|
|
name: Playwright E2E Gate
|
|
# Fixed-name aggregator over the 4 dynamic shard checks. Branch protection
|
|
# can require this single job instead of the per-shard matrix names (which
|
|
# change if the shard count changes). if: always() so it runs even when a
|
|
# shard is failed/skipped and can report the real aggregate result.
|
|
needs: [playwright-e2e]
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Require all Playwright shards to pass
|
|
run: |
|
|
result="${{ needs.playwright-e2e.result }}"
|
|
echo "Playwright web lane aggregate result: ${result}"
|
|
# NOTE: the shards currently carry continue-on-error: true, so this
|
|
# aggregate is 'success' even when a shard hit a known flake — the
|
|
# gate passes today. Once continue-on-error is removed from the shards
|
|
# (after the flakes are fixed) this same check enforces a real pass.
|
|
if [ "${result}" = "success" ]; then
|
|
echo "Playwright shards passed."
|
|
exit 0
|
|
fi
|
|
echo "::error::Playwright web lane did not succeed (result=${result})."
|
|
exit 1
|
|
|
|
coverage-gate:
|
|
name: Coverage Gate (diff-cover >= 80%)
|
|
needs: [frontend-coverage, rust-core-coverage, rust-tauri-coverage]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Resolve coverage compare ref
|
|
id: coverage-compare
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
git fetch origin "${{ github.base_ref }}" --depth=200
|
|
echo "ref=origin/${{ github.base_ref }}" >> "$GITHUB_OUTPUT"
|
|
elif [ -n "${{ github.event.before }}" ] && [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
|
|
echo "ref=${{ github.event.before }}" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "ref=HEAD^" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install diff-cover
|
|
run: pip install 'diff-cover>=9.2.0'
|
|
|
|
- name: Download all lcov artifacts
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
path: lcov-artifacts
|
|
pattern: lcov-*
|
|
merge-multiple: false
|
|
|
|
- name: List collected lcov files
|
|
run: |
|
|
set -euo pipefail
|
|
find lcov-artifacts -type f -name '*.info' -print
|
|
|
|
- name: Enforce >= 80% coverage on changed lines
|
|
run: |
|
|
set -euo pipefail
|
|
mapfile -t LCOV_FILES < <(find lcov-artifacts -type f -name '*.info' | sort)
|
|
if [ "${#LCOV_FILES[@]}" -eq 0 ]; then
|
|
echo "::error::No lcov files found; coverage gate cannot run"
|
|
exit 1
|
|
fi
|
|
diff-cover "${LCOV_FILES[@]}" \
|
|
--compare-branch="${{ steps.coverage-compare.outputs.ref }}" \
|
|
--fail-under=80 \
|
|
--html-report diff-coverage.html \
|
|
--markdown-report diff-coverage.md
|
|
|
|
- name: Upload diff-cover report
|
|
if: always()
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: diff-coverage-report
|
|
path: |
|
|
diff-coverage.html
|
|
diff-coverage.md
|
|
retention-days: 14
|
|
if-no-files-found: warn
|