name: CI full build + e2e (Ubicloud)

# Main/PR gate: build all 6 KiCad WASM tools + run the wxWidgets + KiCad e2e
# suites on a Ubicloud runner. The actual recipe lives in the reusable
# wasm-build.yml (the SINGLE build definition) — this is just the main/PR caller.
# The tag release (release.yml) calls the same recipe with the same inputs and
# then publishes, so the build can never diverge from what ships.
#
# Routine edits under scripts/ do NOT bust the WASM output cache — only the subset
# in scripts/deploy/wasm-cache-hash.mjs does. For inputs the sc-hash can't see
# (base-image / apt drift, a bad cache) bump .ci-cache-epoch; for a one-off
# rebuild put [no-cache] or [rebuild-wasm] in the commit message / PR title.
#
# site/** is ignored: the Astro marketing site shares no build inputs with the
# WASM tools and ships from its own deploy-site.yml. Without the exclusion every
# blog post or landing-page tweak queued a full 6-tool build + both e2e suites —
# and since concurrency never cancels, a multi-commit push stacked them up.

on:
  push:
    branches: ["main", "ubicloud-ci"]
    paths-ignore: ["docs/**", "**.md", "site/**"]
  pull_request:
    branches: ["main"]
    paths-ignore: ["docs/**", "**.md", "site/**"]
  workflow_dispatch:
    inputs:
      no_cache:
        description: "Bypass the KiCad WASM output cache (force a full rebuild this run)"
        type: boolean
        required: false
        default: false

concurrency:
  # Per-ref: a new push queues behind its own in-flight run (don't cancel).
  group: ci-ubicloud-${{ github.ref }}
  cancel-in-progress: false

jobs:
  build:
    uses: ./.github/workflows/wasm-build.yml
    # Pass repo secrets (DISCORD_WEBHOOK_URL) through to the reusable build so the
    # post-test step can post the screenshot + perf report on push to main.
    secrets: inherit
    with:
      # 3D viewer ON so 3d-viewer.spec.ts has a viewer.
      build_3d_viewer: "ON"
      run_tests: true
      no_cache: ${{ inputs.no_cache || false }}
