# インフラ構成図

## 全体構成図

```mermaid
graph TB
    subgraph "開発者環境"
        DEV[開発者PC]
        GITPOD[Gitpod]
        CODESANDBOX[CodeSandbox]
    end

    subgraph "ソースコード管理"
        GITHUB[GitHub<br/>babel/babel]
    end

    subgraph "CI/CD プラットフォーム"
        subgraph "GitHub Actions"
            GA_UBUNTU[ubuntu-latest<br/>ランナー]
            GA_WINDOWS[windows-latest<br/>ランナー]
            GA_MACOS[macos-latest<br/>ランナー]
        end

        subgraph "CircleCI"
            CIRCLECI[cimg/node:current<br/>Executor]
        end
    end

    subgraph "配布・公開サービス"
        NPM[npm Registry]
        PKGPR[pkg.pr.new]
    end

    subgraph "品質・監視サービス"
        CODECOV[Codecov]
        RENOVATE[Renovate Bot]
    end

    DEV --> |push/PR| GITHUB
    GITPOD --> |push/PR| GITHUB
    CODESANDBOX --> |CI統合| GITHUB

    GITHUB --> |トリガー| GA_UBUNTU
    GITHUB --> |トリガー| GA_WINDOWS
    GITHUB --> |トリガー| GA_MACOS
    GITHUB --> |トリガー| CIRCLECI

    GA_UBUNTU --> |publish| NPM
    GA_UBUNTU --> |preview| PKGPR
    GA_UBUNTU --> |coverage| CODECOV
    CIRCLECI --> |artifacts| GITHUB

    RENOVATE --> |PR作成| GITHUB
```

## CI/CD パイプライン構成

```mermaid
flowchart LR
    subgraph "トリガー"
        PUSH[push]
        PR[pull_request]
        TAG[tag v*]
        MANUAL[workflow_dispatch]
    end

    subgraph "ビルドステージ"
        CACHE[Prepare Cache]
        VALIDATE[Yarn Validate]
        BUILD[Build Babel<br/>Artifacts]
        BUILD_WIN[Build on<br/>Windows]
        BUILD_B9[Build Babel 9<br/>Artifacts]
    end

    subgraph "テストステージ"
        LINT[Lint]
        LINT_B9[Lint Babel 9]
        TEST_COV[Test with<br/>Coverage]
        TEST_MATRIX[Test on<br/>Node 20/22/24]
        TEST_B9[Test Babel 9]
        TEST_WINOS[Test on<br/>Windows/macOS]
        PARSER[Third-party<br/>Parser Tests]
        RUNTIME[Runtime<br/>Integration]
        TEST262[test262<br/>8 Chunks]
        E2E[E2E Tests]
    end

    subgraph "リリースステージ"
        VERSION[Create Git Tag]
        NPM_PUB[Publish to npm]
        GH_REL[GitHub Release]
        GH_PUSH[Push to main]
    end

    PUSH --> CACHE
    PR --> CACHE
    TAG --> VERSION
    MANUAL --> VERSION

    CACHE --> VALIDATE
    CACHE --> BUILD
    CACHE --> BUILD_B9

    BUILD --> LINT
    BUILD --> TEST_COV
    BUILD --> TEST_MATRIX
    BUILD --> TEST_WINOS
    BUILD --> PARSER
    BUILD --> RUNTIME
    BUILD --> TEST262
    BUILD --> E2E

    BUILD_WIN --> |確認| BUILD

    BUILD_B9 --> LINT_B9
    BUILD_B9 --> TEST_B9

    VERSION --> NPM_PUB
    NPM_PUB --> GH_REL
    GH_REL --> GH_PUSH
```

## ワークフロー依存関係

```mermaid
graph TD
    subgraph "ci.yml"
        PC[prepare-yarn-cache]
        YV[yarn-validate]
        B[build]
        BW[build-windows]
        B9[build-babel9]

        L[lint]
        TC[test-coverage]
        T[test]
        TWM[test-windows-mac]

        L9[lint-babel9]
        T9C[test-babel9-coverage]
        T9WM[test-babel9-windows-mac]

        EPT[external-parser-tests]
        RIP[runtime-interop-prepare]
        RI[runtime-interop]
        EVT[eslint-version-test]

        T262P[test262-prepare]
        T262[test262]
        T262F[test262-finish]

        ENPE[ensure-npm-packages-exist]
    end

    PC --> YV
    PC --> B
    PC --> B9

    B --> L
    B --> TC
    B --> T
    B --> TWM
    B --> EPT
    B --> RIP
    B --> EVT
    B --> T262

    B9 --> L9
    B9 --> T9C
    B9 --> T9WM

    RIP --> RI

    T262P --> T262
    T262 --> T262F

    YV --> ENPE
```

## テスト実行マトリクス

```mermaid
graph LR
    subgraph "Node.js バージョン"
        N20[Node 20]
        N22[Node 22]
        N24[Node 24]
        N25[Node 25.6.1]
    end

    subgraph "OS"
        UBUNTU[Ubuntu]
        WINDOWS[Windows]
        MACOS[macOS]
    end

    subgraph "Babel バージョン"
        B7[Babel 7/8]
        B9[Babel 9]
    end

    N20 --> UBUNTU
    N22 --> UBUNTU
    N24 --> UBUNTU
    N25 --> UBUNTU
    N25 --> WINDOWS
    N25 --> MACOS

    UBUNTU --> B7
    UBUNTU --> B9
    WINDOWS --> B7
    WINDOWS --> B9
    MACOS --> B7
    MACOS --> B9
```

## E2E テスト構成

```mermaid
flowchart TB
    subgraph "E2E パイプライン"
        PUB[Publish to Verdaccio]

        subgraph "テストマトリクス"
            BABEL[babel]
            CRA[create-react-app]
            ANGULAR[angular-cli]
            PRETTIER[prettier]
        end
    end

    subgraph "Verdaccio"
        REG[localhost:4873<br/>Local npm Registry]
    end

    PUB --> REG
    REG --> BABEL
    REG --> CRA
    REG --> ANGULAR
    REG --> PRETTIER
```

## リリースフロー

```mermaid
sequenceDiagram
    participant Dev as 開発者/Bot
    participant GH as GitHub
    participant GA as GitHub Actions
    participant NPM as npm Registry

    Dev->>GH: git tag v* / workflow_dispatch
    GH->>GA: release.yml トリガー

    GA->>GA: ensure-npm-packages-exist
    GA->>GA: git-version (タグ作成)
    GA->>GA: Build & Test (prepublish)
    GA->>NPM: yarn release-tool publish
    GA->>GH: GitHub Release 作成
    GA->>GH: CHANGELOG.md 更新
    GA->>GH: main ブランチへプッシュ
```

## 外部サービス連携

```mermaid
graph TB
    subgraph "Babel リポジトリ"
        REPO[babel/babel]
    end

    subgraph "CI サービス"
        GA[GitHub Actions]
        CIRCLE[CircleCI]
    end

    subgraph "品質サービス"
        CODECOV[Codecov<br/>カバレッジ 90%+]
        RENOVATE[Renovate<br/>依存関係更新]
    end

    subgraph "配布サービス"
        NPM[npm Registry<br/>@babel/* packages]
        PKGPR[pkg.pr.new<br/>PRプレビュー]
    end

    subgraph "開発サービス"
        GITPOD[Gitpod<br/>クラウドIDE]
        CODESANDBOX[CodeSandbox<br/>サンドボックス]
    end

    subgraph "外部テスト"
        TEST262[TC39 test262]
        FLOW[Flow Parser]
        TS[TypeScript Parser]
    end

    REPO --> GA
    REPO --> CIRCLE

    GA --> CODECOV
    RENOVATE --> REPO

    GA --> NPM
    GA --> PKGPR

    GITPOD --> REPO
    CODESANDBOX --> REPO

    GA --> TEST262
    GA --> FLOW
    GA --> TS
```

## キャッシュ戦略

```mermaid
graph LR
    subgraph "キャッシュ対象"
        YARN[~/.yarn/berry/cache]
        NODE[node_modules]
    end

    subgraph "キャッシュキー"
        KEY1["v2-yarn-cache-{checksum}"]
        KEY2["yarn.lock hash"]
    end

    subgraph "CI プラットフォーム"
        GA[GitHub Actions<br/>actions/setup-node cache]
        CIRCLE[CircleCI<br/>restore_cache/save_cache]
    end

    YARN --> KEY1
    KEY1 --> CIRCLE

    YARN --> KEY2
    KEY2 --> GA
```

## アーティファクト管理

```mermaid
graph TB
    subgraph "ビルドアーティファクト"
        BA[babel-artifact<br/>保持: 5日]
        B9A[babel9-artifact<br/>保持: 5日]
    end

    subgraph "テストアーティファクト"
        T262C[test262-chunks<br/>保持: 30日]
        T262R[test262-result-*<br/>保持: 30日]
        T262[test262-result<br/>保持: 30日]
    end

    subgraph "E2E アーティファクト"
        VER[verdaccio-workspace<br/>保持: 1日]
    end

    subgraph "CircleCI アーティファクト"
        STANDALONE[babel-standalone/*.js]
        SOURCEMAP[babel-standalone/*.js.map]
    end

    BA --> |ダウンロード| T262
    B9A --> |ダウンロード| T262
    T262C --> T262R
    T262R --> T262
    VER --> |E2Eテスト| BA
```
