1+ version : 2.1
2+
3+ # Define reusable commands
4+ commands :
5+ install-dependencies :
6+ description : " Install system dependencies"
7+ steps :
8+ - run :
9+ name : " Update package list"
10+ command : |
11+ sudo apt-get update -y
12+ - run :
13+ name : " Install PostgreSQL and development tools"
14+ command : |
15+ sudo apt-get install -y \
16+ postgresql-17 \
17+ postgresql-server-dev-17 \
18+ postgresql-client-17 \
19+ build-essential \
20+ make \
21+ gcc \
22+ libc6-dev \
23+ pkg-config \
24+ libpq-dev \
25+ git \
26+ curl
27+
28+ setup-postgresql :
29+ description : " Setup PostgreSQL for testing"
30+ steps :
31+ - run :
32+ name : " Start PostgreSQL service"
33+ command : |
34+ sudo systemctl start postgresql
35+ sudo systemctl enable postgresql
36+ - run :
37+ name : " Create test database and user"
38+ command : |
39+ sudo -u postgres psql -c "CREATE DATABASE testdb;"
40+ sudo -u postgres psql -c "CREATE USER testuser WITH PASSWORD 'testpass';"
41+ sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE testdb TO testuser;"
42+ sudo -u postgres psql -c "ALTER USER testuser CREATEDB;"
43+
44+ build-pgraft :
45+ description : " Build pgraft extension"
46+ steps :
47+ - run :
48+ name : " Build pgraft extension"
49+ command : |
50+ cd pgraft
51+ make clean
52+ make
53+ - run :
54+ name : " Install pgraft extension"
55+ command : |
56+ cd pgraft
57+ sudo make install
58+
59+ test-pgraft :
60+ description : " Test pgraft extension"
61+ steps :
62+ - run :
63+ name : " Test pgraft extension loading"
64+ command : |
65+ sudo -u postgres psql -d testdb -c "CREATE EXTENSION IF NOT EXISTS pgraft;"
66+ - run :
67+ name : " Test pgraft core functions"
68+ command : |
69+ sudo -u postgres psql -d testdb -c "SELECT pgraft_version();"
70+ sudo -u postgres psql -d testdb -c "SELECT pgraft_init(1, 'localhost', 5432);"
71+ sudo -u postgres psql -d testdb -c "SELECT pgraft_start();"
72+ sudo -u postgres psql -d testdb -c "SELECT pgraft_get_state();"
73+ sudo -u postgres psql -d testdb -c "SELECT pgraft_is_leader();"
74+ - run :
75+ name : " Test pgraft monitoring functions"
76+ command : |
77+ sudo -u postgres psql -d testdb -c "SELECT pgraft_get_cluster_health();"
78+ sudo -u postgres psql -d testdb -c "SELECT pgraft_get_performance_metrics();"
79+ sudo -u postgres psql -d testdb -c "SELECT pgraft_is_cluster_healthy();"
80+ sudo -u postgres psql -d testdb -c "SELECT pgraft_get_system_stats();"
81+ sudo -u postgres psql -d testdb -c "SELECT pgraft_get_quorum_status();"
82+
83+ build-ramd :
84+ description : " Build ramd daemon"
85+ steps :
86+ - run :
87+ name : " Build ramd daemon"
88+ command : |
89+ cd ramd
90+ make clean
91+ make
92+ - run :
93+ name : " Test ramd build"
94+ command : |
95+ test -f ramd/ramd
96+ echo "ramd daemon built successfully"
97+
98+ build-ramctrl :
99+ description : " Build ramctrl utility"
100+ steps :
101+ - run :
102+ name : " Build ramctrl utility"
103+ command : |
104+ cd ramctrl
105+ make clean
106+ make
107+ - run :
108+ name : " Test ramctrl build"
109+ command : |
110+ test -f ramctrl/ramctrl
111+ echo "ramctrl utility built successfully"
112+
113+ # Define jobs
114+ jobs :
115+ build-and-test :
116+ docker :
117+ - image : cimg/base:stable
118+ steps :
119+ - checkout
120+ - install-dependencies
121+ - setup-postgresql
122+ - build-pgraft
123+ - test-pgraft
124+ - build-ramd
125+ - build-ramctrl
126+
127+ test-pgraft-only :
128+ docker :
129+ - image : cimg/base:stable
130+ steps :
131+ - checkout
132+ - install-dependencies
133+ - setup-postgresql
134+ - build-pgraft
135+ - test-pgraft
136+
137+ build-components :
138+ docker :
139+ - image : cimg/base:stable
140+ steps :
141+ - checkout
142+ - install-dependencies
143+ - build-pgraft
144+ - build-ramd
145+ - build-ramctrl
146+
147+ # Define workflows
148+ workflows :
149+ version : 2
150+ build-and-test :
151+ jobs :
152+ - build-and-test :
153+ filters :
154+ branches :
155+ only : main
156+ - test-pgraft-only :
157+ filters :
158+ branches :
159+ only : develop
160+ - build-components :
161+ filters :
162+ branches :
163+ ignore : [main, develop]
164+
165+ nightly-build :
166+ triggers :
167+ - schedule :
168+ cron : " 0 2 * * *" # Run at 2 AM UTC daily
169+ jobs :
170+ - build-and-test
171+
172+ pull-request :
173+ jobs :
174+ - build-components
0 commit comments