diff --git a/.github/workflows/advanced.yml b/.github/workflows/advanced.yml index 80ab73d..a9fa87f 100644 --- a/.github/workflows/advanced.yml +++ b/.github/workflows/advanced.yml @@ -10,17 +10,19 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macOS-latest] + version: ["2019", "2022"] steps: - uses: actions/checkout@v3 - - name: Install sqlengine + - name: Install sqlengine with full-text search uses: ./ with: - install: sqlengine + install: sqlengine,fulltext sa-password: c0MplicatedP@ssword show-log: true collation: Latin1_General_BIN + version: ${{ matrix.version }} - name: Install sqlclient uses: ./ @@ -48,3 +50,7 @@ jobs: run: | ./Test-Collation -ExpectedCollation Latin1_General_BIN -UserName sa -Password c0MplicatedP@ssword + - name: Check full-text search enabled + shell: pwsh + run: | + ./Test-FullTextSearch -UserName sa -Password c0MplicatedP@ssword -ExpectedStatus Running diff --git a/.github/workflows/simple.yml b/.github/workflows/simple.yml index 0b4904d..12f532a 100644 --- a/.github/workflows/simple.yml +++ b/.github/workflows/simple.yml @@ -26,3 +26,8 @@ jobs: shell: pwsh run: | ./Test-Collation -ExpectedCollation SQL_Latin1_General_CP1_CI_AS -UserName sa -Password dbatools.I0 + + - name: Check full-text search disabled + shell: pwsh + run: | + ./Test-FullTextSearch -UserName sa -Password c0MplicatedP@ssword -ExpectedStatus NotRunning diff --git a/Dockerfile-2019 b/Dockerfile-2019 new file mode 100644 index 0000000..c13f71d --- /dev/null +++ b/Dockerfile-2019 @@ -0,0 +1,17 @@ +FROM mcr.microsoft.com/mssql/server:2019-latest + +USER root + +RUN apt-get update && \ + apt-get install -yq gnupg gnupg2 gnupg1 curl apt-transport-https && \ + curl https://packages.microsoft.com/keys/microsoft.asc -o /var/opt/mssql/ms-key.cer && \ + apt-key add /var/opt/mssql/ms-key.cer && \ + curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list -o /etc/apt/sources.list.d/mssql-server-2019.list && \ + apt-get update && \ + apt-get install -y mssql-server-fts && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists + +EXPOSE 1433 +USER mssql +ENTRYPOINT [ "/opt/mssql/bin/sqlservr" ] diff --git a/Dockerfile-2022 b/Dockerfile-2022 new file mode 100644 index 0000000..c0c8bf1 --- /dev/null +++ b/Dockerfile-2022 @@ -0,0 +1,17 @@ +FROM mcr.microsoft.com/mssql/server:2022-latest + +USER root + +RUN apt-get update && \ + apt-get install -yq gnupg gnupg2 gnupg1 curl apt-transport-https && \ + curl https://packages.microsoft.com/keys/microsoft.asc -o /var/opt/mssql/ms-key.cer && \ + apt-key add /var/opt/mssql/ms-key.cer && \ + curl https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list -o /etc/apt/sources.list.d/mssql-server-2022.list && \ + apt-get update && \ + apt-get install -y mssql-server-fts && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists + +EXPOSE 1433 +USER mssql +ENTRYPOINT [ "/opt/mssql/bin/sqlservr" ] diff --git a/README.md b/README.md index 4d0f13c..601481b 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ This GitHub Action automatically installs a SQL Server suite of tools including ## Documentation -Just copy the code below and modify the line **`install: sqlengine, sqlclient, sqlpackage, localdb`** with the options you need. +Just copy the code below and modify the line **`install: sqlengine, sqlclient, sqlpackage, localdb, fulltext`** with the options you need. ```yaml - name: Install a SQL Server suite of tools uses: potatoqualitee/mssqlsuite@v1.7 with: - install: sqlengine, sqlclient, sqlpackage, localdb + install: sqlengine, sqlclient, sqlpackage, localdb, fulltext ``` ## Usage @@ -20,7 +20,7 @@ Create a workflow `.yml` file in your repositories `.github/workflows` directory ### Inputs -* `install` - The apps to install. Options include: `sqlengine`, `sqlclient`, `sqlpackage`, and `localdb` +* `install` - The apps to install. Options include: `sqlengine`, `sqlclient`, `sqlpackage`, `localdb`, and `fulltext` * `sa-password` - The sa password for the SQL instance. The default is `dbatools.I0` * `collation` - Change the collation associated with the SQL Server instance * `version` - The version of SQL Server to install in year format. Options are 2019 and 2022 (defaults to 2022) @@ -38,14 +38,17 @@ None | SqlLocalDB | localdb | Linux | Not supported | N/A | | Client Tools | sqlclient | Linux | Includes sqlcmd, bcp, and odbc drivers | ~15s | | sqlpackage | sqlpackage | Linux | Installed from web | ~5s | +| Full-Text Search | fulltext | Linux | Installed using apt-get | ~45s | | SQL Engine | sqlengine | Windows | Full install of SQL Server 2022, accessible at `localhost`. Docker took like 15 minutes. Windows and SQL authentication both supported. | ~3m | | SqlLocalDB | localdb | Windows | Accessible at `(localdb)\MSSQLLocalDB` | ~30s | | Client Tools | sqlclient | Windows | Already included in runner, including sqlcmd, bcp, and odbc drivers | N/A | | sqlpackage | sqlpackage | Windows | Installed using chocolatey | ~20s | +| Full-Text Search | fulltext | Windows | Enabled during SQL Engine install | ~1m | | SQL Engine | sqlengine | macOS | Docker container with SQL Server 2022 accessible at `localhost`. | ~7m | | SqlLocalDB | localdb | macOS | Not supported | N/A | | Client Tools | sqlclient | macOS | Includes sqlcmd, bcp, and odbc drivers | ~20s | | sqlpackage | sqlpackage | macOS | Installed from web | ~5s | +| Full-Text Search | fulltext | macOS | Installed using apt-get | ~5m | ### Example workflows @@ -91,7 +94,7 @@ jobs: - name: Run the action uses: potatoqualitee/mssqlsuite@v1.7 with: - install: sqlengine, sqlclient, sqlpackage, localdb + install: sqlengine, sqlclient, sqlpackage, localdb, fulltext version: 2019 sa-password: c0MplicatedP@ssword show-log: true diff --git a/Test-FullTextSearch.ps1 b/Test-FullTextSearch.ps1 new file mode 100644 index 0000000..4eafe30 --- /dev/null +++ b/Test-FullTextSearch.ps1 @@ -0,0 +1,29 @@ +param( + [Parameter(Mandatory=$true)] + [string]$ExpectedStatus, + [Parameter(Mandatory=$true)] + [string]$UserName, + [Parameter(Mandatory=$true)] + [string]$Password +) + +$Status = sqlcmd -S localhost -U $UserName -P $Password -Q "SELECT servicename, status_desc FROM sys.dm_server_services WHERE servicename LIKE 'SQL Full-text Filter Daemon Launcher%';" -C | Select-String -Pattern "Running" -Quiet + +if ($ExpectedStatus -eq "Running"){ + if ($Status){ + "Full-Text Search is installed and running." + } + else{ + throw "Full-Text Search is not running or not installed." + } +} +else{ + if ($Status){ + throw "Full-Text Search is running but it should not be." + } + else{ + "Full-Text Search is not running." + } +} + +exit 0 diff --git a/main.ps1 b/main.ps1 index 30b38c6..5a79ea2 100644 --- a/main.ps1 +++ b/main.ps1 @@ -1,5 +1,5 @@ param ( - [ValidateSet("sqlclient", "sqlpackage", "sqlengine", "localdb")] + [ValidateSet("sqlclient", "sqlpackage", "sqlengine", "localdb", "fulltext")] [string[]]$Install, [string]$SaPassword = "dbatools.I0", [switch]$ShowLog, @@ -20,7 +20,14 @@ if ("sqlengine" -in $Install) { if ($ismacos -or $islinux) { Write-Output "linux/mac detected, downloading the docker container" - docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=$SaPassword" -e "MSSQL_COLLATION=$Collation" --name sql -p 1433:1433 -d "mcr.microsoft.com/mssql/server:$Version-latest" + if ("fulltext" -in $Install) { + docker build -f Dockerfile-$Version -t mssql-fulltext . + $img = "mssql-fulltext" + } else { + $img = "mcr.microsoft.com/mssql/server:$Version-latest" + } + + docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=$SaPassword" -e "MSSQL_COLLATION=$Collation" --name sql -p 1433:1433 -d $img Write-Output "Waiting for docker to start" # MacOS takes longer to start using qemu @@ -62,7 +69,9 @@ if ("sqlengine" -in $Install) { Invoke-WebRequest -Uri $boxUri -OutFile sqlsetup.box Start-Process -Wait -FilePath ./sqlsetup.exe -ArgumentList /qs, /x:setup - .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT SERVICE\MSSQLSERVER' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS /SQLCOLLATION=$Collation /USESQLRECOMMENDEDMEMORYLIMITS + $features = if ("fulltext" -in $Install) { "SQLEngine,FullText" } else { "SQLEngine" } + + .\setup\setup.exe /q /ACTION=Install /INSTANCENAME=MSSQLSERVER /FEATURES=$features /UPDATEENABLED=0 /SQLSVCACCOUNT='NT SERVICE\MSSQLSERVER' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS /SQLCOLLATION=$Collation /USESQLRECOMMENDEDMEMORYLIMITS Set-ItemProperty -path "HKLM:\Software\Microsoft\Microsoft SQL Server\MSSQL$versionMajor.MSSQLSERVER\MSSQLSERVER\" -Name LoginMode -Value 2 Restart-Service MSSQLSERVER