From b0248ccbab0fd2acc969283d1fc82e0e71da47fe Mon Sep 17 00:00:00 2001 From: moha Date: Tue, 7 Apr 2026 18:20:33 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20CI=E3=81=AB=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=AB=E3=83=90=E3=83=AC=E3=83=83=E3=82=B8=E8=A8=88=E6=B8=AC?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=83=BBREADME=E3=82=92=E5=85=85?= =?UTF-8?q?=E5=AE=9F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - go test -coverprofile によるカバレッジ計測をCIに追加 - coverage.out をアーティファクトとして7日間保存 - go tool cover -func でカバレッジサマリーをCI上に表示 - READMEにクイックスタート・セットアップ手順・テスト実行方法を追加 - 環境変数・プロジェクト構成・技術スタックの説明を追記 --- .github/workflows/ci.yml | 14 ++++++- README.md | 91 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f87c60..e2d396f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,18 @@ jobs: - name: Build run: go build ./... - - name: Test - run: go test -v -race ./... + - name: Test with coverage + run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... + + - name: Show coverage summary + run: go tool cover -func=coverage.out + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage.out + retention-days: 7 - name: Vet run: go vet ./... diff --git a/README.md b/README.md index 23f05af..b0a525f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,91 @@ -# bringit +# BringIt + 旅行、キャンプ、イベント、遊びの前に、友達同士で持ち物を分担するためのサービス + +## 機能 + +- **持ち物リスト作成**: タイトルと説明を入力して、共有可能なリストを作成 +- **アイテム管理**: 持ち物の追加・削除、担当者の設定、必須/任意の切り替え +- **準備状況のトラッキング**: 各アイテムの「準備済み」状態をトグルしてプログレスを確認 +- **共有リンク**: ユニークなトークン付きURLで友達とリストを共有 +- **インメモリストレージ**: サーバー再起動まで状態を保持 + +## 必要な環境 + +- [Go](https://golang.org/dl/) 1.24 以上 + +## クイックスタート + +```bash +# リポジトリをクローン +git clone https://github.com/mohadayo/bringit.git +cd bringit + +# サーバーを起動 +go run . +``` + +ブラウザで http://localhost:8080 を開いてください。 + +## 環境変数 + +| 変数名 | デフォルト値 | 説明 | +|--------|-------------|------| +| `PORT` | `8080` | サーバーのリッスンポート | + +### 例: ポートを変更して起動 + +```bash +PORT=3000 go run . +``` + +## テストの実行 + +```bash +# すべてのテストを実行 +go test ./... + +# 詳細出力でテストを実行 +go test -v ./... + +# カバレッジ付きでテストを実行 +go test -v -race -coverprofile=coverage.out ./... + +# カバレッジレポートを表示 +go tool cover -func=coverage.out + +# ブラウザでカバレッジレポートを確認 +go tool cover -html=coverage.out +``` + +## ビルド + +```bash +go build -o bringit . +./bringit +``` + +## プロジェクト構成 + +``` +bringit/ +├── main.go # エントリーポイント、サーバー起動 +├── handler.go # HTTPハンドラー・ルーティング +├── store.go # インメモリストア(スレッドセーフ) +├── model.go # データモデル(List, Item) +├── handler_test.go # HTTPハンドラーのテスト +├── templates/ +│ ├── index.html # トップページテンプレート +│ └── list.html # リスト詳細ページテンプレート +└── .github/ + └── workflows/ + └── ci.yml # GitHub Actions CI設定 +``` + +## 技術スタック + +- **言語**: Go 1.24 +- **サーバー**: `net/http`(標準ライブラリ) +- **テンプレート**: `html/template`(標準ライブラリ) +- **ストレージ**: インメモリ(`sync.RWMutex` でスレッドセーフ) +- **CI**: GitHub Actions(build / test / vet / coverage)