Skip to content

Commit

Permalink
build(efcore): use LocalDB for SQL testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jayharris committed Apr 3, 2024
1 parent ea40d5e commit 817a79c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci-efcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install SQL LocalDB
run: ${{ env.solutionFolder }}/InstallLocalDB.ps1
shell: pwsh

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
Expand All @@ -43,6 +47,9 @@ jobs:
- name: Build
run: dotnet build ${{ env.solutionFolder }} --no-restore --configuration ${{ env.buildConfiguration }} /p:ContinuousIntegrationBuild=true /p:BuildNumber=${{ env.BUILD_NUMBER }}

- name: Start SQL LocalDB
run: sqllocaldb start mssqllocaldb

- name: Test
run: dotnet test ${{ env.solutionFolder }} --no-restore --no-build --configuration ${{ env.buildConfiguration }}

Expand Down
3 changes: 3 additions & 0 deletions src/entityframeworkcore/EntityFrameworkCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
CHANGELOG.md = CHANGELOG.md
Directory.Build.props = Directory.Build.props
README.md = README.md
InstallLocalDB.ps1 = InstallLocalDB.ps1
.pipelines/build.yml = .pipelines/build.yml
../../.github/workflows/ci-efcore.yml = ../../.github/workflows/ci-efcore.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_deps", "_deps", "{6CB010A9-4ADC-4F5B-843C-0490204A9110}"
Expand Down
31 changes: 31 additions & 0 deletions src/entityframeworkcore/InstallLocalDB.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Taken from psake https://github.com/psake/psake

<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}

Write-Host "Downloading"
Import-Module BitsTransfer
Start-BitsTransfer -Source https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SqlLocalDB.msi -Destination SqlLocalDB.msi
Write-Host "Installing"
Start-Process -FilePath "SqlLocalDB.msi" -Wait -ArgumentList "/qn", "/norestart", "/l*v SqlLocalDBInstall.log", "IACCEPTSQLLOCALDBLICENSETERMS=YES";
Write-Host "Checking"
sqlcmd -l 60 -S "(localdb)\MSSQLLocalDB" -Q "SELECT @@VERSION;"

0 comments on commit 817a79c

Please sign in to comment.