Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: .NET

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: Password12!
POSTGRES_USER: postgres
POSTGRES_DB: sqlprovider
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore tools
run: dotnet tool restore

- name: Restore dependencies
run: dotnet paket restore

- name: Build
run: dotnet fake run build.fsx -t Build

- name: Test
run: dotnet fake run build.fsx -t RunTests
9 changes: 2 additions & 7 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,14 @@
<Splits>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)</Splits>
<PackageName>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])</PackageName>
<PackageVersion>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])</PackageVersion>
<Reference>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[2])</Reference>
<AllPrivateAssets>$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])</AllPrivateAssets>
<CopyLocal Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 6">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])</CopyLocal>
<OmitContent Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 7">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])</OmitContent>
<ImportTargets Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 8">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])</ImportTargets>
<Aliases Condition="%(PaketReferencesFileLinesInfo.Splits) &gt;= 9">$([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[8])</Aliases>
</PaketReferencesFileLinesInfo>
<PackageReference Condition=" '$(ManagePackageVersionsCentrally)' != 'true' Or '%(PaketReferencesFileLinesInfo.Reference)' == 'Direct' " Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version Condition=" '$(ManagePackageVersionsCentrally)' != 'true' ">%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PackageReference Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
<PrivateAssets Condition=" ('%(PaketReferencesFileLinesInfo.AllPrivateAssets)' == 'true') Or ('$(PackAsTool)' == 'true') ">All</PrivateAssets>
<ExcludeAssets Condition=" %(PaketReferencesFileLinesInfo.CopyLocal) == 'false' or %(PaketReferencesFileLinesInfo.AllPrivateAssets) == 'exclude'">runtime</ExcludeAssets>
<ExcludeAssets Condition=" %(PaketReferencesFileLinesInfo.OmitContent) == 'true'">$(ExcludeAssets);contentFiles</ExcludeAssets>
Expand All @@ -253,10 +252,6 @@
<AllowExplicitVersion>true</AllowExplicitVersion>

</PackageReference>

<PackageVersion Include="%(PaketReferencesFileLinesInfo.PackageName)">
<Version>%(PaketReferencesFileLinesInfo.PackageVersion)</Version>
</PackageVersion>
</ItemGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ build_script:
test: off
version: 0.0.1.{build}
image: Visual Studio 2022
install:
- cmd: choco install dotnetcore-sdk -y
services:
- mssql2022
artifacts:
- path: bin
name: bin
Expand Down
22 changes: 15 additions & 7 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,27 @@ let setupMssql url saPassword =
connBuilder.UserID <- "sa"
connBuilder.DataSource <- url
connBuilder.Password <- saPassword
connBuilder.TrustServerCertificate <- true

let runCmd query =
// We wait up to 30 seconds for MSSQL to be initialized
// We wait up to 60 seconds for MSSQL to be initialized on AppVeyor
let maxAttempts = if Fake.Core.BuildServer.buildServer = AppVeyor then 60 else 30
let rec runCmd' attempt =
try
use conn = new SqlConnection(connBuilder.ConnectionString)
conn.Open()
use cmd = new SqlCommand(query, conn)
cmd.ExecuteNonQuery() |> ignore
with e ->
printfn "Connection attempt %i: %A" attempt e
Threading.Thread.Sleep 1000
if attempt < 30 then runCmd' (attempt + 1)
printfn "Connection attempt %i/%i: %A" attempt maxAttempts e
if attempt < maxAttempts then
Threading.Thread.Sleep 1000
runCmd' (attempt + 1)
else
printfn "Failed to connect to SQL Server after %i attempts. Last error: %A" maxAttempts e
reraise()

runCmd' 0
runCmd' 1

let runScript fileLines =

Expand Down Expand Up @@ -330,11 +336,13 @@ let setupMssql url saPassword =
(url,saPassword) |> ignore

Target.create "SetupMSSQL2008R2" (fun _ ->
setupMssql "(local)\\SQL2008R2SP2" "Password12!"
printfn "Setting up MSSQL for AppVeyor (compatibility target for SQL2008R2)"
setupMssql "(local)\\SQL2022" "Password12!"
)

Target.create "SetupMSSQL2017" (fun _ ->
setupMssql "(local)\\SQL2017" "Password12!"
printfn "Setting up MSSQL for AppVeyor (compatibility target for SQL2017)"
setupMssql "(local)\\SQL2022" "Password12!"
)


Expand Down
4 changes: 2 additions & 2 deletions tests/SqlProvider.Tests/SqlServerTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ let runtimeConnStr = connStr2008R2
#else
module SqlServerTests

let [<Literal>] connStr2008R2 = "Data Source=(local)\SQL2008R2SP2;User Id=sa;Password=Password12!; Initial Catalog=sqlprovider;"
let [<Literal>] connStr2017 = "Data Source=(local)\SQL2017;User Id=sa;Password=Password12!; Initial Catalog=sqlprovider;"
let [<Literal>] connStr2008R2 = "Data Source=(local)\SQL2022;User Id=sa;Password=Password12!; Initial Catalog=sqlprovider; TrustServerCertificate=true;"
let [<Literal>] connStr2017 = "Data Source=(local)\SQL2022;User Id=sa;Password=Password12!; Initial Catalog=sqlprovider; TrustServerCertificate=true;"

#endif

Expand Down
Loading