Skip to content

Commit 550b447

Browse files
committed
ci: 同步 postgres 服务端与客户端的版本
1 parent 5a81934 commit 550b447

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

.github/workflows/postgres.yml

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
name: Postgres
22
on: [push, pull_request]
3-
jobs:
43

4+
jobs:
55
test:
66
name: Test
77
runs-on: ${{ matrix.os }}
88

99
strategy:
1010
matrix:
1111
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"]
1313

1414
services:
1515
postgres:
16-
image: postgres:latest
16+
image: postgres:15
1717
env:
1818
POSTGRES_USER: postgres
1919
POSTGRES_PASSWORD: postgres
@@ -25,30 +25,33 @@ jobs:
2525
--health-timeout=5s
2626
--health-retries=3
2727
28-
2928
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

Comments
 (0)