ci: add selectable external CI runners (#3451)
This commit is contained in:
@@ -24,6 +24,8 @@ permissions:
|
||||
jobs:
|
||||
lint:
|
||||
name: Architecture boundaries do not regress
|
||||
# Checkout receives the short-lived job token. Keep this credential-bearing
|
||||
# path on GitHub-hosted capacity during the external-runner pilot.
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
@@ -33,11 +33,38 @@ permissions:
|
||||
packages: read
|
||||
|
||||
jobs:
|
||||
runner_plan:
|
||||
name: Plan external runner allocation
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
plan: ${{ steps.plan.outputs.plan }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Plan runner allocation
|
||||
id: plan
|
||||
uses: ./.github/actions/plan-external-runners
|
||||
with:
|
||||
workflow: backend
|
||||
run-id: ${{ github.run_id }}
|
||||
families: >-
|
||||
[{"name":"test","tier":"light"}]
|
||||
burst: ${{ vars.KANDEV_CI_EXTERNAL_ENABLED }}
|
||||
percent: ${{ vars.KANDEV_CI_EXTERNAL_PERCENT }}
|
||||
light-label: ${{ vars.KANDEV_CI_RUNNER_LIGHT }}
|
||||
standard-label: ${{ vars.KANDEV_CI_RUNNER_STANDARD }}
|
||||
|
||||
# The former trigger-level `paths:` list, applied one level down so a skip
|
||||
# still produces a conclusion. `.github/scripts/changed-paths.py` implements
|
||||
# the same last-match-wins semantics GitHub applies to `paths:`.
|
||||
changes:
|
||||
name: Detect relevant changes
|
||||
# Checkout receives the short-lived job token. Keep this credential-bearing
|
||||
# path on GitHub-hosted capacity during the external-runner pilot.
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
outputs:
|
||||
@@ -106,6 +133,8 @@ jobs:
|
||||
name: Backend Static Checks
|
||||
needs: changes
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
# Checkout receives the short-lived job token. Keep this credential-bearing
|
||||
# path on GitHub-hosted capacity during the external-runner pilot.
|
||||
runs-on: ubuntu-latest
|
||||
# Pre-baked image bundles Go, golangci-lint, go-licenses, Docker CLI, Node,
|
||||
# pnpm, and the Playwright base — see .github/docker/ci-base/Dockerfile.
|
||||
@@ -226,6 +255,8 @@ jobs:
|
||||
name: Backend Tests (${{ matrix.shard }}/2)
|
||||
needs: changes
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
# Checkout receives the short-lived job token. Keep this credential-bearing
|
||||
# path on GitHub-hosted capacity during the external-runner pilot.
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -334,11 +365,13 @@ jobs:
|
||||
if: always()
|
||||
shell: bash
|
||||
working-directory: ${{ github.workspace }}
|
||||
env:
|
||||
BACKEND_TEST_SHARD: ${{ matrix.shard }}
|
||||
run: |
|
||||
report_summary="$RUNNER_TEMP/backend-test-summary-${{ matrix.shard }}.md"
|
||||
report_summary="$RUNNER_TEMP/backend-test-summary-${BACKEND_TEST_SHARD}.md"
|
||||
: > "$report_summary"
|
||||
GITHUB_STEP_SUMMARY="$report_summary" \
|
||||
INPUT_FROMJSONFILE="$GITHUB_WORKSPACE/apps/backend/test-results-${{ matrix.shard }}.json" \
|
||||
INPUT_FROMJSONFILE="$GITHUB_WORKSPACE/apps/backend/test-results-${BACKEND_TEST_SHARD}.json" \
|
||||
INPUT_MODULEDIRECTORY="$GITHUB_WORKSPACE/apps/backend" \
|
||||
INPUT_OMIT="successful" \
|
||||
node ".github/vendor/go-test-action/dist/index.js"
|
||||
@@ -347,12 +380,14 @@ jobs:
|
||||
if: always()
|
||||
shell: bash
|
||||
working-directory: ${{ github.workspace }}
|
||||
env:
|
||||
BACKEND_TEST_SHARD: ${{ matrix.shard }}
|
||||
run: |
|
||||
python3 .github/scripts/bounded-step-summary.py \
|
||||
--input "$RUNNER_TEMP/backend-test-summary-${{ matrix.shard }}.md" \
|
||||
--input "$RUNNER_TEMP/backend-test-summary-${BACKEND_TEST_SHARD}.md" \
|
||||
--output "$GITHUB_STEP_SUMMARY" \
|
||||
--diagnostics-label "backend-test-results-${{ matrix.shard }}" \
|
||||
--diagnostics-url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts"
|
||||
--diagnostics-label "backend-test-results-${BACKEND_TEST_SHARD}" \
|
||||
--diagnostics-url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID#artifacts"
|
||||
|
||||
- name: Upload test artifacts
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
@@ -368,6 +403,8 @@ jobs:
|
||||
name: Backend (ambient integration env)
|
||||
needs: changes
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
# Checkout receives the short-lived job token. Keep this credential-bearing
|
||||
# path on GitHub-hosted capacity during the external-runner pilot.
|
||||
runs-on: ubuntu-latest
|
||||
# test_shards runs in the same clean container and never sets these vars,
|
||||
# so it cannot catch a package that starts reading them again — the class
|
||||
@@ -430,9 +467,10 @@ jobs:
|
||||
# `test-windows` were outside it before this workflow became a gate.
|
||||
test:
|
||||
name: Run Backend Tests
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ fromJSON(needs.runner_plan.outputs.plan).test_runner }}
|
||||
needs:
|
||||
- changes
|
||||
- runner_plan
|
||||
- static_checks
|
||||
- test_shards
|
||||
- test_ambient_env
|
||||
@@ -442,6 +480,7 @@ jobs:
|
||||
steps:
|
||||
- name: Require backend checks to pass
|
||||
env:
|
||||
RUNNER_PLAN_RESULT: ${{ needs.runner_plan.result }}
|
||||
CHANGES_RESULT: ${{ needs.changes.result }}
|
||||
STATIC_CHECKS_RESULT: ${{ needs.static_checks.result }}
|
||||
TEST_SHARDS_RESULT: ${{ needs.test_shards.result }}
|
||||
@@ -451,6 +490,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
echo "Runner plan: ${RUNNER_PLAN_RESULT}"
|
||||
echo "Change detection: ${CHANGES_RESULT}"
|
||||
echo "Static checks: ${STATIC_CHECKS_RESULT}"
|
||||
echo "Test shards: ${TEST_SHARDS_RESULT}"
|
||||
@@ -458,6 +498,13 @@ jobs:
|
||||
echo "Postgres boot: ${POSTGRES_BOOT_RESULT}"
|
||||
echo "Windows tests: ${TEST_WINDOWS_RESULT}"
|
||||
|
||||
# Runner planning must succeed because its outputs select the runner
|
||||
# fleet. A planner error cannot silently become a hosted fallback.
|
||||
if [[ "${RUNNER_PLAN_RESULT}" != "success" ]]; then
|
||||
echo "Runner planning did not succeed; refusing to report a pass." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Change detection itself must succeed: if it errored we do not know
|
||||
# whether the skips below were deliberate.
|
||||
if [[ "${CHANGES_RESULT}" != "success" ]]; then
|
||||
|
||||
@@ -39,12 +39,47 @@ permissions:
|
||||
packages: read
|
||||
|
||||
jobs:
|
||||
runner_plan:
|
||||
name: Plan external runner allocation
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
plan: ${{ steps.plan.outputs.plan }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Plan runner allocation
|
||||
id: plan
|
||||
uses: ./.github/actions/plan-external-runners
|
||||
with:
|
||||
workflow: e2e
|
||||
run-id: ${{ github.run_id }}
|
||||
families: >-
|
||||
[
|
||||
{"name":"changes","tier":"light"},
|
||||
{"name":"e2e","tier":"standard","instances":[
|
||||
{"shard":1},{"shard":2},{"shard":3},{"shard":4},
|
||||
{"shard":5},{"shard":6},{"shard":7},{"shard":8},
|
||||
{"shard":9},{"shard":10},{"shard":11},{"shard":12},
|
||||
{"shard":13},{"shard":14}
|
||||
]},
|
||||
{"name":"e2e_gate","tier":"light"}
|
||||
]
|
||||
burst: ${{ vars.KANDEV_CI_EXTERNAL_ENABLED }}
|
||||
percent: ${{ vars.KANDEV_CI_EXTERNAL_PERCENT }}
|
||||
light-label: ${{ vars.KANDEV_CI_RUNNER_LIGHT }}
|
||||
standard-label: ${{ vars.KANDEV_CI_RUNNER_STANDARD }}
|
||||
|
||||
# The former trigger-level `paths:` list, applied one level down so a skip
|
||||
# still produces a conclusion. `.github/scripts/changed-paths.py` implements
|
||||
# the same last-match-wins semantics GitHub applies to `paths:`.
|
||||
changes:
|
||||
name: Detect relevant changes
|
||||
runs-on: ubuntu-latest
|
||||
needs: runner_plan
|
||||
runs-on: ${{ fromJSON(needs.runner_plan.outputs.plan).changes_runner }}
|
||||
timeout-minutes: 10
|
||||
outputs:
|
||||
run: ${{ steps.detect.outputs.run }}
|
||||
@@ -113,6 +148,8 @@ jobs:
|
||||
name: Build
|
||||
needs: changes
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
# Build reads the GitHub API and downloads a timing artifact with the job token.
|
||||
# Keep this credential-bearing path on the GitHub-hosted boundary.
|
||||
runs-on: ubuntu-latest
|
||||
# Pre-baked image bundles Go, Node 24, pnpm 9.15.9 — see
|
||||
# .github/docker/ci-base/Dockerfile. Uses the `build` tag (with Go)
|
||||
@@ -367,9 +404,9 @@ jobs:
|
||||
|
||||
e2e:
|
||||
name: E2E Shard ${{ matrix.shard }}/14
|
||||
needs: [changes, build]
|
||||
needs: [changes, build, runner_plan]
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.runner }}
|
||||
# Pre-baked image bundles Node 24, pnpm 9.15.9, and the Playwright browser
|
||||
# binaries (Chromium etc.) — see .github/docker/ci-base/Dockerfile. This is
|
||||
# the biggest speedup since `npx playwright install chromium --with-deps`
|
||||
@@ -398,8 +435,7 @@ jobs:
|
||||
NODE_OPTIONS: --dns-result-order=ipv4first
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
|
||||
matrix: ${{ fromJSON(needs.runner_plan.outputs.plan).e2e_matrix }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -467,9 +503,10 @@ jobs:
|
||||
working-directory: apps/web
|
||||
env:
|
||||
E2E_SHARD: ${{ matrix.shard }}
|
||||
E2E_MANIFEST_SHARD: ${{ matrix.shard }}
|
||||
KANDEV_E2E_BUILD_IDENTITY: ${{ github.workspace }}/apps/backend/bin/e2e-build-identity.json
|
||||
KANDEV_E2E_EXPECTED_SOURCE_REVISION: ${{ github.sha }}
|
||||
run: bash e2e/scripts/run-planned-shard.sh "$GITHUB_WORKSPACE/e2e-manifests/normal/${{ matrix.shard }}.json"
|
||||
run: bash e2e/scripts/run-planned-shard.sh "$GITHUB_WORKSPACE/e2e-manifests/normal/${E2E_MANIFEST_SHARD}.json"
|
||||
|
||||
- name: Upload blob report
|
||||
if: always()
|
||||
@@ -1104,6 +1141,8 @@ jobs:
|
||||
# reports to download, and the artifact step would fail on an empty run.
|
||||
# `e2e-gate` below, not this job, is what the merge queue waits on.
|
||||
if: always() && needs.changes.outputs.run == 'true'
|
||||
# Report aggregation queries GitHub history and downloads artifacts with the
|
||||
# job token, so it remains on a GitHub-hosted runner during the pilot.
|
||||
runs-on: ubuntu-latest
|
||||
# Pre-baked image bundles Node 24, pnpm 9.15.9, and the Playwright CLI.
|
||||
# `runtime` tag — no Go needed for merging blob reports.
|
||||
@@ -1473,10 +1512,11 @@ jobs:
|
||||
# count changes.
|
||||
e2e-gate:
|
||||
name: E2E Tests Passed
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ fromJSON(needs.runner_plan.outputs.plan).e2e_gate_runner }}
|
||||
needs:
|
||||
[
|
||||
changes,
|
||||
runner_plan,
|
||||
build,
|
||||
playwright_image,
|
||||
e2e,
|
||||
@@ -1490,6 +1530,7 @@ jobs:
|
||||
steps:
|
||||
- name: Require the E2E jobs to have passed or been skipped
|
||||
env:
|
||||
RUNNER_PLAN_RESULT: ${{ needs.runner_plan.result }}
|
||||
CHANGES_RESULT: ${{ needs.changes.result }}
|
||||
BUILD_RESULT: ${{ needs.build.result }}
|
||||
PLAYWRIGHT_IMAGE_RESULT: ${{ needs.playwright_image.result }}
|
||||
@@ -1502,6 +1543,7 @@ jobs:
|
||||
set -euo pipefail
|
||||
|
||||
echo "Change detection: ${CHANGES_RESULT}"
|
||||
echo "Runner plan: ${RUNNER_PLAN_RESULT}"
|
||||
echo "Build: ${BUILD_RESULT}"
|
||||
echo "Playwright image: ${PLAYWRIGHT_IMAGE_RESULT}"
|
||||
echo "E2E shards: ${E2E_RESULT}"
|
||||
@@ -1510,6 +1552,13 @@ jobs:
|
||||
echo "Desktop smoke: ${DESKTOP_E2E_RESULT}"
|
||||
echo "Report merge: ${E2E_REPORT_RESULT}"
|
||||
|
||||
# Runner planning must succeed because its outputs select the runner
|
||||
# fleet. A planner error cannot silently become a hosted fallback.
|
||||
if [[ "${RUNNER_PLAN_RESULT}" != "success" ]]; then
|
||||
echo "Runner planning did not succeed; refusing to report a pass." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Change detection itself must succeed: if it errored we do not know
|
||||
# whether the skips below were deliberate.
|
||||
if [[ "${CHANGES_RESULT}" != "success" ]]; then
|
||||
|
||||
@@ -29,12 +29,42 @@ permissions:
|
||||
packages: read
|
||||
|
||||
jobs:
|
||||
runner_plan:
|
||||
name: Plan external runner allocation
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
plan: ${{ steps.plan.outputs.plan }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Plan runner allocation
|
||||
id: plan
|
||||
uses: ./.github/actions/plan-external-runners
|
||||
with:
|
||||
workflow: frontend
|
||||
run-id: ${{ github.run_id }}
|
||||
families: >-
|
||||
[
|
||||
{"name":"changes","tier":"light"},
|
||||
{"name":"frontend","tier":"standard"},
|
||||
{"name":"frontend_gate","tier":"light"}
|
||||
]
|
||||
burst: ${{ vars.KANDEV_CI_EXTERNAL_ENABLED }}
|
||||
percent: ${{ vars.KANDEV_CI_EXTERNAL_PERCENT }}
|
||||
light-label: ${{ vars.KANDEV_CI_RUNNER_LIGHT }}
|
||||
standard-label: ${{ vars.KANDEV_CI_RUNNER_STANDARD }}
|
||||
|
||||
# The former trigger-level `paths:` list, applied one level down so a skip
|
||||
# still produces a conclusion. `.github/scripts/changed-paths.py` implements
|
||||
# the same last-match-wins semantics GitHub applies to `paths:`.
|
||||
changes:
|
||||
name: Detect relevant changes
|
||||
runs-on: ubuntu-latest
|
||||
needs: runner_plan
|
||||
runs-on: ${{ fromJSON(needs.runner_plan.outputs.plan).changes_runner }}
|
||||
timeout-minutes: 10
|
||||
outputs:
|
||||
run: ${{ steps.detect.outputs.run }}
|
||||
@@ -103,9 +133,9 @@ jobs:
|
||||
|
||||
frontend:
|
||||
name: Run Frontend Lint, Tests, and Build
|
||||
needs: changes
|
||||
needs: [changes, runner_plan]
|
||||
if: needs.changes.outputs.run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ fromJSON(needs.runner_plan.outputs.plan).frontend_runner }}
|
||||
# Pre-baked image bundles Node 24, pnpm 9.15.9, Go, and go-licenses —
|
||||
# see .github/docker/ci-base/Dockerfile.
|
||||
container: ghcr.io/kdlbs/kandev-ci:build-latest
|
||||
@@ -121,6 +151,7 @@ jobs:
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Mark workspace safe for git
|
||||
shell: bash
|
||||
@@ -353,22 +384,28 @@ jobs:
|
||||
# conclusion to read instead of a check that stays pending forever.
|
||||
frontend-gate:
|
||||
name: Frontend Tests Passed
|
||||
runs-on: ubuntu-latest
|
||||
needs: [changes, frontend]
|
||||
runs-on: ${{ fromJSON(needs.runner_plan.outputs.plan).frontend_gate_runner }}
|
||||
needs: [changes, frontend, runner_plan]
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Require the frontend job to have passed or been skipped
|
||||
env:
|
||||
RUNNER_PLAN_RESULT: ${{ needs.runner_plan.result }}
|
||||
CHANGES_RESULT: ${{ needs.changes.result }}
|
||||
FRONTEND_RESULT: ${{ needs.frontend.result }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
echo "Runner plan: ${RUNNER_PLAN_RESULT}"
|
||||
# `skipped` is a pass: the change-detection job decided nothing this
|
||||
# workflow covers was touched. `cancelled` is not — a cancelled job
|
||||
# never reached a verdict, and treating that as a pass would let an
|
||||
# untested merge group through.
|
||||
if [[ "${RUNNER_PLAN_RESULT}" != "success" ]]; then
|
||||
echo "Runner planning finished with result: ${RUNNER_PLAN_RESULT}" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${CHANGES_RESULT}" != "success" ]]; then
|
||||
echo "Change detection finished with result: ${CHANGES_RESULT}" >&2
|
||||
exit 1
|
||||
|
||||
@@ -34,6 +34,8 @@ permissions:
|
||||
jobs:
|
||||
lint:
|
||||
name: All action refs are SHA-pinned
|
||||
# Checkout receives the short-lived job token. Keep this credential-bearing
|
||||
# path on GitHub-hosted capacity during the external-runner pilot.
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -73,6 +75,12 @@ jobs:
|
||||
- name: Test E2E workflow contract
|
||||
run: python3 .github/scripts/e2e-tests-workflow-contract_test.py
|
||||
|
||||
- name: Test external runner workflow contract
|
||||
run: python3 .github/scripts/external-runner-workflow-contract_test.py
|
||||
|
||||
- name: Test external runner planner
|
||||
run: python3 .github/scripts/runner-plan_test.py
|
||||
|
||||
- name: Test bounded step summary
|
||||
run: python3 .github/scripts/bounded-step-summary_test.py
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ permissions:
|
||||
jobs:
|
||||
lint:
|
||||
name: Harness files pass lint
|
||||
# Checkout receives the short-lived job token. Keep this credential-bearing
|
||||
# path on GitHub-hosted capacity during the external-runner pilot.
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
Reference in New Issue
Block a user