Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Version Bump #988

Merged
merged 24 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/integration-mssql-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,23 @@ jobs:
env:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: ${{ env.DB_PASSWORD }}
MSSQL_PID: Developer
ports:
- 1433:1433

steps:
- uses: actions/checkout@v4

- name: Install SQL Server tools (sqlcmd)
run: |
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18>18.0.0

- name: Set up SQL db
working-directory: ${{ env.project_dir }}/data
env:
MSSQL_SA_PASSWORD: ${{env.DB_PASSWORD}}
AUTH_ARG: "N" # I can't get it to install sqlcmd>18. This is a hack
run: |
bash init-db.sh

Expand Down
20 changes: 15 additions & 5 deletions grai-integrations/source-mssql/data/init-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ HOST="${DB_HOST:-localhost}"
PORT="${DB_PORT:-"1433"}"
MSSQL_SA_PASSWORD="${MSSQL_SA_PASSWORD:-"GraiGraiGr4i"}"
SERVER="tcp:$HOST,$PORT"
RETRY_LIMIT=${RETRY_LIMIT:-30}
RETRY_LIMIT=${RETRY_LIMIT:-60}
SQL_CMD_DIR=${SQL_CMD_DIR-"/opt/mssql-tools18/bin"}
export PATH=$PATH:$SQL_CMD_DIR

AUTH_ARG=${AUTH_ARG:-"Y"}
if [ "$AUTH_ARG" == "Y" ]; then
AUTH_ARG="-No"
else
AUTH_ARG=""
fi

SQL_CMD="sqlcmd -S $SERVER -U sa -P $MSSQL_SA_PASSWORD $AUTH_ARG"

/opt/mssql-tools/bin/sqlcmd -S $SERVER -U sa -P $MSSQL_SA_PASSWORD -Q 'SELECT 1' -b -o /dev/null
$SQL_CMD -Q 'SELECT 1' -b -o /dev/null
DBSTATUS=$?

if [[ $DBSTATUS -ne 0 ]]; then
echo "Waiting for database to become ready"
sleep 1
Expand All @@ -20,7 +29,8 @@ i=1
while [[ $DBSTATUS -ne 0 ]] && [[ $i -lt $RETRY_LIMIT ]]; do
i=$((i + 1))

/opt/mssql-tools/bin/sqlcmd -S $SERVER -U sa -P $MSSQL_SA_PASSWORD -Q 'SELECT 1' -b -o /dev/null
${SQL_CMD} -Q 'SELECT 1' -b
# -o /dev/null
DBSTATUS=$?

if [[ $DBSTATUS -ne 0 ]]; then
Expand All @@ -39,5 +49,5 @@ echo "Database ready"
for file in $(find $SCRIPT_DIR -type f -name '*.sql' | sort)
do
echo "Executing init script $file"
/opt/mssql-tools/bin/sqlcmd -U sa -P $MSSQL_SA_PASSWORD -l 30 -e -i $file
${SQL_CMD} -l 30 -e -i $file
done
5 changes: 2 additions & 3 deletions grai-integrations/source-mssql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
Expand All @@ -8,11 +6,12 @@ services:
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: GraiGraiGr4i
MSSQL_PID: Developer
ports:
- 1433:1433
command: ['/bin/bash', '-c', '/init/init-db.sh & /opt/mssql/bin/sqlservr']
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $$MSSQL_SA_PASSWORD -Q 'select 1' -b -o /dev/null
test: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P $$MSSQL_SA_PASSWORD -Q 'select 1' -o /dev/null -b -No
interval: 3s
timeout: 3s
retries: 10
Loading
Loading