-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (101 loc) · 3.1 KB
/
100_backend_test.yml
File metadata and controls
113 lines (101 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: 【backend】Go Tests
on:
pull_request:
paths:
- "backend/**"
- ".github/**"
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: pgvector/pgvector:pg15
env:
POSTGRES_PASSWORD: dev-pass
POSTGRES_USER: postgres
POSTGRES_DB: umi_mikan
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: "backend/go.mod"
cache: false # setup-go の組み込みキャッシュを無効化し、直後の actions/cache で一元管理する
- name: Cache Go modules
uses: actions/cache@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
working-directory: ./backend
run: go mod download
- name: Initialize database
run: |
for file in schema/*.sql; do
if [[ "$(basename "$file")" != *"_."* ]]; then
echo "Applying schema: $(basename "$file")"
psql "$DATABASE_URL" -f "$file"
fi
done
env:
DATABASE_URL: postgres://postgres:dev-pass@localhost:5432/umi_mikan?sslmode=disable
- name: Run tests
working-directory: ./backend
run: go test -v ./...
env:
DATABASE_URL: postgres://postgres:dev-pass@localhost:5432/umi_mikan?sslmode=disable
JWT_SECRET: test-secret-for-ci
TEST_DB_HOST: localhost
TEST_DB_USER: postgres
TEST_DB_PASSWORD: dev-pass
TEST_DB_NAME: umi_mikan
DB_HOST: localhost
DB_PORT: 5432
DB_USER: postgres
DB_PASS: dev-pass
DB_NAME: umi_mikan
REDIS_HOST: localhost
REDIS_PORT: 6379
- name: Run tests with coverage
working-directory: ./backend
run: go test -coverprofile=coverage.out ./...
env:
DATABASE_URL: postgres://postgres:dev-pass@localhost:5432/umi_mikan?sslmode=disable
JWT_SECRET: test-secret-for-ci
TEST_DB_HOST: localhost
TEST_DB_USER: postgres
TEST_DB_PASSWORD: dev-pass
TEST_DB_NAME: umi_mikan
DB_HOST: localhost
DB_PORT: 5432
DB_USER: postgres
DB_PASS: dev-pass
DB_NAME: umi_mikan
REDIS_HOST: localhost
REDIS_PORT: 6379
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./backend/coverage.out
flags: backend
name: backend-coverage