# インフラ構成図

## 全体構成図

```mermaid
graph TB
    subgraph Developer["開発者環境"]
        DEV[開発者]
        LOCAL_DOCKER["Docker / Docker Compose<br/>ruby:3.2.2-bullseye"]
    end

    subgraph GitHub["GitHub"]
        REPO["mruby/mruby<br/>リポジトリ"]
        ISSUES["Issues / PR"]
        RELEASES["GitHub Releases<br/>zip, tar.gz, tar.xz"]
        DEPENDABOT["Dependabot<br/>bundler / github-actions"]
    end

    subgraph GitHubActions["GitHub Actions CI/CD"]
        subgraph BuildTest["Build & Test ワークフロー"]
            LINUX_GCC["Ubuntu 22.04/24.04<br/>GCC"]
            LINUX_CLANG["Ubuntu 22.04/24.04<br/>Clang"]
            MACOS["macOS 14/15<br/>Clang"]
            WIN_MINGW["Windows 2022/2025<br/>MinGW GCC"]
            WIN_MSVC["Windows 2022<br/>MSVC"]
            COSMO["Ubuntu 24.04<br/>Cosmopolitan"]
        end

        subgraph QualitySecurity["品質・セキュリティ"]
            CODEQL["CodeQL Analysis"]
            SUPERLINTER["Super-Linter"]
            PRECOMMIT_CI["pre-commit"]
            LSLINT["ls-lint"]
            LABELER["PR Labeler"]
        end

        subgraph CoverageRelease["カバレッジ・リリース"]
            COVERAGE["Coverage<br/>gcovr + Clang-18"]
            RELEASE_WF["Release Builds<br/>softprops/action-gh-release"]
        end
    end

    subgraph ExternalCI["外部 CI サービス"]
        TRAVIS["Travis CI<br/>Linux / macOS"]
        APPVEYOR["AppVeyor<br/>Windows VS 2015-2022"]
    end

    subgraph ExternalServices["外部サービス"]
        OSSFUZZ["Google OSS-Fuzz<br/>ファジングテスト"]
        RUBYGEMS["RubyGems.org<br/>Gem 依存関係"]
    end

    DEV -->|git push / PR| REPO
    DEV -->|docker-compose run| LOCAL_DOCKER
    REPO -->|push, PR trigger| BuildTest
    REPO -->|push to master| CODEQL
    REPO -->|PR trigger| SUPERLINTER
    REPO -->|PR trigger| PRECOMMIT_CI
    REPO -->|PR trigger| LSLINT
    REPO -->|PR trigger| LABELER
    REPO -->|PR trigger| OSSFUZZ
    REPO -->|push trigger| COVERAGE
    REPO -->|tag push| RELEASE_WF
    REPO -->|webhook| TRAVIS
    REPO -->|webhook| APPVEYOR
    RELEASE_WF -->|draft release| RELEASES
    DEPENDABOT -->|auto PR| REPO
    COVERAGE -->|upload artifact| REPO
    LOCAL_DOCKER -->|rake test| LOCAL_DOCKER
    BuildTest -->|status check| ISSUES
    RUBYGEMS -->|bundle install| LOCAL_DOCKER
```

## CI/CD パイプライン フロー図

```mermaid
flowchart LR
    subgraph Triggers["トリガー"]
        PUSH["git push"]
        PR["Pull Request"]
        TAG["Tag Push<br/>*.*.*"]
    end

    subgraph BuildPhase["ビルド・テストフェーズ"]
        BT["Build & Test<br/>8並列マトリクス"]
        COSMO_BUILD["Cosmopolitan Build"]
        WINVC["Windows VC Build"]
    end

    subgraph QualityPhase["品質チェックフェーズ"]
        SL["Super-Linter"]
        PC["pre-commit"]
        LS["ls-lint"]
        CQ["CodeQL"]
        FUZZ["OSS-Fuzz<br/>600秒"]
    end

    subgraph CoveragePhase["カバレッジフェーズ"]
        COV["Coverage<br/>gcovr / llvm-cov-18"]
        ART["Artifact Upload<br/>保持: 3日"]
    end

    subgraph ReleasePhase["リリースフェーズ"]
        ARCHIVE["git archive<br/>zip / tar.gz / tar.xz"]
        SHA["SHA256 チェックサム"]
        GH_RELEASE["GitHub Release<br/>Draft"]
    end

    PUSH --> BT
    PUSH --> COSMO_BUILD
    PUSH --> WINVC
    PUSH --> COV
    PUSH --> CQ

    PR --> BT
    PR --> COSMO_BUILD
    PR --> WINVC
    PR --> SL
    PR --> PC
    PR --> LS
    PR --> CQ
    PR --> FUZZ

    TAG --> ARCHIVE
    ARCHIVE --> SHA
    SHA --> GH_RELEASE

    COV --> ART
```

## Docker コンテナ構成図

```mermaid
graph TB
    subgraph DockerCompose["docker-compose.yml (version 3.8)"]
        subgraph TestService["test サービス"]
            BASE["ベースイメージ<br/>ruby:3.2.2-bullseye"]
            APT["apt パッケージ<br/>python3-pip, shellcheck"]
            BUNDLE["bundle install<br/>rake, yard, yard-coderay, yard-mruby"]
            PIP["pip install<br/>pre-commit"]
            WORKDIR["/app<br/>mruby ソースコード"]

            BASE --> APT
            APT --> BUNDLE
            BUNDLE --> PIP
            PIP --> WORKDIR
        end
    end

    subgraph EnvVars["環境変数"]
        ENV1["MRUBY_CONFIG=ci/gcc-clang"]
        ENV2["CC=gcc"]
        ENV3["CXX=g++"]
        ENV4["LD=gcc"]
        ENV5["SKIP=check-executables-have-shebangs"]
    end

    subgraph Command["実行コマンド"]
        CMD["rake deep_clean &&<br/>rake -m test:run:serial"]
    end

    EnvVars --> TestService
    TestService --> CMD
```

## ビルドマトリクス構成図

```mermaid
graph LR
    subgraph Platforms["ビルド対象プラットフォーム"]
        subgraph Linux["Linux"]
            U24_GCC["Ubuntu 24.04<br/>GCC"]
            U24_CLANG["Ubuntu 24.04<br/>Clang"]
            U22_GCC["Ubuntu 22.04<br/>GCC"]
            U22_CLANG["Ubuntu 22.04<br/>Clang"]
            COSMO_P["Ubuntu 24.04<br/>Cosmopolitan"]
        end

        subgraph Mac["macOS"]
            M15["macOS 15<br/>Clang"]
            M14["macOS 14<br/>Clang"]
        end

        subgraph Windows["Windows"]
            W25_MINGW["Windows 2025<br/>MinGW GCC"]
            W22_MINGW["Windows 2022<br/>MinGW GCC"]
            W22_MSVC["Windows 2022<br/>MSVC"]
        end

        subgraph ExtCI["外部CI"]
            TRAVIS_L["Travis CI<br/>Linux"]
            TRAVIS_M["Travis CI<br/>macOS"]
            AV_VS22["AppVeyor<br/>VS 2022 x64"]
            AV_VS19_64["AppVeyor<br/>VS 2019 x64"]
            AV_VS19_32["AppVeyor<br/>VS 2019 x32"]
            AV_VS17_64["AppVeyor<br/>VS 2017 x64"]
            AV_VS17_32["AppVeyor<br/>VS 2017 x32"]
            AV_VS15_64["AppVeyor<br/>VS 2015 x64"]
            AV_VS15_32["AppVeyor<br/>VS 2015 x32"]
        end
    end

    subgraph BuildConfig["ビルド設定"]
        CI_GCC["ci/gcc-clang"]
        CI_MSVC["ci/msvc"]
        CI_COSMO["cosmopolitan"]
    end

    CI_GCC --> U24_GCC
    CI_GCC --> U24_CLANG
    CI_GCC --> U22_GCC
    CI_GCC --> U22_CLANG
    CI_GCC --> M15
    CI_GCC --> M14
    CI_GCC --> W25_MINGW
    CI_GCC --> W22_MINGW
    CI_GCC --> TRAVIS_L
    CI_GCC --> TRAVIS_M
    CI_MSVC --> W22_MSVC
    CI_MSVC --> AV_VS22
    CI_MSVC --> AV_VS19_64
    CI_MSVC --> AV_VS19_32
    CI_MSVC --> AV_VS17_64
    CI_MSVC --> AV_VS17_32
    CI_MSVC --> AV_VS15_64
    CI_MSVC --> AV_VS15_32
    CI_COSMO --> COSMO_P
```
