-
Notifications
You must be signed in to change notification settings - Fork 6
153 lines (145 loc) · 3.8 KB
/
test.yaml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
# @see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# @see https://docs.github.com/en/actions/guides/creating-postgresql-service-containers
# @see https://github.com/actions/virtual-environments
# @see https://www.postgresql.jp/document/11/html/app-pgrestore.html
name: Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
unit:
name: Unit
timeout-minutes: 5
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
task:
- lint
- test
- bench
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true
- name: Download modules
run: go mod download
- name: Run
run: make ${{ matrix.task }}
profiling:
name: Profiling
timeout-minutes: 5
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
package: ["pgpasswd"]
type: ["cpu", "mem"]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true
- name: Download modules
run: go mod download
- name: Run
run: make prof
env:
PKG: ${{ matrix.package }}
TYPE: ${{ matrix.type }}
feature:
name: Feature
timeout-minutes: 5
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
postgres:
- 10-alpine
- 11-alpine
- 12-alpine
- 13-alpine
- 14-alpine
- 15-alpine
- 16-alpine
services:
postgres:
image: postgres:${{ matrix.postgres }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: '--auth-host=scram-sha-256'
env:
PGHOST: 127.0.0.1
PGPORT: 5432
PGDATABASE: postgres
steps:
- name: Install PostgreSQL clients
run: sudo apt update && sudo apt install -y --no-install-recommends postgresql-client
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true
- name: Download modules
run: go mod download
- name: Build
run: make term
- name: Create role for test
run: |
echo -n "CREATE ROLE test WITH LOGIN PASSWORD " >> $SQL_FILE_PATH
echo -n "'" >> $SQL_FILE_PATH
./cmd/term/encrypt test | tr -d '\n' >> $SQL_FILE_PATH
echo "';" >> $SQL_FILE_PATH
cat $SQL_FILE_PATH | tee /dev/stderr | psql
env:
SQL_FILE_PATH: /tmp/create_role.sql
PGUSER: postgres
PGPASSWORD: postgres
- name: Check roles out
run: psql -c 'SELECT usename, passwd FROM pg_catalog.pg_shadow'
env:
PGUSER: postgres
PGPASSWORD: postgres
- name: Test login success
run: psql -c 'SELECT user'
env:
PGUSER: test
PGPASSWORD: test
- name: Test login fail
run: psql -c 'SELECT user' || echo 'fail ok'
env:
PGUSER: test
PGPASSWORD: wrong