Skip to content

Commit fa0cedb

Browse files
Update github-actions-ci.yaml
1 parent 6378685 commit fa0cedb

1 file changed

Lines changed: 43 additions & 27 deletions

File tree

.github/workflows/github-actions-ci.yaml

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,46 @@ on:
88

99
jobs:
1010
build:
11+
runs-on: ubuntu-latest
12+
services:
13+
sqlserver:
14+
image: mcr.microsoft.com/mssql/server:2022-latest
15+
env:
16+
SA_PASSWORD: "Your_password123"
17+
ACCEPT_EULA: "Y"
18+
ports:
19+
- 1433:1433
20+
options: >-
21+
--health-cmd "timeout 5s /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Your_password123 -Q 'SELECT 1' || exit 1"
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 10
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: 8.0.x
32+
33+
- name: Restore dependencies
34+
run: dotnet restore PosInformatique.Testing.Databases.sln
35+
36+
- name: Build solution
37+
run: dotnet build PosInformatique.Testing.Databases.sln --configuration Release --no-restore
38+
39+
- name: Restore samples
40+
run: dotnet restore samples/PosInformatique.Testing.Databases.Samples.sln
41+
42+
- name: Build samples
43+
run: dotnet build samples/PosInformatique.Testing.Databases.Samples.sln --configuration Debug --no-restore
44+
45+
- name: Run tests
46+
run: dotnet test PosInformatique.Testing.Databases.sln --configuration Debug --no-build --logger:"trx;LogFileName=test_results.trx"
47+
env:
48+
SQL_SERVER_UNIT_TESTS_CONNECTION_STRING: "Data Source=localhost,1433;Database=master;User Id=sa;Password=Your_password123;TrustServerCertificate=True;"
49+
50+
build-samples:
1151
runs-on: windows-latest
1252
steps:
1353
- uses: actions/checkout@v4
@@ -16,34 +56,10 @@ jobs:
1656
uses: nuget/setup-nuget@v2
1757

1858
- name: Restore NuGet packages
19-
run: nuget restore PosInformatique.Testing.Databases.sln
20-
59+
run: nuget restore samples/PosInformatique.Testing.Databases.Samples.sln
60+
2161
- name: Add msbuild to PATH
2262
uses: microsoft/setup-msbuild@v2
2363

24-
- name: Build
25-
run: msbuild "PosInformatique.Testing.Databases.sln" /p:Configuration=Debug
26-
27-
- name: Restore NuGet packages
28-
run: nuget restore "samples/PosInformatique.Testing.Databases.Samples.sln"
29-
30-
- name: Build the samples
64+
- name: Build samples with Visual Studio
3165
run: msbuild "samples/PosInformatique.Testing.Databases.Samples.sln" /p:Configuration=Debug
32-
33-
- name: Creates the LocalDB for the tests
34-
shell: cmd
35-
run: SqlLocalDB create posinfo-tests
36-
37-
- name: Creates the SQL Login service accounts for the tests
38-
shell: cmd
39-
run: sqlcmd -S "(localDB)\posinfo-tests" -Q "IF NOT EXISTS (SELECT 1 FROM [sys].[server_principals] WHERE [Name] = 'ServiceAccountLogin') CREATE LOGIN [ServiceAccountLogin] WITH PASSWORD = 'P@ssw0rd'"
40-
41-
# Use this fix https://github.com/microsoft/vstest-action/issues/31#issuecomment-2159463764
42-
- name: Test with the dotnet CLI
43-
uses: rusty-bender/vstest-action@main
44-
with:
45-
searchFolder: .\
46-
testAssembly: |
47-
/tests/**/*tests.dll
48-
!./**/*TestAdapter.dll
49-
!./**/obj/**

0 commit comments

Comments
 (0)