Skip to content

Commit 0aaeea5

Browse files
authored
開発環境コマンド(Makefile)の作成とGitHub Actions CI の設定 (#1290)
1 parent 3d4710b commit 0aaeea5

File tree

11 files changed

+609
-731
lines changed

11 files changed

+609
-731
lines changed

.claude/specs/1_doing/sign-in.md

Lines changed: 0 additions & 544 deletions
This file was deleted.

.claude/specs/template.md

Lines changed: 0 additions & 173 deletions
This file was deleted.

.github/workflows/go-ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Go CI
2+
3+
on: push
4+
5+
env:
6+
GO_VERSION: "1.25.4"
7+
8+
jobs:
9+
lint:
10+
name: Lint
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
working-directory: go
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v6
20+
with:
21+
go-version: ${{ env.GO_VERSION }}
22+
23+
- name: Check templ generate
24+
run: |
25+
make templ-generate
26+
make goimports
27+
git diff --exit-code internal/templates/
28+
29+
- name: Check go mod tidy
30+
run: |
31+
go mod tidy
32+
git diff --exit-code go.mod go.sum
33+
34+
- name: Run golangci-lint
35+
uses: golangci/golangci-lint-action@v9.1.0
36+
with:
37+
version: v2.6.2
38+
working-directory: go
39+
args: --config=.golangci.yml ./...
40+
41+
test:
42+
name: Test
43+
runs-on: ubuntu-latest
44+
defaults:
45+
run:
46+
working-directory: go
47+
env:
48+
APP_ENV: test
49+
DATABASE_URL: postgres://postgres@localhost:5432/mewst_test?sslmode=disable
50+
MEWST_PORT: "4004"
51+
MEWST_DOMAIN: "test.example.com"
52+
MEWST_COOKIE_DOMAIN: ".test.example.com"
53+
MEWST_SESSION_SECURE: "false"
54+
MEWST_SESSION_HTTPONLY: "true"
55+
MEWST_RAILS_APP_URL: "http://localhost:3000"
56+
MEWST_DISABLE_RATE_LIMIT: "false"
57+
MEWST_TURNSTILE_SECRET_KEY: "1x0000000000000000000000000000000AA"
58+
MEWST_RESEND_API_KEY: "re_test_key"
59+
MEWST_RESEND_FROM_EMAIL: "test@example.com"
60+
61+
services:
62+
postgresql:
63+
image: postgres:16.2
64+
ports:
65+
- 5432:5432
66+
env:
67+
POSTGRES_DB: mewst_test
68+
POSTGRES_HOST_AUTH_METHOD: trust
69+
options: >-
70+
--health-cmd pg_isready
71+
--health-interval 10s
72+
--health-timeout 5s
73+
--health-retries 5
74+
75+
steps:
76+
- uses: actions/checkout@v6
77+
78+
- name: Set up Go
79+
uses: actions/setup-go@v6
80+
with:
81+
go-version: ${{ env.GO_VERSION }}
82+
83+
- name: Get dependencies
84+
run: |
85+
go mod download
86+
87+
- name: Setup test database
88+
run: |
89+
make db-setup-test
90+
91+
- name: Run tests
92+
shell: bash
93+
env:
94+
CI: true
95+
run: |
96+
echo "🧪 テストを実行中(CI環境: 短時間テストのみ)..."
97+
echo ""
98+
99+
set +e
100+
make test 2>&1 | tee test-output.log
101+
test_exit_code=$?
102+
set -e
103+
104+
echo ""
105+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
106+
echo "📊 テスト結果サマリー"
107+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
108+
109+
if [ $test_exit_code -ne 0 ]; then
110+
echo "❌ テストが失敗しました"
111+
echo ""
112+
113+
echo "📦 失敗したパッケージ:"
114+
grep "^FAIL" test-output.log | sed 's/^/ /' || echo " (失敗したパッケージが見つかりません)"
115+
116+
echo ""
117+
echo "🔍 失敗したテストの詳細:"
118+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
119+
120+
grep -A 2 -- "--- FAIL:" test-output.log | grep -E -- "(--- FAIL:|\.go:[0-9]+:)" || echo " (失敗したテストの詳細が見つかりません)"
121+
122+
exit $test_exit_code
123+
else
124+
echo "✅ すべてのテストが成功しました"
125+
ok_count=$(grep -c "^ok" test-output.log || echo "0")
126+
echo " 合計 ${ok_count} パッケージのテストが成功"
127+
fi
128+
129+
build:
130+
name: Build
131+
runs-on: ubuntu-latest
132+
defaults:
133+
run:
134+
working-directory: go
135+
steps:
136+
- uses: actions/checkout@v6
137+
138+
- name: Set up Go
139+
uses: actions/setup-go@v6
140+
with:
141+
go-version: ${{ env.GO_VERSION }}
142+
143+
- name: Build
144+
run: |
145+
make build
146+
147+
- name: Check binary exists
148+
run: |
149+
if [ ! -f bin/server ]; then
150+
echo "Build failed: binary not found"
151+
exit 1
152+
fi

0 commit comments

Comments
 (0)