-
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (88 loc) · 2.44 KB
/
test-myself.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
name: Test `query-postgresql` action
on:
push:
branches:
- main
env:
PG_USER: postgres
PG_PWD: mypassword
PG_DB: postgres
PG_HOST: localhost
PG_PORT: 5432
jobs:
test-query:
runs-on: [ "ubuntu-latest" ]
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: ${{ env.PG_PWD }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Simple query
id: query
uses: ./ # Uses an action in the root directory
with:
query: |
select true as result
host: ${{ env.PG_HOST }}
port: ${{ env.PG_PORT }}
username: ${{ env.PG_USER }}
password: ${{ env.PG_PWD }}
db: ${{ env.PG_DB }}
ssl: 'false'
- name: Test 1
run: |
echo "Expecting [{result:true}]"
echo "${{ steps.query.outputs.result }}"
echo "${{ steps.query.outputs.count }}"
test "${{ steps.query.outputs.count }}" == "1"
test "${{ steps.query.outputs.result }}" == "[{result:true}]"
test-query-files:
runs-on: [ "ubuntu-latest" ]
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: ${{ env.PG_PWD }}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare query
run: |
echo "select true as result" > query.sql
- name: File query
id: query
uses: ./ # Uses an action in the root directory
with:
query: 'query.sql'
host: ${{ env.PG_HOST }}
port: ${{ env.PG_PORT }}
username: ${{ env.PG_USER }}
password: ${{ env.PG_PWD }}
db: ${{ env.PG_DB }}
ssl: false
from_file: true
to_file: true
- name: Test 1
run: |
echo "Expecting [{result:true}]"
echo "Path: ${{ steps.query.outputs.result }}"
echo "Count: ${{ steps.query.outputs.count }}"
cat "${{ steps.query.outputs.result }}"
test "${{ steps.query.outputs.count }}" == "1"