File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ pull_request :
6+
7+ jobs :
8+ lint :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Checkout
12+ uses : actions/checkout@v4
13+
14+ - name : Setup Go
15+ uses : actions/setup-go@v5
16+ with :
17+ go-version-file : go.mod
18+
19+ - name : Lint
20+ run : make lint
21+
22+ test :
23+ runs-on : ubuntu-latest
24+ steps :
25+ - name : Checkout
26+ uses : actions/checkout@v4
27+
28+ - name : Setup Go
29+ uses : actions/setup-go@v5
30+ with :
31+ go-version-file : go.mod
32+
33+ - name : Test
34+ run : make test
35+
36+ test-integration :
37+ runs-on : ubuntu-latest
38+ services :
39+ postgres :
40+ image : postgres:16
41+ env :
42+ POSTGRES_DB : postgres
43+ POSTGRES_USER : postgres
44+ POSTGRES_PASSWORD : postgres
45+ ports :
46+ - 5432:5432
47+ options : >-
48+ --health-cmd "pg_isready -U postgres -d postgres"
49+ --health-interval 10s
50+ --health-timeout 5s
51+ --health-retries 5
52+ steps :
53+ - name : Checkout
54+ uses : actions/checkout@v4
55+
56+ - name : Setup Go
57+ uses : actions/setup-go@v5
58+ with :
59+ go-version-file : go.mod
60+
61+ - name : Create config.json
62+ run : |
63+ cat > config.json <<'EOF'
64+ {
65+ "Listen": ":8080",
66+ "DB": "host=127.0.0.1 port=5432 user=postgres password=postgres dbname=postgres sslmode=disable",
67+ "Debug": false,
68+ "RealIPHeader": "X-Forwarded-For",
69+ "RemoteUserHeader": "X-Remote-User"
70+ }
71+ EOF
72+
73+ - name : Integration tests
74+ run : make test-all
Original file line number Diff line number Diff line change 1- image : golang
1+ image : golang:1.26
2+
3+ stages :
4+ - lint
5+ - test
6+ - integration
7+
8+ lint :
9+ stage : lint
10+ script :
11+ - make lint
212
313test :
14+ stage : test
415 script :
516 - make test
17+
18+ test-integration :
19+ stage : integration
20+ services :
21+ - name : postgres:16
22+ alias : postgres
23+ variables :
24+ POSTGRES_DB : postgres
25+ POSTGRES_USER : postgres
26+ POSTGRES_PASSWORD : postgres
27+ script :
28+ - |
29+ cat > config.json <<'EOF'
30+ {
31+ "Listen": ":8080",
32+ "DB": "host=postgres user=postgres password=postgres dbname=postgres sslmode=disable",
33+ "Debug": false,
34+ "RealIPHeader": "X-Forwarded-For",
35+ "RemoteUserHeader": "X-Remote-User"
36+ }
37+ EOF
38+ - make test-all
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ run: urlredir
1313
1414.PHONY : test
1515test :
16+ CGO_ENABLED=0 go test -short -shuffle=on -vet=all -v
17+
18+ .PHONY : test-all
19+ test-all :
1620 CGO_ENABLED=0 go test -shuffle=on -vet=all -v
1721
1822.PHONY : cover
2327.PHONY : lint
2428lint :
2529 CGO_ENABLED=0 go tool golangci-lint run --default all \
26- --disable varnamelen,depguard
30+ --disable varnamelen,depguard,wsl,noinlineerr \
31+ --enable wsl_v5
2732
2833.PHONY : cloc
2934cloc :
Original file line number Diff line number Diff line change 2626
2727## Testing
2828
29- The test-target runs only a subset of tests, but works without config:
29+ Unit tests run in short mode and work without local Postgres/ config:
3030
3131 make test
3232
33+ Integration tests require config and a reachable Postgres database:
34+
35+ make test-all
36+
3337Coverage needs the config (for database connection details):
3438
3539 make cover
You can’t perform that action at this time.
0 commit comments