In this post, let's see how you can install SQL Server Express LocalDB in GitHub Workflows. This is useful when you want to run integration tests in a Workflow.
Technically you can use this approach anywhere as long as the Agent is Windows, as this is just a set of PowerShell commands.
name: Build and deploy
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- ...
- name: Install MSSQLLocalDB
run: |
Import-Module BitsTransfer
Start-BitsTransfer `
-Source https://download.microsoft.com/download/3/8/d/38de7036-2433-4207-8eae-06e247e17b25/SqlLocalDB.msi `
-Destination SqlLocalDB.msi
Start-Process `
-FilePath "SqlLocalDB.msi" `
-ArgumentList "/qn", "/norestart", "/l*v SqlLocalDBInstall.log", "IACCEPTSQLLOCALDBLICENSETERMS=YES"; `
-Wait
sqlcmd -l 60 -S "(LocalDb)\MSSQLLocalDB" -Q "SELECT @@VERSION;"
First, we are importing the
BITS (Background Intelligent Transfer Management) module, and downloading the SqlLocalDB.msi. Then we are doing a silent
install and the last command is to test the connectivity to the instance.
The specified link for SqlLocalDB.msi is for SQL Server 2022. If you want to use
SQL Server 2019, you can this link: https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SqlLocalDB.msi
Hope this helps.
Happy Coding.
Regards,
Jaliya
Jaliya
No comments:
Post a Comment