Skip to content

Commit 2e2de7e

Browse files
authored
Add SQL Server testing on Github Actions (#37501)
For SQL Server 2025, 2022, 2019. Closes #36382
1 parent 6b86657 commit 2e2de7e

File tree

4 files changed

+79
-7
lines changed

4 files changed

+79
-7
lines changed

.github/workflows/TestCosmos.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Test Cosmos
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
- feature/*
8+
- release/*
49
pull_request:
510
branches:
611
- main
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Test SQL Server
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- feature/*
8+
- release/*
9+
pull_request:
10+
branches:
11+
- main
12+
- feature/*
13+
- release/*
14+
15+
permissions: {}
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-24.04
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
sqlserver_version: [2025, 2022, 2019]
25+
26+
env:
27+
MSSQL_SA_PASSWORD: 'PLACEHOLDERPass$$w0rd'
28+
29+
services:
30+
mssql:
31+
image: mcr.microsoft.com/mssql/server:${{ matrix.sqlserver_version }}-latest
32+
env:
33+
ACCEPT_EULA: Y
34+
SA_PASSWORD: ${{ env.MSSQL_SA_PASSWORD }}
35+
ports:
36+
- 1433:1433
37+
options: >-
38+
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -Q 'SELECT 1' -C"
39+
--health-start-period=20s
40+
--health-interval=2s
41+
--health-retries=30
42+
--health-timeout=5s
43+
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v6
47+
48+
- name: Restore
49+
run: ./restore.sh
50+
51+
- name: Test on SQL Server
52+
env:
53+
Test__SqlServer__DefaultConnection: 'Server=localhost;Database=master;User=SA;Password=${{ env.MSSQL_SA_PASSWORD }};Connect Timeout=60;ConnectRetryCount=0;Trust Server Certificate=true'
54+
run: dotnet test test/EFCore.SqlServer.FunctionalTests
55+
56+
- name: Publish Test Results
57+
uses: actions/upload-artifact@v6
58+
if: always()
59+
with:
60+
name: test-results-sqlserver-${{ matrix.sqlserver_version }}
61+
path: artifacts/log/Debug/*

.github/workflows/copilot-setup-steps.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,26 @@ on:
1313
paths:
1414
- .github/workflows/copilot-setup-steps.yml
1515

16+
permissions: {}
17+
1618
jobs:
1719
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
1820
copilot-setup-steps:
1921
runs-on: ubuntu-24.04
2022

23+
env:
24+
MSSQL_SA_PASSWORD: 'PLACEHOLDERPass$$w0rd'
25+
Test__SqlServer__DefaultConnection: 'Server=localhost;Database=master;User=SA;Password=PLACEHOLDERPass$$w0rd;Connect Timeout=60;ConnectRetryCount=0;Trust Server Certificate=true'
26+
2127
# Install SQL Server via a docker container.
2228
# It's better to do this rather than e.g. use a testcontainer, because then the agent can reuse the same container
2329
# and instance of SQL Server rather than have to start it up each time it needs to iterate and run a test.
2430
services:
2531
mssql:
2632
image: mcr.microsoft.com/mssql/server:2025-latest
2733
env:
28-
ACCEPT_EULA: "Y"
29-
SA_PASSWORD: "${{ secrets.MSSQL_SA_PASSWORD }}"
34+
ACCEPT_EULA: Y
35+
SA_PASSWORD: ${{ env.MSSQL_SA_PASSWORD }}
3036
ports:
3137
- 1433:1433
3238
options: >-
@@ -36,9 +42,8 @@ jobs:
3642
--health-retries=30
3743
--health-timeout=5s
3844
39-
permissions:
40-
contents: read
41-
4245
steps:
43-
- name: Export SQL Server connection string for the agent's session
44-
run: echo "Test__SqlServer__DefaultConnection=Server=localhost;Database=master;User=SA;Password=${{ secrets.MSSQL_SA_PASSWORD }};Connect Timeout=60;ConnectRetryCount=0;Trust Server Certificate=true" >> "$GITHUB_ENV"
46+
# The Github Actions workflow syntax requires there to be at least one step;
47+
# we don't have anything to do (we started SQL Server above), so just print something.
48+
- name: Dummy step
49+
run: echo "Workflow complete."

EFCore.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<File Path=".github/workflows/copilot-setup-steps.yml" />
2020
<File Path=".github/workflows/inter-branch-merge-flow.yml" />
2121
<File Path=".github/workflows/TestCosmos.yaml" />
22+
<File Path=".github/workflows/TestSqlServer.yaml" />
2223
</Folder>
2324
<Folder Name="/src/">
2425
<File Path="src/Directory.Build.props" />

0 commit comments

Comments
 (0)