-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (126 loc) · 4.54 KB
/
Copy pathintegration-tests.yml
File metadata and controls
137 lines (126 loc) · 4.54 KB
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
name: Integration Tests
on:
pull_request:
branches: [main, dev]
push:
branches: [main, dev]
workflow_dispatch:
inputs:
test_size:
description: "Test size (small/medium/large)"
required: true
default: "small"
type: choice
options:
- small
- medium
- large
jobs:
setup:
name: Determine test matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
case "${{ github.event_name }}" in
pull_request)
echo 'matrix={"include":[{"size":"small","label":"Small","max_height":1000,"job_timeout":10,"test_timeout":"5m","test_timeout_min":5,"upload_artifacts":false}]}' >> $GITHUB_OUTPUT
;;
push)
echo 'matrix={"include":[{"size":"medium","label":"Medium","max_height":10000,"job_timeout":30,"test_timeout":"20m","test_timeout_min":20,"upload_artifacts":false}]}' >> $GITHUB_OUTPUT
;;
workflow_dispatch)
case "${{ github.event.inputs.test_size }}" in
small)
echo 'matrix={"include":[{"size":"small","label":"Small","max_height":1000,"job_timeout":10,"test_timeout":"5m","test_timeout_min":5,"upload_artifacts":false}]}' >> $GITHUB_OUTPUT
;;
medium)
echo 'matrix={"include":[{"size":"medium","label":"Medium","max_height":10000,"job_timeout":30,"test_timeout":"20m","test_timeout_min":20,"upload_artifacts":false}]}' >> $GITHUB_OUTPUT
;;
large)
echo 'matrix={"include":[{"size":"large","label":"Large","max_height":100000,"job_timeout":90,"test_timeout":"75m","test_timeout_min":75,"upload_artifacts":true}]}' >> $GITHUB_OUTPUT
;;
esac
;;
esac
integration-test:
name: Integration Test (${{ matrix.label }})
needs: setup
permissions:
contents: read
packages: read
runs-on: ubuntu-latest
timeout-minutes: ${{ matrix.job_timeout }}
strategy:
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
services:
timescaledb:
image: timescale/timescaledb-ha:pg17
env:
POSTGRES_PASSWORD: test_password_12345678
POSTGRES_DB: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4
with:
go-version: "1.26.5"
cache: true
- name: Wait for PostgreSQL
run: |
timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U postgres; do sleep 1; done'
env:
PGPASSWORD: test_password_12345678
- name: Initialize database schema
run: |
go run indexer/cmd/indexer.go setup create-db --db-user postgres --db-name postgres
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: test_password_12345678
DB_NAME: gnoland
- name: Create test config
run: |
cat > integration/test_config.yml << EOF
host: localhost
port: 5432
user: postgres
password: test_password_12345678
dbname: gnoland
sslmode: disable
pool_max_conns: 100
pool_min_conns: 2
pool_max_conn_lifetime: 5m
pool_max_conn_idle_time: 2m
pool_health_check_period: 30s
pool_max_conn_lifetime_jitter: 30s
chain_id: gnoland
max_height: ${{ matrix.max_height }}
from_height: 1
to_height: ${{ matrix.max_height }}
EOF
- name: Run ${{ matrix.size }} integration test (${{ matrix.label }})
run: |
cd integration
go test -v -tags=integration -timeout=${{ matrix.test_timeout }}
timeout-minutes: ${{ matrix.test_timeout_min }}
- name: Upload test results
if: always() && matrix.upload_artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: integration-test-results
path: |
integration/test_results/
state_dumps/
retention-days: 7