Skip to content

Commit 016ae1f

Browse files
committed
Added SQL Server checks and creating database
1 parent fecee52 commit 016ae1f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/go.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,47 @@ jobs:
124124
# Install PostgreSQL client
125125
sudo apt-get update
126126
sudo apt-get install -y postgresql-client
127+
# Install SQL Server tools
128+
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
129+
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
130+
sudo apt-get update
131+
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev
132+
133+
- name: Create SQL Server user and database
134+
run: |
135+
# Wait for SQL Server to be ready (max 30 attempts)
136+
for i in {1..30}; do
137+
if /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P MyP@ssw0rd123 -Q "SELECT 1" -b -o /dev/null; then
138+
echo "SQL Server is ready!"
139+
break
140+
fi
141+
echo "Waiting for SQL Server... (attempt $i/30)";
142+
sleep 5;
143+
done
144+
145+
# Create database and user
146+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P MyP@ssw0rd123 -Q "
147+
IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'perfkit_db_ci')
148+
BEGIN
149+
CREATE DATABASE perfkit_db_ci;
150+
END
151+
GO
152+
USE perfkit_db_ci;
153+
GO
154+
IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = 'perfkit_db_runner')
155+
BEGIN
156+
CREATE LOGIN perfkit_db_runner WITH PASSWORD = 'MyP@ssw0rd123';
157+
END
158+
GO
159+
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = 'perfkit_db_runner')
160+
BEGIN
161+
CREATE USER perfkit_db_runner FOR LOGIN perfkit_db_runner;
162+
END
163+
GO
164+
ALTER ROLE db_owner ADD MEMBER perfkit_db_runner;
165+
GO
166+
"
167+
echo "Database and user created successfully"
127168
128169
- name: Create vector extension
129170
run: PGPASSWORD=password psql -h localhost -U root -d perfkit_pg_vector_db_ci -c "CREATE EXTENSION vector;"

0 commit comments

Comments
 (0)