Skip to content

Commit

Permalink
Adding full-text search option (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaddell authored Jan 13, 2025
1 parent b2e1307 commit 770101d
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 9 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/advanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ./
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions .github/workflows/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions Dockerfile-2019
Original file line number Diff line number Diff line change
@@ -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" ]
17 changes: 17 additions & 0 deletions Dockerfile-2022
Original file line number Diff line number Diff line change
@@ -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" ]
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions Test-FullTextSearch.ps1
Original file line number Diff line number Diff line change
@@ -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
15 changes: 12 additions & 3 deletions main.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
param (
[ValidateSet("sqlclient", "sqlpackage", "sqlengine", "localdb")]
[ValidateSet("sqlclient", "sqlpackage", "sqlengine", "localdb", "fulltext")]
[string[]]$Install,
[string]$SaPassword = "dbatools.I0",
[switch]$ShowLog,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 770101d

Please sign in to comment.