-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (79 loc) · 2.12 KB
/
Copy pathci.yml
File metadata and controls
94 lines (79 loc) · 2.12 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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
GO_VERSION: "1.26"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: 🔍 Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Check formatting
run: |
UNFORMATTED=$(gofmt -l . | grep -v vendor || true)
if [ -n "$UNFORMATTED" ]; then
echo "::error::Code not formatted. Run 'gofmt -w .'"
echo "$UNFORMATTED"
exit 1
fi
- name: Install and run golangci-lint
run: |
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0
golangci-lint run --timeout=5m ./...
test-unit:
name: 🧪 Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run unit tests
run: |
go test -race -v -coverprofile=coverage.out -covermode=atomic ./...
test-integration:
name: 🛢️ Integration Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_password
POSTGRES_DB: test_gogate
ports:
- 54322:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run E2E Integration tests
env:
TEST_DB_HOST: localhost
TEST_DB_PORT: 54322
TEST_DB_USER: test_user
TEST_DB_PASSWORD: test_password
TEST_DB_NAME: test_gogate
run: |
go test -race -v ./...