Skip to content

Commit 7cb66b7

Browse files
committed
Fix CI
1 parent a7a10db commit 7cb66b7

4 files changed

Lines changed: 119 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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

.gitlab-ci.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
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

313
test:
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

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ run: urlredir
1313

1414
.PHONY: test
1515
test:
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
@@ -23,7 +27,8 @@ cover:
2327
.PHONY: lint
2428
lint:
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
2934
cloc:

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ Run:
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+
3337
Coverage needs the config (for database connection details):
3438

3539
make cover

0 commit comments

Comments
 (0)