Skip to content

Merge pull request #733 from AugurProject/t3code/align-liquidator-rpc… #1420

Merge pull request #733 from AugurProject/t3code/align-liquidator-rpc…

Merge pull request #733 from AugurProject/t3code/align-liquidator-rpc… #1420

Workflow file for this run

name: CI Gate
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BUN_VERSION: 1.3.14
FOUNDRY_VERSION: v1.5.1
jobs:
changes:
name: Classify changes
runs-on: ubuntu-latest
outputs:
heavy: ${{ steps.scope.outputs.heavy }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Select CI scope
id: scope
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
if [[ "${GITHUB_EVENT_NAME}" != "pull_request" ]]; then
bun scripts/classify-ci-change.mts --github-output package.json
exit 0
fi
bun scripts/classify-ci-change.mts --github-output --base-ref "${BASE_SHA}"
prepare:
name: Prepare
needs: changes
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up CI
uses: ./.github/actions/setup-ci
with:
verify-generated: "true"
- name: Format
run: bun run format
- name: Cache TypeScript incremental state
uses: actions/cache@v5
with:
path: .tsbuildinfo
key: ${{ runner.os }}-tsbuildinfo-${{ env.BUN_VERSION }}-${{ hashFiles('bun.lock', 'package.json', 'tsconfig.json') }}-${{ hashFiles('shared/ts/**', 'ui/ts/**') }}
restore-keys: |
${{ runner.os }}-tsbuildinfo-${{ env.BUN_VERSION }}-${{ hashFiles('bun.lock', 'package.json', 'tsconfig.json') }}-
- name: Verify pre-task worktree cleanliness
run: |
if ! git diff --exit-code -- .; then
echo 'Generated files or formatting changed tracked files. Run the relevant command locally and commit the result.'
exit 1
fi
if [[ -n "$(git status --porcelain --untracked-files=normal)" ]]; then
git status --short
echo 'CI generated untracked files. Commit them or update .gitignore as appropriate.'
exit 1
fi
git diff --check
- name: TypeScript checks and production UI build
shell: bash
run: |
started_at="${SECONDS}"
set +e
bun run ci:preflight:current
status="$?"
set -e
duration="$((SECONDS - started_at))"
echo "| Preflight and production build | ${duration}s |" >> "${GITHUB_STEP_SUMMARY}"
exit "${status}"
- name: Upload production UI build
uses: actions/upload-artifact@v4
with:
name: production-ui
path: ui/dist
if-no-files-found: error
retention-days: 1
- name: Verify final worktree cleanliness
if: ${{ always() }}
run: |
if ! git diff --exit-code -- .; then
echo 'CI left tracked file changes. Commit intended changes or fix generated output churn.'
exit 1
fi
if [[ -n "$(git status --porcelain --untracked-files=normal)" ]]; then
git status --short
echo 'CI generated untracked files. Commit them or update .gitignore as appropriate.'
exit 1
fi
git diff --check
tests:
name: Tests (${{ matrix.shard }}/${{ strategy.job-total }})
needs: [changes, prepare]
if: needs.changes.outputs.heavy == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: true
matrix:
shard: [1, 2, 3, 4]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up CI
uses: ./.github/actions/setup-ci
- name: Download production UI build
uses: actions/download-artifact@v5
with:
name: production-ui
path: ui/dist
- name: Restore historical test timings
uses: actions/cache/restore@v5
with:
path: .ci/test-timings.json
key: ${{ runner.os }}-test-timings-v1-${{ github.sha }}
restore-keys: |
${{ runner.os }}-test-timings-v1-
- name: Run balanced test shard
shell: bash
env:
SHARD: ${{ matrix.shard }}
SHARD_COUNT: ${{ strategy.job-total }}
ZOLTAR_USE_EXISTING_PRODUCTION_BUILD: "1"
ZOLTAR_TEST_TIMING_HISTORY: .ci/test-timings.json
ZOLTAR_TEST_TIMING_OUTPUT: test-results/shard-${{ matrix.shard }}.timing.json
run: |
started_at="${SECONDS}"
set +e
bun run test:run:balanced-shard -- --bail=1 --parallel=1 --shard="${SHARD}/${SHARD_COUNT}"
status="$?"
set -e
duration="$((SECONDS - started_at))"
echo "### Test shard ${SHARD}/${SHARD_COUNT}" >> "${GITHUB_STEP_SUMMARY}"
echo "" >> "${GITHUB_STEP_SUMMARY}"
echo "Elapsed: ${duration}s" >> "${GITHUB_STEP_SUMMARY}"
exit "${status}"
- name: Upload test timing observation
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: test-timing-${{ matrix.shard }}
path: test-results/shard-${{ matrix.shard }}.timing.json
if-no-files-found: error
retention-days: 1
test-timings:
name: Update test timing history
needs: [changes, tests]
if: needs.changes.outputs.heavy == 'true' && needs.tests.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Restore historical test timings
uses: actions/cache/restore@v5
with:
path: .ci/test-timings.json
key: ${{ runner.os }}-test-timings-v1-${{ github.sha }}
restore-keys: |
${{ runner.os }}-test-timings-v1-
- name: Download test timing observations
uses: actions/download-artifact@v5
with:
pattern: test-timing-*
path: test-results
merge-multiple: true
- name: Merge test timing history
run: bun ./scripts/merge-test-timings.mts --observations test-results --history .ci/test-timings.json
- name: Save test timing history
uses: actions/cache/save@v5
with:
path: .ci/test-timings.json
key: ${{ runner.os }}-test-timings-v1-${{ github.sha }}
checks:
name: Repository checks
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up CI
uses: ./.github/actions/setup-ci
- name: Run repository checks
run: bun run check:ci:current
knip:
name: Dead code analysis
needs: changes
if: needs.changes.outputs.heavy == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up CI
uses: ./.github/actions/setup-ci
- name: Run Knip
run: bun run knip
audit:
name: Dependency audit
needs: changes
if: needs.changes.outputs.heavy == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Run dependency audits
run: bun audit && (cd ui && bun audit) && (cd solidity && bun audit)
required:
name: Required
if: ${{ always() }}
needs: [changes, prepare, tests, test-timings, checks, knip, audit]
runs-on: ubuntu-latest
steps:
- name: Verify required jobs
env:
HEAVY: ${{ needs.changes.outputs.heavy }}
CHANGES_RESULT: ${{ needs.changes.result }}
PREPARE_RESULT: ${{ needs.prepare.result }}
TESTS_RESULT: ${{ needs.tests.result }}
TEST_TIMINGS_RESULT: ${{ needs.test-timings.result }}
CHECKS_RESULT: ${{ needs.checks.result }}
KNIP_RESULT: ${{ needs.knip.result }}
AUDIT_RESULT: ${{ needs.audit.result }}
run: |
if [[ "${CHANGES_RESULT}" != "success" || "${PREPARE_RESULT}" != "success" || "${CHECKS_RESULT}" != "success" ]]; then
echo "Required base job failed: changes=${CHANGES_RESULT}, prepare=${PREPARE_RESULT}, checks=${CHECKS_RESULT}."
exit 1
fi
if [[ "${HEAVY}" == "true" && ( "${TESTS_RESULT}" != "success" || "${TEST_TIMINGS_RESULT}" != "success" || "${KNIP_RESULT}" != "success" || "${AUDIT_RESULT}" != "success" ) ]]; then
echo "Required full-suite job failed: tests=${TESTS_RESULT}, test-timings=${TEST_TIMINGS_RESULT}, knip=${KNIP_RESULT}, audit=${AUDIT_RESULT}."
exit 1
fi
echo "All required CI jobs passed."