File tree Expand file tree Collapse file tree 6 files changed +98
-1
lines changed
Expand file tree Collapse file tree 6 files changed +98
-1
lines changed Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ services :
14+ postgres :
15+ image : postgres:15
16+ env :
17+ POSTGRES_PASSWORD : password
18+ POSTGRES_DB : testdb
19+ options : >-
20+ --health-cmd pg_isready
21+ --health-interval 10s
22+ --health-timeout 5s
23+ --health-retries 5
24+ ports :
25+ - 5432:5432
26+
27+ steps :
28+ - uses : actions/checkout@v4
29+
30+ - name : Set up Go
31+ uses : actions/setup-go@v4
32+ with :
33+ go-version : 1.23
34+
35+ - name : Cache Go modules
36+ uses : actions/cache@v3
37+ with :
38+ path : ~/go/pkg/mod
39+ key : ${{ runner.os}}~go-${{ hashFiles('**/go.sum') }}
40+ restore-keys : |
41+ ${{ runner.os }}~go-
42+
43+ - name : Install dependencies
44+ run : go mod download
45+
46+ - name : Run tests
47+ run : go test -v -race coverprofile=coverage.out ./...
48+ env :
49+ DATABASE_URL : postgres://postgres:password@localhost:5432/testdb?sslmode=disable
50+
51+ - name : Upload coverage to Codecov
52+ uses : codecov/codecov-action@v3
53+ with :
54+ file : coverage.out
55+
56+ - name : Run linter
57+ uses : golangci/golangci-lint-action@v3
58+ with :
59+ version : latest
60+
61+ - name : Build
62+ run : go build -v ./cmd/server
63+
64+
Original file line number Diff line number Diff line change 88/server
99/bin
1010
11+ .github /workflows /deploy.yml
12+
1113# Test binary, built with `go test -c`
1214* .test
1315
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ FROM golang:1.23-alpine AS builder
22
33WORKDIR /app
44
5- RUN apk add --no-cache git
5+ RUN apk add --no-cache git ca-certificates tzdata
66
77COPY go.mod go.sum ./
88RUN go mod download
@@ -21,6 +21,8 @@ COPY --from=builder /app/bin/server .
2121
2222COPY --from=builder /app/data ./data
2323
24+ COPY --from=builder /app/internal/database/migrations ./migrations/
25+
2426EXPOSE 8080
2527
2628CMD ["./server" ]
Original file line number Diff line number Diff line change @@ -58,6 +58,25 @@ services:
5858 volumes :
5959 - pgadmin_data:/var/lib/pgadmin
6060
61+ redis :
62+ image : redis:7-alpine
63+ ports :
64+ - " 6379:6379"
65+ restart : unless-stopped
66+
67+ prometheus :
68+ image : prom/prometheus:latest
69+ ports :
70+ - " 9090:9090"
71+ volumes :
72+ - ./prometheus.yml:/etc/prometheus/prometheus.yml
73+ command :
74+ - ' --config.file=/etc/prometheus/prometheus.yml'
75+ - ' --storage.tsdb.path=/prometheus'
76+ - ' --web.console.libraries=/etc/prometheus/console_libraries'
77+ - ' --web.console.templates=/etc/prometheus/consoles'
78+ restart : unless-stopped
79+
6180volumes :
6281 postgres_data :
6382 driver : local
Original file line number Diff line number Diff line change 1+ CREATE DATABASE forgotten_dev ;
Original file line number Diff line number Diff line change 1+ global :
2+ scrape_interval : 15s
3+
4+ scrape_configs :
5+ - job_name : ' go-app'
6+ static_configs :
7+ - targets : ['app:8080']
8+ metrics_path : /metrics
9+ scrape_interval : 5s
You can’t perform that action at this time.
0 commit comments