# インフラ構成図

## 全体構成図

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

    subgraph "GitHub"
        REPO[nim-lang/Nim<br/>リポジトリ]
        PAGES[GitHub Pages<br/>ドキュメント]

        subgraph "GitHub Actions"
            GHA_DOCS[ci_docs.yml<br/>ドキュメントビルド]
            GHA_PKG[ci_packages.yml<br/>パッケージテスト]
            GHA_PUB[ci_publish.yml<br/>メモリ追跡]
            GHA_STALE[stale.yml<br/>PR管理]
            GHA_BISECT[bisects.yml<br/>二分探索]
        end
    end

    subgraph "Azure DevOps"
        AZ_PIPE[Azure Pipelines<br/>メインCI/CD]
    end

    subgraph "外部リソース"
        CSOURCES[csources_v3<br/>ブートストラップ]
        NIM_ORG[nim-lang.org<br/>依存配布]
    end

    DEV -->|push/PR| REPO
    REPO --> GHA_DOCS
    REPO --> GHA_PKG
    REPO --> GHA_PUB
    REPO --> GHA_STALE
    REPO --> GHA_BISECT
    REPO --> AZ_PIPE

    GHA_DOCS -->|デプロイ| PAGES

    AZ_PIPE -->|clone| CSOURCES
    GHA_PKG -->|clone| CSOURCES

    AZ_PIPE -->|download| NIM_ORG
    GHA_PKG -->|download| NIM_ORG
```

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

```mermaid
graph LR
    subgraph "Azure Pipelines"
        direction TB
        AZ_LINUX[Linux amd64<br/>ubuntu-24.04]
        AZ_MAC[macOS arm64<br/>macos-15]
        AZ_MAC_CPP[macOS arm64 C++<br/>macos-15]
        AZ_WIN1[Windows Batch 0_3<br/>windows-2025]
        AZ_WIN2[Windows Batch 1_3<br/>windows-2025]
        AZ_WIN3[Windows Batch 2_3<br/>windows-2025]
    end

    subgraph "GitHub Actions - Docs"
        direction TB
        GH_DOC_LINUX[Linux<br/>ubuntu-22.04]
        GH_DOC_MAC[macOS<br/>macos-15]
        GH_DOC_WIN[Windows<br/>windows-latest]
    end

    subgraph "GitHub Actions - Packages"
        direction TB
        GH_PKG_LINUX[Linux<br/>ubuntu-latest]
        GH_PKG_MAC[macOS<br/>macos-14]
    end

    TRIGGER[プッシュ/PR] --> AZ_LINUX
    TRIGGER --> AZ_MAC
    TRIGGER --> AZ_MAC_CPP
    TRIGGER --> AZ_WIN1
    TRIGGER --> AZ_WIN2
    TRIGGER --> AZ_WIN3
    TRIGGER --> GH_DOC_LINUX
    TRIGGER --> GH_DOC_MAC
    TRIGGER --> GH_DOC_WIN
    TRIGGER --> GH_PKG_LINUX
    TRIGGER --> GH_PKG_MAC
```

## ビルドプロセスフロー

```mermaid
flowchart TD
    START[ビルド開始] --> CHECKOUT[ソースコードチェックアウト]
    CHECKOUT --> DEPS[依存関係インストール]
    DEPS --> CSOURCES[csourcesビルド/キャッシュ復元]
    CSOURCES --> KOCH[kochビルド<br/>nim c koch]
    KOCH --> BOOT[コンパイラブート<br/>./koch boot -d:release]
    BOOT --> TOOLS[ツールビルド<br/>./koch tools]
    TOOLS --> TEST[テスト実行<br/>./koch runCI]
    TEST --> RESULT{テスト結果}
    RESULT -->|成功| SUCCESS[ビルド成功]
    RESULT -->|失敗| REPORT[結果レポート生成]
    REPORT --> FAILURE[ビルド失敗]
```

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

```mermaid
flowchart LR
    PUSH[develブランチへpush] --> BUILD[ドキュメントビルド<br/>./koch doc]
    BUILD --> DEPLOY[GitHub Pagesへデプロイ]
    DEPLOY --> PAGES[nim-lang.github.io/Nim]
```

## 依存関係図

```mermaid
graph TD
    subgraph "Nimコンパイラ"
        NIM[nim]
        KOCH[koch]
        NIMSUGGEST[nimsuggest]
    end

    subgraph "ブートストラップ"
        CSOURCES[csources_v3<br/>Cソースコード]
    end

    subgraph "Cコンパイラ"
        GCC[GCC/G++]
        MINGW[MinGW<br/>Windows]
        CLANG[Clang<br/>macOS]
    end

    subgraph "ビルドツール"
        MAKE[Make/GMake]
        GIT[Git]
    end

    subgraph "テスト依存"
        NODEJS[Node.js 20.x]
        VALGRIND[Valgrind]
        SDL[SDL/SFML]
        GC[Boehm GC]
    end

    CSOURCES --> GCC
    CSOURCES --> MINGW
    CSOURCES --> CLANG
    GCC --> NIM
    MINGW --> NIM
    CLANG --> NIM
    NIM --> KOCH
    KOCH --> NIMSUGGEST

    MAKE --> CSOURCES
    GIT --> CSOURCES

    NIM --> NODEJS
    NIM --> VALGRIND
    NIM --> SDL
    NIM --> GC
```

## ブランチとCI/CDの関係

```mermaid
gitGraph
    commit id: "initial"
    branch devel
    checkout devel
    commit id: "feature-1"
    commit id: "feature-2"
    branch version-2-2
    checkout version-2-2
    commit id: "release-prep"
    commit id: "v2.2.0" tag: "v2.2.0"
    checkout devel
    commit id: "feature-3"
    branch feature-branch
    checkout feature-branch
    commit id: "PR-change"
    checkout devel
    merge feature-branch id: "merge-PR"
    commit id: "feature-4"
```

## 環境構成

```mermaid
graph TB
    subgraph "Linux環境"
        L_OS[Ubuntu 22.04/24.04]
        L_GCC[GCC 14]
        L_LIBS[libpcre3, libcurl, libgc<br/>libsdl, libsfml, valgrind]
    end

    subgraph "macOS環境"
        M_OS[macOS 14/15<br/>Apple Silicon]
        M_BREW[Homebrew]
        M_LIBS[boehmgc, sfml, gtk+3]
    end

    subgraph "Windows環境"
        W_OS[Windows Server 2025]
        W_MINGW[MinGW64]
        W_DLL[DLLs from nim-lang.org]
    end

    L_OS --> L_GCC
    L_GCC --> L_LIBS

    M_OS --> M_BREW
    M_BREW --> M_LIBS

    W_OS --> W_MINGW
    W_MINGW --> W_DLL
```
