ci: cut queue depth with path filters and smarter concurrency
Skip heavy jobs for docs-only and out-of-scope paths while keeping Product CI as the branch-protection gate. Cancel superseded PR image validation runs; on main cancel stale builds but serialize publish so attest/manifest steps are never interrupted. Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
This commit is contained in:
parent
6fc734b0ae
commit
eeec01cd0e
71
.github/workflows/ci.yml
vendored
71
.github/workflows/ci.yml
vendored
@ -5,6 +5,20 @@ name: ci
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- "apps/**"
|
||||||
|
- "packages/**"
|
||||||
|
- "infra/**"
|
||||||
|
- "scripts/**"
|
||||||
|
- "ops/**"
|
||||||
|
- ".github/**"
|
||||||
|
- "package.json"
|
||||||
|
- "pnpm-lock.yaml"
|
||||||
|
- "pnpm-workspace.yaml"
|
||||||
|
- "turbo.json"
|
||||||
|
- "biome.json"
|
||||||
|
- "vitest.config.ts"
|
||||||
|
- "tsconfig*.json"
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@ -15,8 +29,39 @@ concurrency:
|
|||||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
changes:
|
||||||
|
name: Detect product changes
|
||||||
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
|
outputs:
|
||||||
|
product: ${{ steps.filter.outputs.product }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: dorny/paths-filter@451258540fd6e81b87561f5d5adbd9863fc87cee # v3.0.2
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
product:
|
||||||
|
- 'apps/**'
|
||||||
|
- 'packages/**'
|
||||||
|
- 'infra/**'
|
||||||
|
- 'scripts/**'
|
||||||
|
- 'ops/**'
|
||||||
|
- '.github/**'
|
||||||
|
- 'package.json'
|
||||||
|
- 'pnpm-lock.yaml'
|
||||||
|
- 'pnpm-workspace.yaml'
|
||||||
|
- 'turbo.json'
|
||||||
|
- 'biome.json'
|
||||||
|
- 'vitest.config.ts'
|
||||||
|
- 'tsconfig*.json'
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.product == 'true'
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
@ -51,6 +96,8 @@ jobs:
|
|||||||
|
|
||||||
check:
|
check:
|
||||||
name: Typecheck
|
name: Typecheck
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.product == 'true'
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
@ -88,6 +135,8 @@ jobs:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
name: Production builds
|
name: Production builds
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.product == 'true'
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
@ -138,6 +187,8 @@ jobs:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
name: Unit tests
|
name: Unit tests
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.product == 'true'
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
@ -175,6 +226,8 @@ jobs:
|
|||||||
|
|
||||||
test-integration:
|
test-integration:
|
||||||
name: Postgres journeys
|
name: Postgres journeys
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.product == 'true'
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
@ -210,6 +263,8 @@ jobs:
|
|||||||
|
|
||||||
test-e2e:
|
test-e2e:
|
||||||
name: Web E2E
|
name: Web E2E
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.product == 'true'
|
||||||
uses: ./.github/workflows/playwright.yml
|
uses: ./.github/workflows/playwright.yml
|
||||||
with:
|
with:
|
||||||
upload_artifacts: true
|
upload_artifacts: true
|
||||||
@ -217,11 +272,12 @@ jobs:
|
|||||||
product-gate:
|
product-gate:
|
||||||
name: Product CI
|
name: Product CI
|
||||||
if: always()
|
if: always()
|
||||||
needs: [lint, check, build, test, test-integration, test-e2e]
|
needs: [changes, lint, check, build, test, test-integration, test-e2e]
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
steps:
|
steps:
|
||||||
- name: Verify product checks
|
- name: Verify product checks
|
||||||
env:
|
env:
|
||||||
|
PRODUCT: ${{ needs.changes.outputs.product }}
|
||||||
LINT: ${{ needs.lint.result }}
|
LINT: ${{ needs.lint.result }}
|
||||||
CHECK: ${{ needs.check.result }}
|
CHECK: ${{ needs.check.result }}
|
||||||
BUILD: ${{ needs.build.result }}
|
BUILD: ${{ needs.build.result }}
|
||||||
@ -230,11 +286,18 @@ jobs:
|
|||||||
TEST_E2E: ${{ needs.test-e2e.result }}
|
TEST_E2E: ${{ needs.test-e2e.result }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
if [[ "$PRODUCT" != "true" ]]; then
|
||||||
|
echo "No product-impacting paths changed; Product CI satisfied."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
failed=0
|
failed=0
|
||||||
for name in LINT CHECK BUILD TEST TEST_INTEGRATION TEST_E2E; do
|
for name in LINT CHECK BUILD TEST TEST_INTEGRATION TEST_E2E; do
|
||||||
result="${!name}"
|
result="${!name}"
|
||||||
printf '%s=%s\n' "$name" "$result"
|
printf '%s=%s\n' "$name" "$result"
|
||||||
if [[ "$result" != "success" ]]; then
|
if [[ "$result" == "skipped" ]]; then
|
||||||
|
echo "$name was skipped although product paths changed." >&2
|
||||||
|
failed=1
|
||||||
|
elif [[ "$result" != "success" ]]; then
|
||||||
failed=1
|
failed=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -246,9 +309,9 @@ jobs:
|
|||||||
|
|
||||||
publish-mobile-update:
|
publish-mobile-update:
|
||||||
name: Publish compatible mobile update
|
name: Publish compatible mobile update
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changes.outputs.product == 'true'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
needs: [lint, check, build, test, test-integration, test-e2e]
|
needs: [changes, lint, check, build, test, test-integration, test-e2e]
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
concurrency:
|
concurrency:
|
||||||
|
|||||||
69
.github/workflows/publish-server-image.yml
vendored
69
.github/workflows/publish-server-image.yml
vendored
@ -6,6 +6,17 @@ name: publish-server-image
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- ".dockerignore"
|
||||||
|
- ".github/workflows/publish-server-image.yml"
|
||||||
|
- "apps/**"
|
||||||
|
- "infra/compose/**"
|
||||||
|
- "infra/sandboxes/computer/**"
|
||||||
|
- "infra/updater/**"
|
||||||
|
- "packages/**"
|
||||||
|
- "package.json"
|
||||||
|
- "pnpm-lock.yaml"
|
||||||
|
- "pnpm-workspace.yaml"
|
||||||
tags: ["v*"]
|
tags: ["v*"]
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
@ -31,10 +42,51 @@ env:
|
|||||||
DOCKER_BUILD_RECORD_UPLOAD: false
|
DOCKER_BUILD_RECORD_UPLOAD: false
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: publish-server-image-${{ github.ref }}
|
group: publish-server-image-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}
|
||||||
cancel-in-progress: false
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
changes:
|
||||||
|
name: Detect image publish inputs
|
||||||
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
|
outputs:
|
||||||
|
publish: ${{ steps.decide.outputs.publish }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
fetch-depth: 0
|
||||||
|
- uses: dorny/paths-filter@451258540fd6e81b87561f5d5adbd9863fc87cee # v3.0.2
|
||||||
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
publish:
|
||||||
|
- '.dockerignore'
|
||||||
|
- '.github/workflows/publish-server-image.yml'
|
||||||
|
- 'apps/**'
|
||||||
|
- 'infra/compose/**'
|
||||||
|
- 'infra/sandboxes/computer/**'
|
||||||
|
- 'infra/updater/**'
|
||||||
|
- 'packages/**'
|
||||||
|
- 'package.json'
|
||||||
|
- 'pnpm-lock.yaml'
|
||||||
|
- 'pnpm-workspace.yaml'
|
||||||
|
- name: Decide whether release jobs should run
|
||||||
|
id: decide
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]] || [[ "${{ github.ref }}" == refs/tags/v* ]]; then
|
||||||
|
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||||
|
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||||
|
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||||
|
elif [[ "${{ steps.filter.outputs.publish }}" == "true" ]]; then
|
||||||
|
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "publish=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
installer-smoke:
|
installer-smoke:
|
||||||
name: Compose installer smokes
|
name: Compose installer smokes
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
@ -97,13 +149,17 @@ jobs:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build ${{ matrix.name }} ${{ matrix.arch }}
|
name: Build ${{ matrix.name }} ${{ matrix.arch }}
|
||||||
if: github.event_name != 'pull_request'
|
needs: changes
|
||||||
|
if: github.event_name != 'pull_request' && needs.changes.outputs.publish == 'true'
|
||||||
# Each architecture builds natively on its own runner and pushes by digest only.
|
# Each architecture builds natively on its own runner and pushes by digest only.
|
||||||
# amd64 on evo Linux runners. arm64 is paused: the macOS runners have no Docker buildx,
|
# amd64 on evo Linux runners. arm64 is paused: the macOS runners have no Docker buildx,
|
||||||
# and QEMU emulation took hours for the desktop-sized computer image.
|
# and QEMU emulation took hours for the desktop-sized computer image.
|
||||||
# See docs/self-host.md (Published images and tags).
|
# See docs/self-host.md (Published images and tags).
|
||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{ matrix.runner }}
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
|
concurrency:
|
||||||
|
group: publish-server-image-build-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.ref == 'refs/heads/main' }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
@ -174,10 +230,13 @@ jobs:
|
|||||||
|
|
||||||
publish:
|
publish:
|
||||||
name: Publish ${{ matrix.name }} image
|
name: Publish ${{ matrix.name }} image
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request' && needs.changes.outputs.publish == 'true'
|
||||||
needs: build
|
needs: [changes, build]
|
||||||
runs-on: [self-hosted, evoo-ci, Linux]
|
runs-on: [self-hosted, evoo-ci, Linux]
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
concurrency:
|
||||||
|
group: publish-server-image-publish-${{ github.ref == 'refs/heads/main' && 'main' || github.ref }}
|
||||||
|
cancel-in-progress: false
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|||||||
@ -22,6 +22,7 @@ describe("ci workflow merge gate", () => {
|
|||||||
it("aggregates only product jobs in Product CI", () => {
|
it("aggregates only product jobs in Product CI", () => {
|
||||||
const productGate = workflow.jobs["product-gate"];
|
const productGate = workflow.jobs["product-gate"];
|
||||||
expect(productGate?.needs).toEqual([
|
expect(productGate?.needs).toEqual([
|
||||||
|
"changes",
|
||||||
"lint",
|
"lint",
|
||||||
"check",
|
"check",
|
||||||
"build",
|
"build",
|
||||||
@ -29,6 +30,8 @@ describe("ci workflow merge gate", () => {
|
|||||||
"test-integration",
|
"test-integration",
|
||||||
"test-e2e",
|
"test-e2e",
|
||||||
]);
|
]);
|
||||||
|
expect(workflowText).toContain("needs.changes.outputs.product == 'true'");
|
||||||
|
expect(workflowText).toContain("No product-impacting paths changed; Product CI satisfied.");
|
||||||
expect(productGate?.if).toBe("always()");
|
expect(productGate?.if).toBe("always()");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ describe("server image publish workflow", () => {
|
|||||||
|
|
||||||
it("publishes one verified manifest per image after the build", () => {
|
it("publishes one verified manifest per image after the build", () => {
|
||||||
const publish = workflow.jobs.publish;
|
const publish = workflow.jobs.publish;
|
||||||
expect(publish.needs).toBe("build");
|
expect(publish.needs).toEqual(["changes", "build"]);
|
||||||
expect(workflowText).toContain("push-by-digest=true");
|
expect(workflowText).toContain("push-by-digest=true");
|
||||||
expect(workflowText).toContain("docker buildx imagetools create");
|
expect(workflowText).toContain("docker buildx imagetools create");
|
||||||
expect(workflowText).toContain(`if [[ "\${#sources[@]}" -ne 1 ]]`);
|
expect(workflowText).toContain(`if [[ "\${#sources[@]}" -ne 1 ]]`);
|
||||||
@ -75,8 +75,15 @@ describe("server image publish workflow", () => {
|
|||||||
const build = workflow.jobs.build;
|
const build = workflow.jobs.build;
|
||||||
const publish = workflow.jobs.publish;
|
const publish = workflow.jobs.publish;
|
||||||
expect(validate.if).toBe("github.event_name == 'pull_request'");
|
expect(validate.if).toBe("github.event_name == 'pull_request'");
|
||||||
expect(build.if).toBe("github.event_name != 'pull_request'");
|
expect(build.if).toBe(
|
||||||
expect(publish.if).toBe("github.event_name != 'pull_request'");
|
"github.event_name != 'pull_request' && needs.changes.outputs.publish == 'true'",
|
||||||
|
);
|
||||||
|
expect(publish.if).toBe(
|
||||||
|
"github.event_name != 'pull_request' && needs.changes.outputs.publish == 'true'",
|
||||||
|
);
|
||||||
|
expect(workflowText).toContain("cancel-in-progress: ${{ github.event_name == 'pull_request' }}");
|
||||||
|
expect(workflowText).toContain("publish-server-image-build-${{ github.ref }}");
|
||||||
|
expect(workflowText).toContain("publish-server-image-publish-${{ github.ref == 'refs/heads/main' && 'main' || github.ref }}");
|
||||||
expect(workflowText).toContain("push: false");
|
expect(workflowText).toContain("push: false");
|
||||||
for (const match of workflowText.matchAll(/uses:\s+([^\s#]+)/g)) {
|
for (const match of workflowText.matchAll(/uses:\s+([^\s#]+)/g)) {
|
||||||
expect(match[1], match[1]).toMatch(/@[0-9a-f]{40}$/);
|
expect(match[1], match[1]).toMatch(/@[0-9a-f]{40}$/);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user