sailfork / t3code-github / .repos/ alchemy-effect/ .github/ workflows/ check.yml

name: Check

# Validates repository formatting, the type graph, and website docs.

on:
  push:
    branches: [main]
  pull_request:
    types: [opened, reopened, synchronize]
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: check-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  check:
    name: Check
    runs-on: blacksmith-8vcpu-ubuntu-2404
    steps:
      - name: Checkout repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Checkout distilled
        run: git submodule update --init --depth=1 --checkout -- submodules/distilled

      - name: Restore Astro build cache
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: website/node_modules/.astro
          key: website-astro-check-${{ runner.os }}-${{ github.event.pull_request.number || 'main' }}-${{ github.sha }}-${{ github.workflow }}-${{ github.run_attempt }}
          restore-keys: |
            website-astro-check-${{ runner.os }}-${{ github.event.pull_request.number || 'main' }}-${{ github.sha }}-
            website-astro-check-${{ runner.os }}-${{ github.event.pull_request.number || 'main' }}-
            website-astro-check-${{ runner.os }}-main-

      - name: Setup pnpm, Node.js, Bun and install dependencies
        uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
        with:
          cache: true
          install: true
          require-lockfile: true

      - name: Check formatting
        run: pnpm format:check

      - name: Check package versions
        run: pnpm validate:publish-packages

      - name: Typecheck
        run: pnpm typecheck

      # Must run after the type check: it reads distilled's emitted `lib/*.d.ts`,
      # and stale/missing declarations resolve to `any`.
      - name: Lint providers
        run: pnpm lint:providers

      # Type-aware, so it also needs the build above.
      - name: Run Lint
        run: pnpm lint

      - name: Run Node Utils tests
        run: pnpm -C packages/node-utils test

      - name: Run pkg tests
        run: pnpm -C packages/pkg test

      - name: Run core engine tests
        run: timeout 300 pnpm test test/plan.test.ts test/apply.test.ts --retry 0 --concurrency unbounded

      # In memory: no cloud credentials.
      - name: Run Domain tests
        run: timeout 240 pnpm test:integration test/Domain --retry 0

      - name: Test CLI launcher
        run: |
          timeout 240 pnpm test test/Cli/launcher.test.ts test/Cli/exitCodes.test.ts --retry 0 --concurrency 1
          timeout 120 pnpm test:integration test/Cli/ProviderCheckEnv.test.ts --retry 0 --concurrency 1

      - name: Check API JSDocs
        run: pnpm docs:check-jsdoc

      - name: Check package exports
        run: pnpm exports:check

      # An internal PR carrying `deploy-website` gets a full Astro build in
      # website.yml via StaticSite. That build runs the same output validators,
      # so avoid building the site a second time here. Forks still run this
      # check because they cannot access the preview deployment secrets.
      - name: Check website docs
        if: >-
          github.event.pull_request.head.repo.full_name != github.repository ||
          !contains(github.event.pull_request.labels.*.name, 'deploy-website')
        run: pnpm docs:check