From 296167b30d1a54da6b701ea365d384d35a874520 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Fri, 23 Jun 2023 14:14:23 +0200 Subject: [PATCH 01/92] wip pyodbc for mssql --- .env | 3 +++ Dockerfile | 26 +++++++++++++++++++++--- app/config.py | 27 ++++++++++++++++--------- app/database.py | 2 +- app/main.py | 3 +-- app/models/__init__.py | 4 ++-- docker-compose.yml | 46 +++++++++++++++++++++--------------------- 7 files changed, 71 insertions(+), 40 deletions(-) diff --git a/.env b/.env index 2112709..d341aea 100644 --- a/.env +++ b/.env @@ -11,3 +11,6 @@ POSTGRES_PASSWORD=secret SQLALCHEMY_WARN_20=1 ACCEPT_EULA=Y +MSSQL_DB=master +MSSQL_HOST=sqlserver +MSSQL_USER=sa \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 384ff8f..424a5c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,32 @@ -FROM python:3.10-slim-buster AS base +FROM python:3.10-slim-bullseye AS base RUN apt-get update \ && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends curl git build-essential \ + && apt-get install -y --no-install-recommends gnupg2 curl \ && apt-get autoremove -y \ && apt-get clean \ && rm -rf /var/apt/lists/* \ && rm -rf /var/cache/apt/* + +FROM base AS msodbcsql18 +# https://docs.microsoft.com/en-us/sql/connect/odbc/linux/installing-the-microsoft-odbc-driver-for-sql-server-on-linux +RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - +RUN curl curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list + +RUN apt-get update +RUN ACCEPT_EULA=Y apt-get install -y msodbcsql18 +# optional: for bcp and sqlcmd +RUN ACCEPT_EULA=Y apt-get install -y mssql-tools18 +#RUN echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc +#RUN source ~/.bashrc +# optional: for unixODBC development headers +#RUN apt-get install -y unixodbc-dev +# optional: kerberos library for debian-slim distributions +#RUN apt-get install -y libgssapi-krb5-2 + + +FROM msodbcsql18 AS poetry + ENV POETRY_HOME="/opt/poetry" ENV PATH="$POETRY_HOME/bin:$PATH" \ POETRY_VERSION=1.4.2 @@ -15,7 +35,7 @@ RUN curl -sSL https://install.python-poetry.org | python3 - \ && mkdir -p /cache/poetry \ && poetry config cache-dir /cache/poetry -FROM base AS install +FROM poetry AS install WORKDIR /home/code # allow controlling the poetry installation of dependencies via external args diff --git a/app/config.py b/app/config.py index 6e443a8..fccc6b8 100644 --- a/app/config.py +++ b/app/config.py @@ -1,19 +1,28 @@ import os from functools import lru_cache -from pydantic import BaseSettings, PostgresDsn +from pydantic import BaseSettings, PostgresDsn, AnyUrl + + +class SqlServerUrl(AnyUrl): + allowed_schemes = { + "mssql+pyodbc", + } + user_required = True + password_required = True + host_required = True class Settings(BaseSettings): - pg_url: PostgresDsn = PostgresDsn.build( - scheme="postgresql", - user=os.getenv("SQL_USER"), - password=os.getenv("POSTGRES_PASSWORD"), - host=os.getenv("SQL_HOST"), - port="5432", - path=f"/{os.getenv('SQL_DB') or ''}", + sqlserver_url: SqlServerUrl = SqlServerUrl.build( + scheme="mssql+pyodbc", + user=os.getenv("MSSQL_USER"), + password=os.getenv("MSSQL_SA_PASSWORD"), + host=os.getenv("MSSQL_HOST"), + port="1433", + path=f"/{os.getenv('MSSQL_DB') or ''}", + query="driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes" ) - pg_url_csearch_path: str = os.getenv("SQL_CSEARCH_PATH") sql_datasource_name: str = os.getenv("SQL_DATASOURCE_NAME", "default") diff --git a/app/database.py b/app/database.py index 8c7a424..e0ade0c 100644 --- a/app/database.py +++ b/app/database.py @@ -9,7 +9,7 @@ from app.models.base import Base engine = create_engine( - settings.pg_url.__str__(), + settings.sqlserver_url.__str__(), echo=True, ) diff --git a/app/main.py b/app/main.py index fca5245..19ee4ab 100644 --- a/app/main.py +++ b/app/main.py @@ -21,8 +21,7 @@ @app.on_event("startup") def startup_event(): app.state.gx = GxSession( - settings.pg_url.__str__() - + f"?options=-csearch_path={settings.pg_url_csearch_path}", + settings.sqlserver_url.__str__(), settings.sql_datasource_name, ) start_db() diff --git a/app/models/__init__.py b/app/models/__init__.py index 1916814..40bb2d4 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -1,2 +1,2 @@ -from app.models.expectation import ExpectationStore -from app.models.validation import ValidationStore +# from app.models.expectation import ExpectationStore +# from app.models.validation import ValidationStore diff --git a/docker-compose.yml b/docker-compose.yml index db98a98..4ae6adc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: ports: - 8585:8080 depends_on: - - db + - sqlserver command: bash -c " uvicorn app.main:app --log-config ./logger.ini @@ -41,28 +41,28 @@ services: - 1433:1433 - db: - build: - context: ./db - dockerfile: Dockerfile - volumes: - - postgres_data:/var/lib/postgresql/data - env_file: - - .env - - .secrets - ports: - - 5432:5432 - environment: - - POSTGRES_USER=${SQL_USER} - healthcheck: - test: - [ - "CMD-SHELL", "pg_isready -d $SQL_DB -U $SQL_USER" - ] - interval: 5s - timeout: 5s - retries: 5 +# db: +# build: +# context: ./db +# dockerfile: Dockerfile +# volumes: +# - postgres_data:/var/lib/postgresql/data +# env_file: +# - .env +# - .secrets +# ports: +# - 5432:5432 +# environment: +# - POSTGRES_USER=${SQL_USER} +# healthcheck: +# test: +# [ +# "CMD-SHELL", "pg_isready -d $SQL_DB -U $SQL_USER" +# ] +# interval: 5s +# timeout: 5s +# retries: 5 volumes: - postgres_data: +# postgres_data: sqlserver_data: From f2acd8d9fec2874a6de93bef9f66c6ef1d1d7b4e Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Tue, 27 Jun 2023 12:15:31 +0200 Subject: [PATCH 02/92] update poetry to 1.5.1 --- .github/workflows/build-and-test.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2d414fe..c0454a6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: python-version: [ "3.10" ] - poetry-version: [ "1.4.0" ] + poetry-version: [ "1.5.1" ] env: diff --git a/Dockerfile b/Dockerfile index 424a5c0..33c0f8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ FROM msodbcsql18 AS poetry ENV POETRY_HOME="/opt/poetry" ENV PATH="$POETRY_HOME/bin:$PATH" \ - POETRY_VERSION=1.4.2 + POETRY_VERSION=1.5.1 RUN curl -sSL https://install.python-poetry.org | python3 - \ && poetry config virtualenvs.create false \ && mkdir -p /cache/poetry \ From 37275d1548d151c6ebb70f50fb57e5748ff13432 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:19:50 +0200 Subject: [PATCH 03/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 40 ++++++++++++++++++++-------- .secrets | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index c0454a6..fe278b5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -24,23 +24,41 @@ jobs: SQL_DATASOURCE_NAME: my_gxshakezz services: - postgres: - image: postgres:14 + mssql: + image: mcr.microsoft.com/mssql/server:2022-latest env: - # must specify password for PG Docker container image, see: https://registry.hub.docker.com/_/postgres?tab=description&page=1&name=10 - POSTGRES_PASSWORD: secret - POSTGRES_DB: testdb + SA_PASSWORD: pass + ACCEPT_EULA: Y ports: - - 5432:5432 - # needed because the postgres container does not provide a health check - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + - 1433:1433 + +# postgres: +# image: postgres:14 +# env: +# # must specify password for PG Docker container image, see: https://registry.hub.docker.com/_/postgres?tab=description&page=1&name=10 +# POSTGRES_PASSWORD: secret +# POSTGRES_DB: testdb +# ports: +# - 5432:5432 +# # needed because the postgres container does not provide a health check +# options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v3 - - name: Feed Database - run: psql -d postgresql://postgres@localhost/testdb -f ./db/shakespeare.sql + - name: Install SQL Server Tools + run: | + curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 + echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc + source ~/.bashrc + - name: Restore database from backup +# working-directory: /opt/mssql-tools18/bin + run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql env: - PGPASSWORD: secret + SA_PASSWORD: pass + ACCEPT_EULA: Y - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} diff --git a/.secrets b/.secrets index 99aa9be..171582e 100644 --- a/.secrets +++ b/.secrets @@ -1,2 +1,2 @@ POSTGRES_PASSWORD=secret -MSSQL_SA_PASSWORD=yourStrong(!)Password \ No newline at end of file +MSSQL_SA_PASSWORD=pass \ No newline at end of file From bb0d501fde42b48ef579a370c6eb424e6bc2849f Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:23:24 +0200 Subject: [PATCH 04/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fe278b5..7044df7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,8 +47,8 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + sudo curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc From 2b476dc3fe7195dddbc512f9ca993cb1692ebcf5 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:26:25 +0200 Subject: [PATCH 05/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7044df7..64dae05 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -48,11 +48,11 @@ jobs: - name: Install SQL Server Tools run: | sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - sudo curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc - source ~/.bashrc +# sudo curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list +# sudo apt-get update +# sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 +# echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc +# source ~/.bashrc - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From 43850d8f0dece4c6de18afca55c16b4ffd2d0a6e Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:29:06 +0200 Subject: [PATCH 06/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 64dae05..2bbcf4f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc # sudo curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list # sudo apt-get update # sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 From 43e30be65d3bd54d6b67610bc161f105835eac35 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:30:41 +0200 Subject: [PATCH 07/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2bbcf4f..7e34cca 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -48,11 +48,11 @@ jobs: - name: Install SQL Server Tools run: | sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc -# sudo curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list -# sudo apt-get update -# sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 -# echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc -# source ~/.bashrc + sudo curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 + echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc + source ~/.bashrc - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From dfab80cc69364df28a6817626d2ddc8f8cb83e72 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:33:02 +0200 Subject: [PATCH 08/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7e34cca..0a171dd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -48,7 +48,7 @@ jobs: - name: Install SQL Server Tools run: | sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - sudo curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc From c6799da8b8b5c04b718c70ad6ebf9400b509c3bf Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:35:52 +0200 Subject: [PATCH 09/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0a171dd..bad75d0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,10 +47,10 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - sudo curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 + curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + apt-get update + ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc source ~/.bashrc - name: Restore database from backup From 524ac07af07e36e8c7ae83918ba4238324ab5657 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:37:00 +0200 Subject: [PATCH 10/92] update github ci workflow for sqlserver --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index bad75d0..42c6ef1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -48,7 +48,7 @@ jobs: - name: Install SQL Server Tools run: | curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc From 738d967bddc86521a6b363d19b9aaeee2cf7d081 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:40:16 +0200 Subject: [PATCH 11/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 42c6ef1..120af18 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -4,7 +4,7 @@ on: pull_request jobs: ci: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: @@ -47,8 +47,9 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo su + curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc From 0805827b8408336afc75284d086a4ea622d9b647 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:41:31 +0200 Subject: [PATCH 12/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 120af18..e91c9e2 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,7 +47,6 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo su curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update From 2743e4931babcfdea4d001e8726c487f6f4a21aa Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:43:02 +0200 Subject: [PATCH 13/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e91c9e2..1a21955 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,12 +47,12 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list - apt-get update - ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc - source ~/.bashrc + sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 + sudo echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc + sudo source ~/.bashrc - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From 02d01b1a8bd79464eb47f2031684dd7f10996546 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:45:29 +0200 Subject: [PATCH 14/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1a21955..e448128 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -48,11 +48,11 @@ jobs: - name: Install SQL Server Tools run: | sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - sudo echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc - sudo source ~/.bashrc +# sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list +# sudo apt-get update +# sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 +# sudo echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc +# sudo source ~/.bashrc - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From 6b1ce7ef801ddbeb036ff0861fc29fbe2b5c983d Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 12:49:23 +0200 Subject: [PATCH 15/92] update github ci workflow for sqlserver - try with ubuntu 22.04 --- .github/workflows/build-and-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e448128..bad75d0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -4,7 +4,7 @@ on: pull_request jobs: ci: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -47,12 +47,12 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - -# sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list -# sudo apt-get update -# sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 -# sudo echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc -# sudo source ~/.bashrc + curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + apt-get update + ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 + echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc + source ~/.bashrc - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From 26549f3caa47ff4d752021ff0fdc9e490a825e28 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 13:57:07 +0200 Subject: [PATCH 16/92] update github ci workflow for sqlserver - try with ubuntu 22.04 --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index bad75d0..a0211b5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + curl https://packages.microsoft.com/keys/microsoft.asc | gpg | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 From 1cdba332a636278cdcd72ce14be023b7cd6131d1 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 13:58:57 +0200 Subject: [PATCH 17/92] update github ci workflow for sqlserver - try with ubuntu 22.04 --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a0211b5..6012633 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,8 +47,8 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - curl https://packages.microsoft.com/keys/microsoft.asc | gpg | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + sudo curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc From 53addf6f912012092677307375fb5dd0cc350a72 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 14:00:33 +0200 Subject: [PATCH 18/92] update github ci workflow for sqlserver - try with ubuntu 22.04 --- .github/workflows/build-and-test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6012633..80b14c5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -4,7 +4,7 @@ on: pull_request jobs: ci: - runs-on: ubuntu-latest + runs-on: ubuntu-22.10 strategy: fail-fast: false matrix: @@ -47,8 +47,9 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - sudo curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo su + curl https://packages.microsoft.com/keys/microsoft.asc | gpg | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc + curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc From 151758cced133362d917cd74f4d618667f62b374 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 14:31:44 +0200 Subject: [PATCH 19/92] update github ci workflow for sqlserver - try with debian 11 --- .github/workflows/build-and-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 80b14c5..8d61b97 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -4,7 +4,7 @@ on: pull_request jobs: ci: - runs-on: ubuntu-22.10 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -48,8 +48,8 @@ jobs: - name: Install SQL Server Tools run: | sudo su - curl https://packages.microsoft.com/keys/microsoft.asc | gpg | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc - curl https://packages.microsoft.com/config/ubuntu/22.10/prod.list > /etc/apt/sources.list.d/mssql-release.list + curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl curl curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc From 567f16923e39508b74f64ff1e4bf97be49ff6c6f Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 15:00:37 +0200 Subject: [PATCH 20/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 8d61b97..7368bb9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -4,7 +4,7 @@ on: pull_request jobs: ci: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: From be503049e71ebd809ed245abf51e8c68985fc89c Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 15:51:04 +0200 Subject: [PATCH 21/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7368bb9..b6bcac3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -48,12 +48,14 @@ jobs: - name: Install SQL Server Tools run: | sudo su - curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - curl curl curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list + apt-get install gnupg2 curl ca-certificates + curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update - ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc - source ~/.bashrc + ACCEPT_EULA=Y apt-get install -y msodbcsql18 + ACCEPT_EULA=Y apt-get install -y mssql-tools18 +# echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc +# source ~/.bashrc - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From 0787c519dc674fe3b993a22d75f322076817a0cc Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 15:57:06 +0200 Subject: [PATCH 22/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b6bcac3..547bb25 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -15,13 +15,8 @@ jobs: env: PYTHONDONTWRITEBYTECODE: 1 PYTHONUNBUFFERED: 1 - SQL_DB: testdb - SQL_HOST: 127.0.0.1 - SQL_USER: postgres - POSTGRES_PASSWORD: secret - PGPASSWORD: secret - SQL_CSEARCH_PATH: shakespeare - SQL_DATASOURCE_NAME: my_gxshakezz + SA_PASSWORD: pass + ACCEPT_EULA: Y services: mssql: @@ -52,10 +47,9 @@ jobs: curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update - ACCEPT_EULA=Y apt-get install -y msodbcsql18 - ACCEPT_EULA=Y apt-get install -y mssql-tools18 -# echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc -# source ~/.bashrc + apt-get install msodbcsql18 mssql-tools18 + env: + ACCEPT_EULA: Y - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From fe646cc906d6fab7c3fb38c0383c5893765f8f4e Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:05:35 +0200 Subject: [PATCH 23/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 547bb25..3c61921 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,9 +47,8 @@ jobs: curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update - apt-get install msodbcsql18 mssql-tools18 - env: - ACCEPT_EULA: Y + ACCEPT_EULA=Y apt-get install -y msodbcsql18 + - name: Restore database from backup # working-directory: /opt/mssql-tools18/bin run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql From 1a4c80ccd846dea8e6ac2f08bd7cfb0a035af8e9 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:08:05 +0200 Subject: [PATCH 24/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3c61921..b1a5aa9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -48,26 +48,26 @@ jobs: curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update ACCEPT_EULA=Y apt-get install -y msodbcsql18 - - - name: Restore database from backup -# working-directory: /opt/mssql-tools18/bin - run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql - env: - SA_PASSWORD: pass - ACCEPT_EULA: Y - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install Poetry - uses: abatilo/actions-poetry@v2 - with: - poetry-version: ${{ matrix.poetry-version }} - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - - name: Test Code Coverage - run: poetry run coverage run -m pytest -v --cov=app --cov-report=xml - - name: Coveralls - uses: coverallsapp/github-action@v2 +# +# - name: Restore database from backup +## working-directory: /opt/mssql-tools18/bin +# run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql +# env: +# SA_PASSWORD: pass +# ACCEPT_EULA: Y +# - uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Install Poetry +# uses: abatilo/actions-poetry@v2 +# with: +# poetry-version: ${{ matrix.poetry-version }} +# - name: Install dependencies +# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' +# run: poetry install --no-interaction --no-root +# - name: Test Code Coverage +# run: poetry run coverage run -m pytest -v --cov=app --cov-report=xml +# - name: Coveralls +# uses: coverallsapp/github-action@v2 From 87ac70cd34777e288b51a3594d7ef9d39ef0e1f3 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:10:06 +0200 Subject: [PATCH 25/92] update github ci workflow for sqlserver - try with ubuntu 20.04 --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b1a5aa9..26f8bb6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,7 +47,7 @@ jobs: curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update - ACCEPT_EULA=Y apt-get install -y msodbcsql18 + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 # # - name: Restore database from backup ## working-directory: /opt/mssql-tools18/bin From eb4ef0648c1338c672229b8816c979dbb6450f09 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:14:59 +0200 Subject: [PATCH 26/92] update github ci workflow for sqlserver - sudo fix --- .github/workflows/build-and-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 26f8bb6..cfe8c13 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,12 +42,11 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo su apt-get install gnupg2 curl ca-certificates curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 + ACCEPT_EULA=Y apt-get install -y msodbcsql18 # # - name: Restore database from backup ## working-directory: /opt/mssql-tools18/bin From 46fd6e69c402663fbdf235e264911288f17a854e Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:16:09 +0200 Subject: [PATCH 27/92] update github ci workflow for sqlserver - sudo fix --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index cfe8c13..f23f86b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -46,7 +46,7 @@ jobs: curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list apt-get update - ACCEPT_EULA=Y apt-get install -y msodbcsql18 +# ACCEPT_EULA=Y apt-get install -y msodbcsql18 # # - name: Restore database from backup ## working-directory: /opt/mssql-tools18/bin From 15446e2418dc8e2ec2e2e0da453fe35431838e71 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:17:27 +0200 Subject: [PATCH 28/92] update github ci workflow for sqlserver - sudo fix --- .github/workflows/build-and-test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f23f86b..903eab9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,10 +42,11 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - apt-get install gnupg2 curl ca-certificates - curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list - apt-get update + sudo apt-get update + sudo apt-get install gnupg2 curl ca-certificates + sudo curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + sudo curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo apt-get update # ACCEPT_EULA=Y apt-get install -y msodbcsql18 # # - name: Restore database from backup From f05b89e82eeb38cd25a877a083933aa113930734 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:18:06 +0200 Subject: [PATCH 29/92] update github ci workflow for sqlserver - sudo fix --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 903eab9..607646b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -44,8 +44,8 @@ jobs: run: | sudo apt-get update sudo apt-get install gnupg2 curl ca-certificates - sudo curl curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - sudo curl curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list sudo apt-get update # ACCEPT_EULA=Y apt-get install -y msodbcsql18 # From 656b06325c87c5e169a7e8a669a5a49163c99c23 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:21:00 +0200 Subject: [PATCH 30/92] update github ci workflow for sqlserver - sudo fix --- .github/workflows/build-and-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 607646b..26916b5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,8 +42,7 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo apt-get update - sudo apt-get install gnupg2 curl ca-certificates + apt-get update sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list sudo apt-get update From e0d512e0e69df90084469f404507d2ec5cab9fce Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:28:01 +0200 Subject: [PATCH 31/92] update github ci workflow for sqlserver - drop apt-get update --- .github/workflows/build-and-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 26916b5..57e2f3f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,10 +42,9 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - apt-get update sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list - sudo apt-get update + # ACCEPT_EULA=Y apt-get install -y msodbcsql18 # # - name: Restore database from backup From f4250c08f09b70392dc1ce2677006648252fb3d4 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:30:34 +0200 Subject: [PATCH 32/92] update github ci workflow for sqlserver - drop apt-get update --- .github/workflows/build-and-test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 57e2f3f..d4d63ea 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,13 +10,13 @@ jobs: matrix: python-version: [ "3.10" ] poetry-version: [ "1.5.1" ] - - - env: - PYTHONDONTWRITEBYTECODE: 1 - PYTHONUNBUFFERED: 1 - SA_PASSWORD: pass - ACCEPT_EULA: Y +# +# +# env: +# PYTHONDONTWRITEBYTECODE: 1 +# PYTHONUNBUFFERED: 1 +# SA_PASSWORD: pass +# ACCEPT_EULA: Y services: mssql: @@ -42,8 +42,8 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - sudo curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list # ACCEPT_EULA=Y apt-get install -y msodbcsql18 # From eb9b217cc3d4f50261b532fab23f3a34d96f7b06 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:33:47 +0200 Subject: [PATCH 33/92] update github ci workflow for sqlserver - drop apt-get update --- .github/workflows/build-and-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d4d63ea..f67f741 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,6 +42,7 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | + sudo su curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list From 25e45b637f84759caa9ef4a6f2d54ceee7acd88e Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:36:55 +0200 Subject: [PATCH 34/92] update github ci workflow for sqlserver - drop apt-get update --- .github/workflows/build-and-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f67f741..e8b14d3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,11 +42,11 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: | - sudo su - curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list +# sudo su +# curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - +# curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list -# ACCEPT_EULA=Y apt-get install -y msodbcsql18 + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 # # - name: Restore database from backup ## working-directory: /opt/mssql-tools18/bin From 9161d60c69fd44787fadb64bc80f99f35b1c458a Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Wed, 28 Jun 2023 16:38:57 +0200 Subject: [PATCH 35/92] update github ci workflow for sqlserver - drop apt-get update --- .github/workflows/build-and-test.yml | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e8b14d3..0bb9421 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -41,32 +41,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install SQL Server Tools - run: | -# sudo su -# curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - -# curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 -# -# - name: Restore database from backup -## working-directory: /opt/mssql-tools18/bin -# run: ./sqlcmd -S mssql+pyodbc://sa:pass@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U sa -P 'pass' -d master -i /sqlserver/setup/restore.sql -# env: -# SA_PASSWORD: pass -# ACCEPT_EULA: Y -# - uses: actions/setup-python@v4 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Install Poetry -# uses: abatilo/actions-poetry@v2 -# with: -# poetry-version: ${{ matrix.poetry-version }} -# - name: Install dependencies -# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' -# run: poetry install --no-interaction --no-root -# - name: Test Code Coverage -# run: poetry run coverage run -m pytest -v --cov=app --cov-report=xml -# - name: Coveralls -# uses: coverallsapp/github-action@v2 From 70e7bed6f3cd2297cf233c374135edab55d08291 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 12:41:26 +0200 Subject: [PATCH 36/92] update github ci workflow for sqlserver - download backup --- .github/workflows/build-and-test.yml | 47 +++++++++++++++------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0bb9421..cac2536 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,13 +10,13 @@ jobs: matrix: python-version: [ "3.10" ] poetry-version: [ "1.5.1" ] -# -# -# env: -# PYTHONDONTWRITEBYTECODE: 1 -# PYTHONUNBUFFERED: 1 -# SA_PASSWORD: pass -# ACCEPT_EULA: Y + + + env: + PYTHONDONTWRITEBYTECODE: 1 + PYTHONUNBUFFERED: 1 + SA_PASSWORD: pass + ACCEPT_EULA: Y services: mssql: @@ -27,21 +27,24 @@ jobs: ports: - 1433:1433 -# postgres: -# image: postgres:14 -# env: -# # must specify password for PG Docker container image, see: https://registry.hub.docker.com/_/postgres?tab=description&page=1&name=10 -# POSTGRES_PASSWORD: secret -# POSTGRES_DB: testdb -# ports: -# - 5432:5432 -# # needed because the postgres container does not provide a health check -# options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - uses: actions/checkout@v3 - name: Install SQL Server Tools - run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - - - + run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 + - name: Download AdventureWorksLT2022 backup + run: curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + - name: Test Code Coverage + run: poetry run coverage run -m pytest -v --cov=app --cov-report=xml + - name: Coveralls + uses: coverallsapp/github-action@v2 From e84c665e77a3f990c62bb2513cf03a22952d3df7 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 12:41:26 +0200 Subject: [PATCH 37/92] update github ci workflow for sqlserver - download backup --- .github/workflows/build-and-test.yml | 47 +++++++++++++++------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0bb9421..4d76ec2 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,13 +10,13 @@ jobs: matrix: python-version: [ "3.10" ] poetry-version: [ "1.5.1" ] -# -# -# env: -# PYTHONDONTWRITEBYTECODE: 1 -# PYTHONUNBUFFERED: 1 -# SA_PASSWORD: pass -# ACCEPT_EULA: Y + + + env: + PYTHONDONTWRITEBYTECODE: 1 + PYTHONUNBUFFERED: 1 + SA_PASSWORD: pass + ACCEPT_EULA: Y services: mssql: @@ -27,21 +27,24 @@ jobs: ports: - 1433:1433 -# postgres: -# image: postgres:14 -# env: -# # must specify password for PG Docker container image, see: https://registry.hub.docker.com/_/postgres?tab=description&page=1&name=10 -# POSTGRES_PASSWORD: secret -# POSTGRES_DB: testdb -# ports: -# - 5432:5432 -# # needed because the postgres container does not provide a health check -# options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - uses: actions/checkout@v3 - name: Install SQL Server Tools - run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - - - + run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 + - name: Download AdventureWorksLT2022 backup + run: curl -L -o ./db/sqlserver/restore/AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + - name: Test Code Coverage + run: poetry run coverage run -m pytest -v --cov=app --cov-report=xml + - name: Coveralls + uses: coverallsapp/github-action@v2 From 6a04e75db09efc5829e048e2b57e91a19a606b3e Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 12:47:00 +0200 Subject: [PATCH 38/92] update github ci workflow for sqlserver - download backup --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4d76ec2..8f6369f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -32,7 +32,7 @@ jobs: - name: Install SQL Server Tools run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - name: Download AdventureWorksLT2022 backup - run: curl -L -o ./db/sqlserver/restore/AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak + run: curl -L -o ./sqlserver/restore/AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - uses: actions/setup-python@v4 with: From 13562f09bfd8e2b3e757c045267bfad3e1748357 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 12:51:15 +0200 Subject: [PATCH 39/92] update github ci workflow for sqlserver - download backup --- .github/workflows/build-and-test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 8f6369f..ce05cb0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -32,7 +32,11 @@ jobs: - name: Install SQL Server Tools run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - name: Download AdventureWorksLT2022 backup - run: curl -L -o ./sqlserver/restore/AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak + run: | + pwd + ld -al + curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak +# - name: Restore AdventureWorksLT2022 backup - uses: actions/setup-python@v4 with: From 8afdf03c2e9267f04e94c0c900f829b4f9512880 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 12:52:44 +0200 Subject: [PATCH 40/92] update github ci workflow for sqlserver - download backup --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ce05cb0..d9b35e1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -34,7 +34,7 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | pwd - ld -al + ls -la curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak # - name: Restore AdventureWorksLT2022 backup From 5664a67fd4ff07baecca79ca56144fcf7ec6fb0d Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:05:03 +0200 Subject: [PATCH 41/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d9b35e1..5a47daf 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -36,7 +36,10 @@ jobs: pwd ls -la curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak -# - name: Restore AdventureWorksLT2022 backup + mv AdventureWorksLT2022.bak /var/opt/mssql/data/ + - name: Restore AdventureWorksLT2022 backup + working-directory: /opt/mssql-tools/bin + run: ./sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" - uses: actions/setup-python@v4 with: From c48100f63aa3e87349230ebedb71987adb416644 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:06:23 +0200 Subject: [PATCH 42/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5a47daf..23ee7a4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -36,7 +36,6 @@ jobs: pwd ls -la curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - mv AdventureWorksLT2022.bak /var/opt/mssql/data/ - name: Restore AdventureWorksLT2022 backup working-directory: /opt/mssql-tools/bin run: ./sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" From 9aea9b34ecc07b512c4add70cd8e91900fed63d2 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:08:39 +0200 Subject: [PATCH 43/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 23ee7a4..34df615 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -35,10 +35,12 @@ jobs: run: | pwd ls -la + cd /opt/mssql-tools/bin + ls -la curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - name: Restore AdventureWorksLT2022 backup - working-directory: /opt/mssql-tools/bin - run: ./sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" +# working-directory: /opt/mssql-tools/bin + run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" - uses: actions/setup-python@v4 with: From 0847d4e57d87769a1437efd9f48999d946674b4c Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:12:38 +0200 Subject: [PATCH 44/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 34df615..695d11b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -40,8 +40,8 @@ jobs: curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - name: Restore AdventureWorksLT2022 backup # working-directory: /opt/mssql-tools/bin - run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" - +# run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" + run: /opt/mssql-tools/bin/sqlcmd - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From dbadcbad6f159efb33003a8e07f913a070668d4f Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:14:16 +0200 Subject: [PATCH 45/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 695d11b..13676d5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -35,7 +35,7 @@ jobs: run: | pwd ls -la - cd /opt/mssql-tools/bin + cd /opt ls -la curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - name: Restore AdventureWorksLT2022 backup From 777161a00a867a256802c8261d6e0e158cd354a1 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:20:12 +0200 Subject: [PATCH 46/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 13676d5..62dbe79 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -41,7 +41,7 @@ jobs: - name: Restore AdventureWorksLT2022 backup # working-directory: /opt/mssql-tools/bin # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" - run: /opt/mssql-tools/bin/sqlcmd + run: /opt/mssql-tools18/bin/sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From a73e3740887b1236e9649b25c4e1ce6d0e48110e Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:23:35 +0200 Subject: [PATCH 47/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 62dbe79..fd78303 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -41,7 +41,9 @@ jobs: - name: Restore AdventureWorksLT2022 backup # working-directory: /opt/mssql-tools/bin # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" - run: /opt/mssql-tools18/bin/sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" + run: | + /opt/mssql-tools18/bin/sqlcmd -? + /opt/mssql-tools18/bin/sqlcmd -S mssql+pyodbc://localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 54cb4be69df709e2b691ae151e4a281e2cfa3145 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:29:06 +0200 Subject: [PATCH 48/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fd78303..2e814dd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -43,7 +43,7 @@ jobs: # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S mssql+pyodbc://localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA + /opt/mssql-tools18/bin/sqlcmd -S mssql -U sa -P 'pass' -d master -Q "select 1;" - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 14d937fb7f9ca5c751ce1a6d5a2f1cf9592f09ff Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:31:29 +0200 Subject: [PATCH 49/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2e814dd..05fcec7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -43,7 +43,7 @@ jobs: # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S mssql -U sa -P 'pass' -d master -Q "select 1;" + /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'pass' -d master -Q "select 1;" - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 687df2624b30ba9ee8ab080ba361529bb8556d4d Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:36:28 +0200 Subject: [PATCH 50/92] update github ci workflow for sqlserver - test sqlcmd --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 05fcec7..2e814dd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -43,7 +43,7 @@ jobs: # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'pass' -d master -Q "select 1;" + /opt/mssql-tools18/bin/sqlcmd -S mssql -U sa -P 'pass' -d master -Q "select 1;" - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 56d6e63cdd7c5f187e173f57e831d0eebcc37b8a Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:45:45 +0200 Subject: [PATCH 51/92] update github ci workflow for sqlserver - sqlcmd health-cmd --- .github/workflows/build-and-test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2e814dd..e32e446 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -22,10 +22,12 @@ jobs: mssql: image: mcr.microsoft.com/mssql/server:2022-latest env: - SA_PASSWORD: pass + SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y ports: - 1433:1433 + options: --name=mssql --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: - uses: actions/checkout@v3 @@ -43,7 +45,7 @@ jobs: # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S mssql -U sa -P 'pass' -d master -Q "select 1;" + /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE test_db' - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 8d9eb87e433b0a34b18ed4dc2eb0038bfffbf6f6 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Thu, 29 Jun 2023 13:52:09 +0200 Subject: [PATCH 52/92] update github ci workflow for sqlserver - sqlcmd health-cmd --- .github/workflows/build-and-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e32e446..7b9ae6b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -24,9 +24,10 @@ jobs: env: SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y + MSSQL_PID: Developer ports: - 1433:1433 - options: --name=mssql --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 + options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 steps: From c19c05cbacc3388fa2f2be408b80a1824a88acf7 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 16:50:18 +0200 Subject: [PATCH 53/92] update github ci workflow for sqlserver - sqlcmd health-cmd --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7b9ae6b..3f443ec 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -42,11 +42,11 @@ jobs: ls -la curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - name: Restore AdventureWorksLT2022 backup -# working-directory: /opt/mssql-tools/bin +# working-directory: /opt/mssql-tools18/bin # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE test_db' + /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C yes -Q 'CREATE DATABASE test_db' - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 29181f37b1b05946c2e0f56bfc030f9018c0b926 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 16:54:24 +0200 Subject: [PATCH 54/92] update github ci workflow for sqlserver - sqlcmd health-cmd --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3f443ec..98690be 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -46,7 +46,7 @@ jobs: # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C yes -Q 'CREATE DATABASE test_db' + /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -Q 'CREATE DATABASE test_db' - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 10a1828d572bbefa9e28c2afea4592461d0a4fd3 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 17:00:17 +0200 Subject: [PATCH 55/92] update github ci workflow for sqlserver - sqlcmd health-cmd --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 98690be..4ad079a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -38,7 +38,7 @@ jobs: run: | pwd ls -la - cd /opt + cd /var/opt/mssql/backup/ ls -la curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - name: Restore AdventureWorksLT2022 backup From 4eb27ed4943b884b7491fe73a8e9a01b0dd939f6 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 17:07:19 +0200 Subject: [PATCH 56/92] update github ci workflow for sqlserver - sqlcmd restore from bak --- .github/workflows/build-and-test.yml | 2 +- sqlserver/setup/restore-ci.sql | 13 +++++++++++++ sqlserver/setup/restore.sql | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 sqlserver/setup/restore-ci.sql diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4ad079a..11ca9c3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -46,7 +46,7 @@ jobs: # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -Q 'CREATE DATABASE test_db' + /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /sqlserver/setup/restore-ci.sql - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} diff --git a/sqlserver/setup/restore-ci.sql b/sqlserver/setup/restore-ci.sql new file mode 100644 index 0000000..189e169 --- /dev/null +++ b/sqlserver/setup/restore-ci.sql @@ -0,0 +1,13 @@ +/* + +Restore a database from a backup file + +*/ +CREATE DATABASE AdventureWorksLT2022; +GO + +RESTORE DATABASE AdventureWorksLT2022 FROM DISK = 'AdventureWorksLT2022.bak' + WITH REPLACE, + MOVE 'AdventureWorksLT2022_Data' TO '/var/opt/mssql/data/AdventureWorksLT2022.mdf', + MOVE 'AdventureWorksLT2022_log' TO '/var/opt/mssql/data/AdventureWorksLT2022_log.ldf'; +GO diff --git a/sqlserver/setup/restore.sql b/sqlserver/setup/restore.sql index 9b6dcc3..16fdfb0 100644 --- a/sqlserver/setup/restore.sql +++ b/sqlserver/setup/restore.sql @@ -9,5 +9,5 @@ GO RESTORE DATABASE AdventureWorksLT2022 FROM DISK = '/var/opt/mssql/backup/AdventureWorksLT2022.bak' WITH REPLACE, MOVE 'AdventureWorksLT2022_Data' TO '/var/opt/mssql/data/AdventureWorksLT2022.mdf', - MOVE 'AdventureWorksLT2022_log' TO '/var/opt/mssql/data/AdventureWorksLT2022_log.ldf' + MOVE 'AdventureWorksLT2022_log' TO '/var/opt/mssql/data/AdventureWorksLT2022_log.ldf'; GO From 392ca976e00abda6057e2ab150cd56326c1464ab Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 17:10:02 +0200 Subject: [PATCH 57/92] update github ci workflow for sqlserver - sqlcmd restore from bak --- .github/workflows/build-and-test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 11ca9c3..d1ce294 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -27,6 +27,12 @@ jobs: MSSQL_PID: Developer ports: - 1433:1433 + run: | + pwd + ls -la + cd /var/opt/mssql/backup/ + ls -la + curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 From ced15516b5762488fa2adadd188ab92b90952a0d Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 17:26:30 +0200 Subject: [PATCH 58/92] update github ci workflow for sqlserver - sqlcmd restore https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/adventure-works/data-warehouse-install-script/instawdbdw.sql --- .github/workflows/build-and-test.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d1ce294..158cbfc 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -27,12 +27,6 @@ jobs: MSSQL_PID: Developer ports: - 1433:1433 - run: | - pwd - ls -la - cd /var/opt/mssql/backup/ - ls -la - curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 @@ -40,19 +34,12 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - - name: Download AdventureWorksLT2022 backup - run: | - pwd - ls -la - cd /var/opt/mssql/backup/ - ls -la - curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - - name: Restore AdventureWorksLT2022 backup + - name: Build AdventureWorks from script # working-directory: /opt/mssql-tools18/bin # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" run: | /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /sqlserver/setup/restore-ci.sql + /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/adventure-works/data-warehouse-install-script/instawdbdw.sql - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 853f02be7e21932a20127a54ef35c7856c150c53 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 18:55:13 +0200 Subject: [PATCH 59/92] update github ci workflow for sqlserver - sqlcmd curl and unzip AdventureWorks-oltp-install-script.zip --- .github/workflows/build-and-test.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 158cbfc..0b7d6c1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -34,12 +34,19 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - - name: Build AdventureWorks from script -# working-directory: /opt/mssql-tools18/bin + - name: Download AdventureWorksLT2022 backup + run: | + pwd + ls -la + cd /var/opt/mssql/backup/ + ls -la + curl -L -o AdventureWorks-oltp-install-script.zip https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks-oltp-install-script.zip + - name: Restore AdventureWorksLT2022 backup + run: 7z x AdventureWorks-oltp-install-script.zip # run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" - run: | - /opt/mssql-tools18/bin/sqlcmd -? - /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/adventure-works/data-warehouse-install-script/instawdbdw.sql +# run: | +# /opt/mssql-tools18/bin/sqlcmd -? +# /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /sqlserver/setup/restore-ci.sql - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From e44a3942a3972fc4759ec273c133f56ebb1e35f6 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 18:58:03 +0200 Subject: [PATCH 60/92] update github ci workflow for sqlserver - sqlcmd curl and unzip AdventureWorks-oltp-install-script.zip --- .github/workflows/build-and-test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0b7d6c1..32d774c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -38,8 +38,6 @@ jobs: run: | pwd ls -la - cd /var/opt/mssql/backup/ - ls -la curl -L -o AdventureWorks-oltp-install-script.zip https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks-oltp-install-script.zip - name: Restore AdventureWorksLT2022 backup run: 7z x AdventureWorks-oltp-install-script.zip From 5a05a4078463e789a5d5f1d3bfa31b95bf1954ad Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 19:09:40 +0200 Subject: [PATCH 61/92] update github ci workflow for sqlserver - sqlcmd install db --- .github/workflows/build-and-test.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 32d774c..1970b80 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -34,17 +34,13 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - - name: Download AdventureWorksLT2022 backup + - name: Download AdventureWorks install script run: | - pwd - ls -la curl -L -o AdventureWorks-oltp-install-script.zip https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks-oltp-install-script.zip - - name: Restore AdventureWorksLT2022 backup - run: 7z x AdventureWorks-oltp-install-script.zip -# run: sqlcmd -S mssql+pyodbc://sa@localhost:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes -U SA -P ${{ env.SA_PASSWORD }} -Q "CREATE DATABASE AdventureWorksLT2022;" -# run: | -# /opt/mssql-tools18/bin/sqlcmd -? -# /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /sqlserver/setup/restore-ci.sql + - name: Unzip and Install AdventureWorks Database + run: | + 7z x AdventureWorks-oltp-install-script.zip + /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /AdventureWorks-oltp-install-script/instawdb.sql - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From d6098eefae4a98532b8487e6a2f950ece03894f0 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 19:12:41 +0200 Subject: [PATCH 62/92] update github ci workflow for sqlserver - sqlcmd install db --- .github/workflows/build-and-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1970b80..0af6eee 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -40,7 +40,9 @@ jobs: - name: Unzip and Install AdventureWorks Database run: | 7z x AdventureWorks-oltp-install-script.zip - /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /AdventureWorks-oltp-install-script/instawdb.sql + cd AdventureWorks-oltp-install-script/ + ls -al +# /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /AdventureWorks-oltp-install-script/instawdb.sql - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 17bc7c6fc3f4d8c6a2135e572512873b4f1d486c Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 19:16:14 +0200 Subject: [PATCH 63/92] update github ci workflow for sqlserver - sqlcmd install db --- .github/workflows/build-and-test.yml | 2 +- sqlserver/setup/restore-ci.sql | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 sqlserver/setup/restore-ci.sql diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0af6eee..1ba4542 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -39,7 +39,7 @@ jobs: curl -L -o AdventureWorks-oltp-install-script.zip https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks-oltp-install-script.zip - name: Unzip and Install AdventureWorks Database run: | - 7z x AdventureWorks-oltp-install-script.zip + 7z x AdventureWorks-oltp-install-script.zip -oAdventureWorks-oltp-install-script cd AdventureWorks-oltp-install-script/ ls -al # /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /AdventureWorks-oltp-install-script/instawdb.sql diff --git a/sqlserver/setup/restore-ci.sql b/sqlserver/setup/restore-ci.sql deleted file mode 100644 index 189e169..0000000 --- a/sqlserver/setup/restore-ci.sql +++ /dev/null @@ -1,13 +0,0 @@ -/* - -Restore a database from a backup file - -*/ -CREATE DATABASE AdventureWorksLT2022; -GO - -RESTORE DATABASE AdventureWorksLT2022 FROM DISK = 'AdventureWorksLT2022.bak' - WITH REPLACE, - MOVE 'AdventureWorksLT2022_Data' TO '/var/opt/mssql/data/AdventureWorksLT2022.mdf', - MOVE 'AdventureWorksLT2022_log' TO '/var/opt/mssql/data/AdventureWorksLT2022_log.ldf'; -GO From 33a9669c14f08e07762e820e8c4aa691e36a8b0f Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 2 Jul 2023 19:20:04 +0200 Subject: [PATCH 64/92] update github ci workflow for sqlserver - sqlcmd install db --- .github/workflows/build-and-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1ba4542..833af7f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -40,9 +40,7 @@ jobs: - name: Unzip and Install AdventureWorks Database run: | 7z x AdventureWorks-oltp-install-script.zip -oAdventureWorks-oltp-install-script - cd AdventureWorks-oltp-install-script/ - ls -al -# /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i /AdventureWorks-oltp-install-script/instawdb.sql + /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i AdventureWorks-oltp-install-script/instawdb.sql - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From b73fe23d1d03574e93096770f36691eb8f46824b Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 9 Jul 2023 14:00:59 +0200 Subject: [PATCH 65/92] update github ci workflow for sqlserver - align sa pass --- .env | 3 ++- .github/workflows/build-and-test.yml | 2 +- .secrets | 3 ++- app/main.py | 2 ++ docker-compose.yml | 26 +++----------------------- 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/.env b/.env index d341aea..9172f94 100644 --- a/.env +++ b/.env @@ -13,4 +13,5 @@ SQLALCHEMY_WARN_20=1 ACCEPT_EULA=Y MSSQL_DB=master MSSQL_HOST=sqlserver -MSSQL_USER=sa \ No newline at end of file +MSSQL_USER=sa +SA_PASSWORD=Alaska2023 \ No newline at end of file diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 833af7f..a194970 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -15,7 +15,7 @@ jobs: env: PYTHONDONTWRITEBYTECODE: 1 PYTHONUNBUFFERED: 1 - SA_PASSWORD: pass + SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y services: diff --git a/.secrets b/.secrets index 171582e..9b2ca35 100644 --- a/.secrets +++ b/.secrets @@ -1,2 +1,3 @@ POSTGRES_PASSWORD=secret -MSSQL_SA_PASSWORD=pass \ No newline at end of file +MSSQL_SA_PASSWORD=Alaska2023 +SA_PASSWORD=Alaska2023 \ No newline at end of file diff --git a/app/main.py b/app/main.py index 19ee4ab..411e706 100644 --- a/app/main.py +++ b/app/main.py @@ -20,6 +20,8 @@ @app.on_event("startup") def startup_event(): + logger.info("Starting up...") + logger.info(f"Connecting to database...{settings.sqlserver_url.__str__()}") app.state.gx = GxSession( settings.sqlserver_url.__str__(), settings.sql_datasource_name, diff --git a/docker-compose.yml b/docker-compose.yml index 4ae6adc..ebf30b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,32 +37,12 @@ services: env_file: - .env - .secrets + environment: + - SA_PASSWORD=Alaska2023 + - ACCEPT_EULA=Y ports: - 1433:1433 -# db: -# build: -# context: ./db -# dockerfile: Dockerfile -# volumes: -# - postgres_data:/var/lib/postgresql/data -# env_file: -# - .env -# - .secrets -# ports: -# - 5432:5432 -# environment: -# - POSTGRES_USER=${SQL_USER} -# healthcheck: -# test: -# [ -# "CMD-SHELL", "pg_isready -d $SQL_DB -U $SQL_USER" -# ] -# interval: 5s -# timeout: 5s -# retries: 5 - volumes: -# postgres_data: sqlserver_data: From 9bc64cd7ffba56f4574b846e0ca73e84b7a0fd77 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 9 Jul 2023 14:08:30 +0200 Subject: [PATCH 66/92] update github ci workflow for sqlserver - align sa pass --- .github/workflows/build-and-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a194970..ee13152 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -17,6 +17,11 @@ jobs: PYTHONUNBUFFERED: 1 SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y + MSSQL_DB: master + MSSQL_HOST: localhost + MSSQL_USER: sa + MSSQL_SA_PASSWORD: Alaska2023 + SQL_DATASOURCE_NAME: my_gxshakezz services: mssql: From be704786cf53a509029a7f3e5a5886a9dd213e44 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 9 Jul 2023 19:02:35 +0200 Subject: [PATCH 67/92] test passing but still wip :) --- .env | 2 +- Makefile | 6 +- app/config.py | 2 +- docker-compose.yml | 3 +- tests/api/test_database.py | 67 ++++++++++++++----- ...pectations.py => wip_test_expectations.py} | 28 ++++---- 6 files changed, 75 insertions(+), 33 deletions(-) rename tests/api/{test_expectations.py => wip_test_expectations.py} (90%) diff --git a/.env b/.env index 9172f94..47deb13 100644 --- a/.env +++ b/.env @@ -11,7 +11,7 @@ POSTGRES_PASSWORD=secret SQLALCHEMY_WARN_20=1 ACCEPT_EULA=Y -MSSQL_DB=master +MSSQL_DB=AdventureWorks MSSQL_HOST=sqlserver MSSQL_USER=sa SA_PASSWORD=Alaska2023 \ No newline at end of file diff --git a/Makefile b/Makefile index afd39ae..974176b 100644 --- a/Makefile +++ b/Makefile @@ -54,8 +54,12 @@ coverage: ## Run project tests with coverage .PHONY: verify_db_backup verify_db_backup: ## Verify database backup file names before restore on running sqlserver container - docker-compose exec sqlserver bash -c "cd /opt/mssql-tools/bin && ./sqlcmd -S localhost -U sa -P 'yourStrong(!)Password' -d master -i /home/setup/verify.sql" + docker-compose exec sqlserver bash -c "cd /opt/mssql-tools18/bin && ./sqlcmd -S localhost -U sa -P 'yourStrong(!)Password' -d master -i /home/setup/verify.sql" .PHONY: restore_db_backup restore_db_backup: ## Restore database backup on running sqlserver container docker-compose exec sqlserver bash -c "cd /opt/mssql-tools/bin && ./sqlcmd -S localhost -U sa -P 'yourStrong(!)Password' -d master -i /home/setup/restore.sql" + +.PHONY: build_database +build_database: ## Build database on running sqlserver container + docker-compose exec app bash -c "/opt/mssql-tools18/bin/sqlcmd -S sqlserver -U SA -P 'Alaska2023' -C -i /home/code/setup/instawdb.sql" \ No newline at end of file diff --git a/app/config.py b/app/config.py index fccc6b8..93b2d71 100644 --- a/app/config.py +++ b/app/config.py @@ -21,7 +21,7 @@ class Settings(BaseSettings): host=os.getenv("MSSQL_HOST"), port="1433", path=f"/{os.getenv('MSSQL_DB') or ''}", - query="driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes" + query="driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes", ) sql_datasource_name: str = os.getenv("SQL_DATASOURCE_NAME", "default") diff --git a/docker-compose.yml b/docker-compose.yml index ebf30b5..314f281 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: - ./app:/home/code/app - ./tests:/home/code/tests - ./logger.ini:/home/code/logger.ini + - ./sqlserver/setup:/home/code/setup ports: - 8585:8080 depends_on: @@ -33,7 +34,7 @@ services: - ./sqlserver/restore:/var/opt/mssql/restore - ./sqlserver/data:/var/opt/mssql/data - ./sqlserver/log:/var/opt/mssql/log - - ./sqlserver/setup:/home/setup + env_file: - .env - .secrets diff --git a/tests/api/test_database.py b/tests/api/test_database.py index 9e5fc54..fbd421f 100644 --- a/tests/api/test_database.py +++ b/tests/api/test_database.py @@ -7,7 +7,26 @@ "response_data, status_code", ( ( - ["information_schema", "public", "shakespeare"], + [ + "db_accessadmin", + "db_backupoperator", + "db_datareader", + "db_datawriter", + "db_ddladmin", + "db_denydatareader", + "db_denydatawriter", + "db_owner", + "db_securityadmin", + "dbo", + "guest", + "HumanResources", + "INFORMATION_SCHEMA", + "Person", + "Production", + "Purchasing", + "Sales", + "sys" + ], status.HTTP_200_OK, ), ), @@ -22,27 +41,41 @@ def test_get_schemas(client: TestClient, response_data: dict, status_code: int): "response_data, status_code", ( ( - ["paragraph", "wordform", "character", "character_work", "work", "chapter"], + [ + "Address", + "AddressType", + "BusinessEntity", + "BusinessEntityAddress", + "BusinessEntityContact", + "ContactType", + "CountryRegion", + "EmailAddress", + "Password", + "Person", + "PersonPhone", + "PhoneNumberType", + "StateProvince" + ], status.HTTP_200_OK, ), ), ) def test_get_tables(client: TestClient, response_data: dict, status_code: int): - response = client.get("/v1/database/tables?sql_db_schema=shakespeare") + response = client.get("/v1/database/tables?sql_db_schema=Person") assert response.status_code == status_code assert sorted(response.json()) == sorted(response_data) - -@pytest.mark.parametrize( - "response_data, status_code", - ( - ( - ["id", "work_id", "section_number", "chapter_number", "description"], - status.HTTP_200_OK, - ), - ), -) -def test_get_columns(client: TestClient, response_data: dict, status_code: int): - response = client.get("/v1/database/columns/chapter") - assert response.status_code == status_code - assert response.json() == response_data +# TODO: fix this test +# @pytest.mark.parametrize( +# "response_data, status_code", +# ( +# ( +# ["id", "work_id", "section_number", "chapter_number", "description"], +# status.HTTP_200_OK, +# ), +# ), +# ) +# def test_get_columns(client: TestClient, response_data: dict, status_code: int): +# response = client.get("/v1/database/columns/chapter") +# assert response.status_code == status_code +# assert response.json() == response_data diff --git a/tests/api/test_expectations.py b/tests/api/wip_test_expectations.py similarity index 90% rename from tests/api/test_expectations.py rename to tests/api/wip_test_expectations.py index a8af1c7..d186190 100644 --- a/tests/api/test_expectations.py +++ b/tests/api/wip_test_expectations.py @@ -16,7 +16,6 @@ "expect_column_mean_to_be_between", "expect_column_median_to_be_between", "expect_column_min_to_be_between", - "expect_column_most_common_value_to_be_in_set", "expect_column_pair_values_a_to_be_greater_than_b", "expect_column_pair_values_to_be_equal", @@ -120,23 +119,28 @@ def test_get_expectation_types( # status.HTTP_200_OK, # ), ( - "expect_column_most_common_value_to_be_in_set", - status.HTTP_200_OK, - {"column": "section_number", "value_set": [5]}, - False, - {'observed_value': [1]}, + "expect_column_most_common_value_to_be_in_set", + status.HTTP_200_OK, + {"column": "section_number", "value_set": [5]}, + False, + {"observed_value": [1]}, ), ( - "expect_column_most_common_value_to_be_in_set", - status.HTTP_200_OK, - {"column": "section_number", "value_set": [1]}, - True, - {'observed_value': [1]}, + "expect_column_most_common_value_to_be_in_set", + status.HTTP_200_OK, + {"column": "section_number", "value_set": [1]}, + True, + {"observed_value": [1]}, ), ), ) def test_try_expectation_types( - client: TestClient, expectation_type: str, status_code: int, payload: dict, gx_success: bool, gx_result: dict + client: TestClient, + expectation_type: str, + status_code: int, + payload: dict, + gx_success: bool, + gx_result: dict, ): response = client.post( f"/v1/expectation/try_expectation/chapter/{expectation_type}", json=payload From 415a8586c9730d7ccc0f26a6dcc5e6ce536f6d28 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 9 Jul 2023 19:34:05 +0200 Subject: [PATCH 68/92] wip try restore backup on container service --- .github/workflows/build-and-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ee13152..e3d5b31 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -26,6 +26,8 @@ jobs: services: mssql: image: mcr.microsoft.com/mssql/server:2022-latest + container_name: mssql + command: bash -c "while ! /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'; do sleep 1; done;" env: SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y From 2323aa3cedc7c904f370233d1d147320730a6869 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Tue, 11 Jul 2023 13:04:35 +0200 Subject: [PATCH 69/92] wip on db backup restore with volumes --- .github/workflows/build-and-test.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e3d5b31..9377a26 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -26,8 +26,6 @@ jobs: services: mssql: image: mcr.microsoft.com/mssql/server:2022-latest - container_name: mssql - command: bash -c "while ! /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'; do sleep 1; done;" env: SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y @@ -44,10 +42,11 @@ jobs: - name: Download AdventureWorks install script run: | curl -L -o AdventureWorks-oltp-install-script.zip https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks-oltp-install-script.zip - - name: Unzip and Install AdventureWorks Database + - name: ls and pwd run: | - 7z x AdventureWorks-oltp-install-script.zip -oAdventureWorks-oltp-install-script - /opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -C -i AdventureWorks-oltp-install-script/instawdb.sql + ls -la + pwd + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From d1c415f935e50d118a9627dcbb2ce2c474c46ca2 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Tue, 11 Jul 2023 13:08:41 +0200 Subject: [PATCH 70/92] wip on db backup restore with volumes --- .github/workflows/build-and-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9377a26..bd2ba23 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -26,6 +26,8 @@ jobs: services: mssql: image: mcr.microsoft.com/mssql/server:2022-latest + volumes: + - ./sqlserver/setup:/var/opt/mssql/backup env: SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y From c625a6e9195d0ca8d4b3cf15da3b6b004dad0084 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Tue, 11 Jul 2023 13:14:05 +0200 Subject: [PATCH 71/92] wip on db backup restore with volumes --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index bd2ba23..14e464e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -27,7 +27,7 @@ jobs: mssql: image: mcr.microsoft.com/mssql/server:2022-latest volumes: - - ./sqlserver/setup:/var/opt/mssql/backup + - /sqlserver/setup:/var/opt/mssql/backup env: SA_PASSWORD: YourStrong!Passw0rd ACCEPT_EULA: Y From 83efb840e1eac4d35f099051c74ee2d5e105afad Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:26:21 +0200 Subject: [PATCH 72/92] testing bak on service volume --- .github/workflows/build-and-test.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 14e464e..10fd41d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -41,14 +41,12 @@ jobs: - uses: actions/checkout@v3 - name: Install SQL Server Tools run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - - name: Download AdventureWorks install script + - name: Download AdventureWorksLT2022 backup run: | - curl -L -o AdventureWorks-oltp-install-script.zip https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks-oltp-install-script.zip - - name: ls and pwd - run: | - ls -la + curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak + cp AdventureWorksLT2022.bak /sqlserver/setup/AdventureWorksLT2022.bak pwd - + ls /sqlserver/setup - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 8bb64fbee2f5401325f0411aa85ccb2fa8d7f682 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:32:00 +0200 Subject: [PATCH 73/92] testing bak on service volume --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 10fd41d..32b528d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -44,7 +44,7 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - cp AdventureWorksLT2022.bak /sqlserver/setup/AdventureWorksLT2022.bak +# cp AdventureWorksLT2022.bak /sqlserver/setup/AdventureWorksLT2022.bak pwd ls /sqlserver/setup - uses: actions/setup-python@v4 From dedfc63035816159ee9735ba242b7728fa731341 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:34:47 +0200 Subject: [PATCH 74/92] testing bak on service volume --- .github/workflows/build-and-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 32b528d..390f659 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -44,7 +44,6 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak -# cp AdventureWorksLT2022.bak /sqlserver/setup/AdventureWorksLT2022.bak pwd ls /sqlserver/setup - uses: actions/setup-python@v4 From 50d53d217fb8fac55fdbf9a91e434a90a6b52504 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:37:35 +0200 Subject: [PATCH 75/92] testing bak on service volume --- .github/workflows/build-and-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 390f659..5143422 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -44,6 +44,8 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak + cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak + ls pwd ls /sqlserver/setup - uses: actions/setup-python@v4 From 2019f5380117b0770fc4d636ad8865c877fb8cde Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:41:46 +0200 Subject: [PATCH 76/92] testing bak on service volume --- .github/workflows/build-and-test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 5143422..b15e5f6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,9 +45,8 @@ jobs: run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak - ls - pwd - ls /sqlserver/setup + cd /sqlserver/setup + ls -al - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From cefde0e9faffef99d916e46cb6b99a38bed7fca8 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:45:38 +0200 Subject: [PATCH 77/92] testing bak on service volume --- .github/workflows/build-and-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b15e5f6..d3cc538 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -47,6 +47,7 @@ jobs: cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak cd /sqlserver/setup ls -al + pwd - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 6b58ea90194448b9cb451fc44d921c2f1c01f511 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:48:21 +0200 Subject: [PATCH 78/92] testing bak on service volume --- .github/workflows/build-and-test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d3cc538..1004ac9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -44,8 +44,11 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak + pwd cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak - cd /sqlserver/setup + ls -al + + cd sqlserver/setup ls -al pwd - uses: actions/setup-python@v4 From 9ac34326b22ea44f10ec8ed4683ce15d2f70258f Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sun, 16 Jul 2023 21:51:38 +0200 Subject: [PATCH 79/92] testing bak on service volume - copy to value ok --- .github/workflows/build-and-test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1004ac9..14f40a1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -44,13 +44,7 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - pwd cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak - ls -al - - cd sqlserver/setup - ls -al - pwd - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From c99f057f4dd0ae47445178503eef1ab55d3e81e8 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 12:36:38 +0200 Subject: [PATCH 80/92] M1 fix --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 314f281..0936abe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: app: build: . + platform: linux/amd64 env_file: - .env - .secrets @@ -28,6 +29,7 @@ services: build: context: ./sqlserver dockerfile: Dockerfile + platform: linux/amd64 volumes: - sqlserver_data:/var/opt/mssql - ./sqlserver/backup:/var/opt/mssql/backup From 80f6f55263a182680b8ad68206f0e1ba65b53812 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 15:47:03 +0200 Subject: [PATCH 81/92] M1 fix --- .env | 2 +- Makefile | 8 ++--- docker-compose.yml | 2 ++ sqlserver/setup/restore.sql | 2 +- tests/api/test_database.py | 66 +++++++++++++++++-------------------- 5 files changed, 36 insertions(+), 44 deletions(-) diff --git a/.env b/.env index 47deb13..0812813 100644 --- a/.env +++ b/.env @@ -11,7 +11,7 @@ POSTGRES_PASSWORD=secret SQLALCHEMY_WARN_20=1 ACCEPT_EULA=Y -MSSQL_DB=AdventureWorks +MSSQL_DB=AdventureWorksLT2022 MSSQL_HOST=sqlserver MSSQL_USER=sa SA_PASSWORD=Alaska2023 \ No newline at end of file diff --git a/Makefile b/Makefile index 974176b..b8429c6 100644 --- a/Makefile +++ b/Makefile @@ -54,12 +54,8 @@ coverage: ## Run project tests with coverage .PHONY: verify_db_backup verify_db_backup: ## Verify database backup file names before restore on running sqlserver container - docker-compose exec sqlserver bash -c "cd /opt/mssql-tools18/bin && ./sqlcmd -S localhost -U sa -P 'yourStrong(!)Password' -d master -i /home/setup/verify.sql" + docker-compose exec sqlserver bash -c "cd /opt/mssql-tools/bin && ./sqlcmd -S localhost -U sa -P 'Alaska2023' -d master -i /home/setup/verify.sql" .PHONY: restore_db_backup restore_db_backup: ## Restore database backup on running sqlserver container - docker-compose exec sqlserver bash -c "cd /opt/mssql-tools/bin && ./sqlcmd -S localhost -U sa -P 'yourStrong(!)Password' -d master -i /home/setup/restore.sql" - -.PHONY: build_database -build_database: ## Build database on running sqlserver container - docker-compose exec app bash -c "/opt/mssql-tools18/bin/sqlcmd -S sqlserver -U SA -P 'Alaska2023' -C -i /home/code/setup/instawdb.sql" \ No newline at end of file + docker-compose exec sqlserver bash -c "cd /opt/mssql-tools/bin && ./sqlcmd -S localhost -U sa -P 'Alaska2023' -d master -i /home/setup/restore.sql" diff --git a/docker-compose.yml b/docker-compose.yml index 0936abe..33113ce 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,6 +36,7 @@ services: - ./sqlserver/restore:/var/opt/mssql/restore - ./sqlserver/data:/var/opt/mssql/data - ./sqlserver/log:/var/opt/mssql/log + - ./sqlserver/setup:/home/setup env_file: - .env @@ -43,6 +44,7 @@ services: environment: - SA_PASSWORD=Alaska2023 - ACCEPT_EULA=Y + - MSSQL_PID=Developer ports: - 1433:1433 diff --git a/sqlserver/setup/restore.sql b/sqlserver/setup/restore.sql index 16fdfb0..d9f6235 100644 --- a/sqlserver/setup/restore.sql +++ b/sqlserver/setup/restore.sql @@ -6,7 +6,7 @@ Restore a database from a backup file CREATE DATABASE AdventureWorksLT2022; GO -RESTORE DATABASE AdventureWorksLT2022 FROM DISK = '/var/opt/mssql/backup/AdventureWorksLT2022.bak' +RESTORE DATABASE AdventureWorksLT2022 FROM DISK = '/var/opt/mssql/restore/AdventureWorksLT2022.bak' WITH REPLACE, MOVE 'AdventureWorksLT2022_Data' TO '/var/opt/mssql/data/AdventureWorksLT2022.mdf', MOVE 'AdventureWorksLT2022_log' TO '/var/opt/mssql/data/AdventureWorksLT2022_log.ldf'; diff --git a/tests/api/test_database.py b/tests/api/test_database.py index fbd421f..6ccfcfe 100644 --- a/tests/api/test_database.py +++ b/tests/api/test_database.py @@ -7,26 +7,22 @@ "response_data, status_code", ( ( - [ - "db_accessadmin", - "db_backupoperator", - "db_datareader", - "db_datawriter", - "db_ddladmin", - "db_denydatareader", - "db_denydatawriter", - "db_owner", - "db_securityadmin", - "dbo", - "guest", - "HumanResources", - "INFORMATION_SCHEMA", - "Person", - "Production", - "Purchasing", - "Sales", - "sys" - ], + [ + "db_accessadmin", + "db_backupoperator", + "db_datareader", + "db_datawriter", + "db_ddladmin", + "db_denydatareader", + "db_denydatawriter", + "db_owner", + "db_securityadmin", + "dbo", + "guest", + "INFORMATION_SCHEMA", + "SalesLT", + "sys", + ], status.HTTP_200_OK, ), ), @@ -41,30 +37,28 @@ def test_get_schemas(client: TestClient, response_data: dict, status_code: int): "response_data, status_code", ( ( - [ - "Address", - "AddressType", - "BusinessEntity", - "BusinessEntityAddress", - "BusinessEntityContact", - "ContactType", - "CountryRegion", - "EmailAddress", - "Password", - "Person", - "PersonPhone", - "PhoneNumberType", - "StateProvince" - ], + [ + "Address", + "Customer", + "CustomerAddress", + "Product", + "ProductCategory", + "ProductDescription", + "ProductModel", + "ProductModelProductDescription", + "SalesOrderDetail", + "SalesOrderHeader", + ], status.HTTP_200_OK, ), ), ) def test_get_tables(client: TestClient, response_data: dict, status_code: int): - response = client.get("/v1/database/tables?sql_db_schema=Person") + response = client.get("/v1/database/tables?sql_db_schema=SalesLT") assert response.status_code == status_code assert sorted(response.json()) == sorted(response_data) + # TODO: fix this test # @pytest.mark.parametrize( # "response_data, status_code", From 8ca9634d2169aa69d5eda41eb907f640ffa807cb Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 15:48:39 +0200 Subject: [PATCH 82/92] align sa passwords in CI --- .github/workflows/build-and-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 14f40a1..ad3fdab 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -15,7 +15,7 @@ jobs: env: PYTHONDONTWRITEBYTECODE: 1 PYTHONUNBUFFERED: 1 - SA_PASSWORD: YourStrong!Passw0rd + SA_PASSWORD: Alaska2023 ACCEPT_EULA: Y MSSQL_DB: master MSSQL_HOST: localhost @@ -29,12 +29,12 @@ jobs: volumes: - /sqlserver/setup:/var/opt/mssql/backup env: - SA_PASSWORD: YourStrong!Passw0rd + SA_PASSWORD: Alaska2023 ACCEPT_EULA: Y MSSQL_PID: Developer ports: - 1433:1433 - options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 + options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Alaska2023' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 steps: From 07813f4f791df239f67c9973d5013cd8a907b5d2 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 15:55:41 +0200 Subject: [PATCH 83/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ad3fdab..06e32bc 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,6 +45,9 @@ jobs: run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak + - name: Restore AdventureWorksLT2022 backup + run: | + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Alaska2023' -d master -i ./sqlserver/setup/restore.sql - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 2ea088e0c456bd077fbf75d215e5bdef5df3f95b Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 15:58:26 +0200 Subject: [PATCH 84/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 06e32bc..af22c9d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -27,7 +27,7 @@ jobs: mssql: image: mcr.microsoft.com/mssql/server:2022-latest volumes: - - /sqlserver/setup:/var/opt/mssql/backup + - /sqlserver/setup:/var/opt/mssql/restore env: SA_PASSWORD: Alaska2023 ACCEPT_EULA: Y From 004b7c92c6813d5b136ed4672aa516baecf89d05 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:05:05 +0200 Subject: [PATCH 85/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index af22c9d..ce2051c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -28,6 +28,7 @@ jobs: image: mcr.microsoft.com/mssql/server:2022-latest volumes: - /sqlserver/setup:/var/opt/mssql/restore + env: SA_PASSWORD: Alaska2023 ACCEPT_EULA: Y @@ -45,6 +46,8 @@ jobs: run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak + cd ./sqlserver/setup + ls -la - name: Restore AdventureWorksLT2022 backup run: | /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Alaska2023' -d master -i ./sqlserver/setup/restore.sql From d1a468cd5222a48f1f9505dc4a144a7e2eb2b51b Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:05:51 +0200 Subject: [PATCH 86/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ce2051c..6208155 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -27,7 +27,7 @@ jobs: mssql: image: mcr.microsoft.com/mssql/server:2022-latest volumes: - - /sqlserver/setup:/var/opt/mssql/restore + - ./sqlserver/setup:/var/opt/mssql/restore env: SA_PASSWORD: Alaska2023 From 472b8dc3c3c59b42df1735e48e8d8ef81cb38208 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:09:26 +0200 Subject: [PATCH 87/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6208155..45ea869 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -39,7 +39,7 @@ jobs: steps: - - uses: actions/checkout@v3 +# - uses: actions/checkout@v3 - name: Install SQL Server Tools run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 - name: Download AdventureWorksLT2022 backup @@ -50,18 +50,18 @@ jobs: ls -la - name: Restore AdventureWorksLT2022 backup run: | - /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Alaska2023' -d master -i ./sqlserver/setup/restore.sql - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install Poetry - uses: abatilo/actions-poetry@v2 - with: - poetry-version: ${{ matrix.poetry-version }} - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - - name: Test Code Coverage - run: poetry run coverage run -m pytest -v --cov=app --cov-report=xml - - name: Coveralls - uses: coverallsapp/github-action@v2 + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Alaska2023' -d master -Q 'RESTORE DATABASE AdventureWorksLT2022 FROM DISK = "/var/opt/mssql/restore/AdventureWorksLT2022.bak" WITH MOVE "AdventureWorksLT2022" TO "/var/opt/mssql/data/AdventureWorksLT2022.mdf", MOVE "AdventureWorksLT2022_log" TO "/var/opt/mssql/data/AdventureWorksLT2022_log.ldf"' +# - uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Install Poetry +# uses: abatilo/actions-poetry@v2 +# with: +# poetry-version: ${{ matrix.poetry-version }} +# - name: Install dependencies +# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' +# run: poetry install --no-interaction --no-root +# - name: Test Code Coverage +# run: poetry run coverage run -m pytest -v --cov=app --cov-report=xml +# - name: Coveralls +# uses: coverallsapp/github-action@v2 From 24a49adba52ded7d46fa5fada60317499b31c5bf Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:14:01 +0200 Subject: [PATCH 88/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 45ea869..ac2f54d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,8 +45,7 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - cp AdventureWorksLT2022.bak ./sqlserver/setup/AdventureWorksLT2022.bak - cd ./sqlserver/setup + pwd ls -la - name: Restore AdventureWorksLT2022 backup run: | From a0e2611b684e76f10a2a27244d11abcefad5914d Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:18:25 +0200 Subject: [PATCH 89/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ac2f54d..e218ef5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -27,7 +27,7 @@ jobs: mssql: image: mcr.microsoft.com/mssql/server:2022-latest volumes: - - ./sqlserver/setup:/var/opt/mssql/restore + - ./adventure_works:/var/opt/mssql/restore env: SA_PASSWORD: Alaska2023 @@ -46,6 +46,8 @@ jobs: run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak pwd + cd adventure_works + pwd ls -la - name: Restore AdventureWorksLT2022 backup run: | From de13d40aaf782a186c28609b37279f75a57621ef Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:20:55 +0200 Subject: [PATCH 90/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e218ef5..6fb93fd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,7 +45,7 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - pwd + cp AdventureWorksLT2022.bak adventure_works/ cd adventure_works pwd ls -la From dd8a9b4da28c625400d09e70c36743906632b6df Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:23:27 +0200 Subject: [PATCH 91/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6fb93fd..4ec8265 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,7 +45,7 @@ jobs: - name: Download AdventureWorksLT2022 backup run: | curl -L -o AdventureWorksLT2022.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksLT2022.bak - cp AdventureWorksLT2022.bak adventure_works/ + sudo cp AdventureWorksLT2022.bak adventure_works/ cd adventure_works pwd ls -la From c7da577d04885bdf370e501e5421154692511119 Mon Sep 17 00:00:00 2001 From: Jakub Miazek Date: Sat, 12 Aug 2023 16:54:54 +0200 Subject: [PATCH 92/92] restore db from backup on CI --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4ec8265..b1e3175 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -51,7 +51,7 @@ jobs: ls -la - name: Restore AdventureWorksLT2022 backup run: | - /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Alaska2023' -d master -Q 'RESTORE DATABASE AdventureWorksLT2022 FROM DISK = "/var/opt/mssql/restore/AdventureWorksLT2022.bak" WITH MOVE "AdventureWorksLT2022" TO "/var/opt/mssql/data/AdventureWorksLT2022.mdf", MOVE "AdventureWorksLT2022_log" TO "/var/opt/mssql/data/AdventureWorksLT2022_log.ldf"' + /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Alaska2023' -d master -Q 'RESTORE DATABASE AdventureWorksLT2022 FROM DISK = "/var/opt/mssql/restore/AdventureWorksLT2022.bak" WITH MOVE "AdventureWorksLT2022_Data" TO "/var/opt/mssql/data/AdventureWorksLT2022.mdf", MOVE "AdventureWorksLT2022_log" TO "/var/opt/mssql/data/AdventureWorksLT2022_log.ldf"' # - uses: actions/setup-python@v4 # with: # python-version: ${{ matrix.python-version }}