Skip to content

Commit bc17445

Browse files
committed
feat : set up ci-test with db-up
1 parent 6d1e2d6 commit bc17445

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

.github/workflows/go.yml

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
uses: actions/setup-go@v4
2727
with:
2828
go-version: 1.19
29+
30+
- name: Set up db
31+
run: |
32+
cd server
33+
make run-db
2934
3035
- name: Build
3136
run: cd server && go build -v ./...

server/.env.db.sample

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DB_DATABASE=hoge
2+
DB_HOST="glyph-database"
3+
DB_USER=hoge
4+
DB_PASSWORD=hoge

server/Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
ENV_LOCAL_FILE := .env.local
66
ENV_LOCAL = $(shell cat $(ENV_LOCAL_FILE))
77

8+
ENV_SAMPLE_FILE = .env.db.sample
9+
ENV_SAMPLE = $(shell cat $(ENV_SAMPLE_FILE))
10+
11+
812
# go
913
GO := go run
1014

1115
# docker
1216
DOCKER_FILE_DIR := ./docker
17+
DOCKER_COMPOSE_CI := $(DOCKER_FILE_DIR)/docker-compose.ci.yml
1318
DOCKER_COMPOSE_LOCAL := $(DOCKER_FILE_DIR)/docker-compose.local.yml
1419
DOCKER_COMPOSE_LOCAL_DATABASE := $(DOCKER_FILE_DIR)/docker-compose.local.database.yml
1520
DOCKER_COMPOSE_LOCAL_SERVER := $(DOCKER_FILE_DIR)/docker-compose.local.server.yml
@@ -44,6 +49,13 @@ fclean:down del-volumes ## マウントしたデータを削除、またdocker
4449
.PHONY: re
4550
re:fclean up ## 完全に初期化した状態でdocker環境を立ち上げる
4651

52+
.PHONY: run-db
53+
run-db:
54+
$(ENV_SAMPLE) docker-compose \
55+
-f $(DOCKER_COMPOSE_CI) \
56+
-f $(DOCKER_COMPOSE_LOCAL_DATABASE) up
57+
58+
4759
.PHONY: del-volumes
4860
del-volumes:del-data
4961

server/docker/docker-compose.ci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "3"
2+
3+
services:
4+
database:
5+
container_name: glyph-database
6+
restart: always
7+
tty: true

0 commit comments

Comments
 (0)