# インフラ構成図

## 全体構成図

```mermaid
flowchart TB
    subgraph "開発者環境"
        DEV[開発者]
    end

    subgraph "GitHub"
        GH_REPO[GitHub Repository<br/>jestjs/jest]
        GH_ACTIONS[GitHub Actions]
        GH_ISSUES[Issues/PRs]
    end

    subgraph "CI/CD Pipeline"
        subgraph "テスト実行環境"
            UBUNTU[Ubuntu Runner<br/>4シャード並列]
            MACOS[macOS Runner<br/>3シャード並列]
            WINDOWS[Windows Runner<br/>4シャード並列]
        end

        subgraph "Node.js マトリクス"
            NODE18[Node.js 18.x]
            NODE20[Node.js 20.x]
            NODE22[Node.js 22.x]
            NODE24[Node.js 24.x]
        end
    end

    subgraph "外部サービス"
        NPM[npm Registry]
        CODECOV[Codecov]
        NETLIFY[Netlify]
        CROWDIN[Crowdin]
    end

    subgraph "ドキュメントサイト"
        DOCS[jestjs.io<br/>Docusaurus]
        CDN[Netlify CDN]
    end

    DEV -->|git push| GH_REPO
    GH_REPO -->|trigger| GH_ACTIONS
    GH_ACTIONS --> UBUNTU
    GH_ACTIONS --> MACOS
    GH_ACTIONS --> WINDOWS

    UBUNTU --> NODE18
    UBUNTU --> NODE20
    UBUNTU --> NODE22
    UBUNTU --> NODE24

    MACOS --> NODE18
    MACOS --> NODE20
    MACOS --> NODE22
    MACOS --> NODE24

    WINDOWS --> NODE18
    WINDOWS --> NODE20
    WINDOWS --> NODE22
    WINDOWS --> NODE24

    GH_ACTIONS -->|coverage upload| CODECOV
    GH_ACTIONS -->|npm publish| NPM
    GH_REPO -->|webhook| NETLIFY
    NETLIFY -->|build| DOCS
    DOCS --> CDN
    CROWDIN -->|translations| DOCS
```

## CI/CD パイプライン詳細図

```mermaid
flowchart LR
    subgraph "Trigger"
        PUSH[git push main]
        PR[Pull Request]
        MG[Merge Group]
        SCHEDULE[Schedule<br/>0 12 * * *]
    end

    subgraph "Cache Preparation"
        CACHE_UB[prepare-cache<br/>Ubuntu]
        CACHE_MAC[prepare-cache<br/>macOS]
        CACHE_WIN[prepare-cache<br/>Windows]
    end

    subgraph "Static Checks"
        LINT[ESLint]
        PRETTIER[Prettier]
        TYPECHECK[TypeCheck]
        CHANGELOG[Changelog Check]
        COPYRIGHT[Copyright Headers]
        CONSTRAINTS[Yarn Constraints]
    end

    subgraph "Test Matrix"
        TEST_UB[test-ubuntu<br/>4 shards]
        TEST_MAC[test-macos<br/>3 shards]
        TEST_WIN[test-windows<br/>4 shards]
    end

    subgraph "Additional Tests"
        TS_COMPAT[TypeScript<br/>Compatibility]
        LEAK[Leak Detection]
        COVERAGE[Coverage<br/>4 shards]
        JASMINE[jest-jasmine2]
    end

    subgraph "Reporting"
        CODECOV_UP[Codecov Upload]
        FAIL_ISSUE[Failed Build Issue]
    end

    PUSH --> CACHE_UB
    PUSH --> CACHE_MAC
    PUSH --> CACHE_WIN
    PR --> CACHE_UB
    PR --> CACHE_MAC
    PR --> CACHE_WIN
    MG --> CACHE_UB
    MG --> CACHE_MAC
    MG --> CACHE_WIN

    CACHE_UB --> LINT
    CACHE_UB --> PRETTIER
    CACHE_UB --> TYPECHECK
    CACHE_UB --> CHANGELOG
    CACHE_UB --> COPYRIGHT
    CACHE_UB --> CONSTRAINTS
    CACHE_UB --> TS_COMPAT

    CACHE_UB --> TEST_UB
    CACHE_MAC --> TEST_MAC
    CACHE_WIN --> TEST_WIN

    CACHE_UB --> LEAK
    CACHE_UB --> COVERAGE

    TEST_UB --> JASMINE
    TEST_MAC --> JASMINE
    TEST_WIN --> JASMINE

    COVERAGE --> CODECOV_UP

    SCHEDULE --> FAIL_ISSUE
```

## ドキュメントサイト デプロイフロー

```mermaid
flowchart TB
    subgraph "Source"
        WEBSITE[website/]
        DOCS_DIR[docs/]
        NETLIFY_TOML[netlify.toml]
    end

    subgraph "Netlify Build"
        DETECT[変更検出<br/>git diff]
        BUILD_PROD[Production Build<br/>netlify:ci:production]
        BUILD_PREVIEW[Preview Build<br/>netlify:ci:deployPreview]
    end

    subgraph "Build Steps"
        FETCH[fetchSupporters]
        BUILD_JS[yarn build:js]
        CROWDIN_SYNC[Crowdin Sync]
        DOCUSAURUS[Docusaurus Build]
    end

    subgraph "Deploy"
        DEPLOY_PROD[Production Deploy<br/>jestjs.io]
        DEPLOY_PREVIEW[Deploy Preview<br/>*.netlify.app]
    end

    subgraph "Cache"
        NODE_MODULES[node_modules/.cache]
        YARN_CACHE[Yarn Global Cache]
    end

    WEBSITE -->|trigger| DETECT
    DOCS_DIR -->|trigger| DETECT
    NETLIFY_TOML -->|trigger| DETECT

    DETECT -->|main branch| BUILD_PROD
    DETECT -->|PR| BUILD_PREVIEW

    BUILD_PROD --> FETCH
    BUILD_PREVIEW --> FETCH
    FETCH --> BUILD_JS
    BUILD_JS --> CROWDIN_SYNC
    BUILD_JS --> DOCUSAURUS
    CROWDIN_SYNC --> DOCUSAURUS

    DOCUSAURUS -->|main| DEPLOY_PROD
    DOCUSAURUS -->|PR| DEPLOY_PREVIEW

    NODE_MODULES -.->|cache| BUILD_PROD
    NODE_MODULES -.->|cache| BUILD_PREVIEW
    YARN_CACHE -.->|cache| BUILD_PROD
    YARN_CACHE -.->|cache| BUILD_PREVIEW
```

## モノレポパッケージ構成図

```mermaid
flowchart TB
    subgraph "Entry Point"
        JEST[jest]
    end

    subgraph "CLI Layer"
        CLI[jest-cli]
        CREATE[create-jest]
    end

    subgraph "Core Layer"
        CORE[jest-core]
        CONFIG[jest-config]
        RUNTIME[jest-runtime]
    end

    subgraph "Test Runners"
        CIRCUS[jest-circus<br/>Default]
        JASMINE[jest-jasmine2<br/>Legacy]
    end

    subgraph "Assertion & Comparison"
        EXPECT[expect]
        EXPECT_UTILS[expect-utils]
        DIFF[jest-diff]
        DIFF_SEQ[diff-sequences]
        SNAPSHOT[jest-snapshot]
    end

    subgraph "Transform"
        BABEL_JEST[babel-jest]
        BABEL_PLUGIN[babel-plugin-jest-hoist]
        BABEL_PRESET[babel-preset-jest]
    end

    subgraph "Environment"
        ENV_NODE[jest-environment-node]
        ENV_JSDOM[jest-environment-jsdom]
        ENV_JSDOM_ABSTRACT[jest-environment-jsdom-abstract]
    end

    subgraph "Utilities"
        UTIL[jest-util]
        MOCK[jest-mock]
        WORKER[jest-worker]
        CONSOLE[jest-console]
        WATCHER[jest-watcher]
    end

    subgraph "Output"
        PRETTY[pretty-format]
    end

    JEST --> CLI
    CLI --> CORE
    CORE --> CONFIG
    CORE --> RUNTIME
    CORE --> CIRCUS
    CORE --> JASMINE

    CIRCUS --> EXPECT
    JASMINE --> EXPECT
    EXPECT --> EXPECT_UTILS
    EXPECT --> DIFF
    DIFF --> DIFF_SEQ

    RUNTIME --> BABEL_JEST
    BABEL_JEST --> BABEL_PLUGIN
    BABEL_JEST --> BABEL_PRESET

    RUNTIME --> ENV_NODE
    RUNTIME --> ENV_JSDOM
    ENV_JSDOM --> ENV_JSDOM_ABSTRACT

    CORE --> WORKER
    CORE --> CONSOLE
    CORE --> WATCHER

    EXPECT --> PRETTY
    SNAPSHOT --> PRETTY
```

## 自動化ワークフロー一覧

```mermaid
flowchart LR
    subgraph "Scheduled Workflows"
        NIGHTLY[nightly.yml<br/>毎日 12:00 UTC]
        STALE[close-stale.yml<br/>毎時]
        LOCK[lock.yml<br/>毎日 0:00 UTC]
    end

    subgraph "Event Workflows"
        NODEJS[nodejs.yml<br/>push/PR/merge]
        TEST[test.yml<br/>reusable]
        CACHE[prepare-cache.yml<br/>reusable]
        PKG_PR[pkg-pr-new.yml<br/>push/PR]
    end

    subgraph "Actions"
        NIGHTLY_ACTION[Nightly Node Test]
        STALE_ACTION[Stale Issue/PR Close]
        LOCK_ACTION[Thread Lock]
        CI_ACTION[CI Test Suite]
        PUBLISH_ACTION[Package Preview Publish]
    end

    NIGHTLY --> NIGHTLY_ACTION
    STALE --> STALE_ACTION
    LOCK --> LOCK_ACTION
    NODEJS --> CI_ACTION
    TEST --> CI_ACTION
    CACHE --> CI_ACTION
    PKG_PR --> PUBLISH_ACTION
```
