1
1
name : Postgres
2
2
on : [push, pull_request]
3
- jobs :
4
3
4
+ jobs :
5
5
test :
6
6
name : Test
7
7
runs-on : ${{ matrix.os }}
8
8
9
9
strategy :
10
10
matrix :
11
11
os : [ubuntu-latest] # action 不支持非 linux 下的容器, windows-latest, macOS-latest
12
- go : [' 1.23.x', ' 1.24.x' ]
12
+ go : [" 1.23.x", " 1.24.x" ]
13
13
14
14
services :
15
15
postgres :
16
- image : postgres:latest
16
+ image : postgres:15
17
17
env :
18
18
POSTGRES_USER : postgres
19
19
POSTGRES_PASSWORD : postgres
@@ -25,30 +25,33 @@ jobs:
25
25
--health-timeout=5s
26
26
--health-retries=3
27
27
28
-
29
28
steps :
30
-
31
- - name : 创建数据库
32
- run : |
33
- PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -c 'CREATE DATABASE orm_test;'
34
-
35
- - name : 安装 Go ${{ matrix.go }}
36
- uses : actions/setup-go@v5
37
- with :
38
- go-version : ${{ matrix.go }}
39
- id : go
40
-
41
- - name : Check out code into the Go module directory
42
- uses : actions/checkout@v4
43
-
44
- - name : Vet
45
- run : go vet -v ./...
46
-
47
- - name : Test
48
- run : go test -p=1 ./... -test.coverprofile=coverage.txt -covermode=atomic -dbs=postgres,postgres -p=1 -parallel=1
49
-
50
- - name : Upload coverage to Codecov
51
- uses : codecov/codecov-action@v5
52
- with :
53
- token : ${{secrets.CODECOV_TOKEN}}
54
- files : ./coverage.txt
29
+ - name : 安装客户端
30
+ run : |
31
+ sudo apt-get update
32
+ sudo apt-get install -y postgresql-client-15
33
+
34
+ - name : 创建数据库
35
+ run : |
36
+ PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -c 'CREATE DATABASE orm_test;'
37
+
38
+ - name : 安装 Go ${{ matrix.go }}
39
+ uses : actions/setup-go@v5
40
+ with :
41
+ go-version : ${{ matrix.go }}
42
+ id : go
43
+
44
+ - name : Check out code into the Go module directory
45
+ uses : actions/checkout@v4
46
+
47
+ - name : Vet
48
+ run : go vet -v ./...
49
+
50
+ - name : Test
51
+ run : go test -p=1 ./... -test.coverprofile=coverage.txt -covermode=atomic -dbs=postgres,postgres -p=1 -parallel=1
52
+
53
+ - name : Upload coverage to Codecov
54
+ uses : codecov/codecov-action@v5
55
+ with :
56
+ token : ${{secrets.CODECOV_TOKEN}}
57
+ files : ./coverage.txt
0 commit comments