Skip to content

Commit b26f789

Browse files
committed
Add Github Copilot setup steps for SQL Server
1 parent d52eb38 commit b26f789

3 files changed

Lines changed: 88 additions & 1 deletion

File tree

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
8989
- Create both unit tests and functional tests where appropriate
9090
- Fix `SQL` and `C#` baselines for tests when necessary by setting the `EF_TEST_REWRITE_BASELINES` env var to `1`
9191
- Run tests with project rebuilding enabled (don't use `--no-build`) to ensure code changes are picked up
92+
- When adding a new query-related test, always override it in the SQL Server provider and use AssertSql to verify the generated SQL is as expected.
9293

9394
#### Environment Setup
9495
- **ALWAYS** run `restore.cmd` (Windows) or `. ./restore.sh` (Linux/Mac) first to restore dependencies
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Based on https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment
4+
5+
# Automatically run the setup steps when they are changed to allow for easy validation, and
6+
# allow manual testing through the repository's "Actions" tab
7+
on:
8+
workflow_dispatch:
9+
push:
10+
paths:
11+
- .github/workflows/copilot-setup-steps.yml
12+
pull_request:
13+
paths:
14+
- .github/workflows/copilot-setup-steps.yml
15+
16+
jobs:
17+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
18+
copilot-setup-steps:
19+
runs-on: ubuntu-latest
20+
21+
# env:
22+
# MSSQL_IMAGE: mcr.microsoft.com/mssql/server:2025-latest
23+
24+
# Install SQL Server via a docker container.
25+
# It's better to do this rather than e.g. use a testcontainer, because then the agent can reuse the same container
26+
# and instance of SQL Server rather than have to start it up each time it needs to iterate and run a test.
27+
services:
28+
mssql:
29+
image: mcr.microsoft.com/mssql/server:2025-latest
30+
env:
31+
ACCEPT_EULA: "Y"
32+
SA_PASSWORD: ${{ secrets.MSSQL_SA_PASSWORD }}
33+
ports:
34+
- 1433:1433
35+
options: >-
36+
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${{ secrets.MSSQL_SA_PASSWORD }} -Q 'SELECT 1'"
37+
--health-interval=2s
38+
--health-retries=30
39+
--health-timeout=5s
40+
41+
# permissions:
42+
# contents: read
43+
44+
# You can define any steps you want, and they will run before the agent starts.
45+
# If you do not check out your code, Copilot will do this for you.
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v5
49+
50+
- name: Restore
51+
run: ./restore.sh
52+
53+
# - name: Setup .NET Core SDK
54+
# uses: actions/setup-dotnet@v5
55+
56+
# Install SQL Server via a docker container.
57+
# It's better to do this rather than e.g. use a testcontainer, because then the agent can reuse the same container
58+
# and instance of SQL Server rather than have to start it up each time it needs to iterate and run a test.
59+
# - name: Start SQL Server container
60+
# run: |
61+
# docker pull "$MSSQL_IMAGE"
62+
# docker run --name mssql -e ACCEPT_EULA=Y -e "SA_PASSWORD=${SA_PASSWORD}" -p 1433:1433 -d "$MSSQL_IMAGE"
63+
64+
# - name: Wait for SQL Server to be ready
65+
# shell: bash
66+
# run: |
67+
# # Simple wait loop; the container typically needs ~10-20s
68+
# for i in {1..60}; do
69+
# if docker exec mssql /opt/mssql-tools/bin/sqlcmd \
70+
# -S localhost -U sa -P "${{ secrets.MSSQL_SA_PASSWORD }}" \
71+
# -Q "SELECT 1" &>/dev/null; then
72+
# echo "SQL Server is up"
73+
# break
74+
# fi
75+
# echo "Waiting for SQL Server..." && sleep 1
76+
# done
77+
78+
- name: Export SQL Server connection string for the agent's session
79+
run: echo "Test__SqlServer__DefaultConnection=Server=localhost;Database=admin;User=SA;Password=${{ secrets.MSSQL_SA_PASSWORD }};Connect Timeout=60;ConnectRetryCount=0;Trust Server Certificate=true" >> "$GITHUB_ENV"

EFCore.slnx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Solution>
22
<Folder Name="/Solution Items/">
33
<File Path=".editorconfig" />
4-
<File Path=".github/copilot-instructions.md" />
54
<File Path="azure-pipelines-internal-tests.yml" />
65
<File Path="azure-pipelines-public.yml" />
76
<File Path="azure-pipelines.yml" />
@@ -13,6 +12,14 @@
1312
<File Path="NuGet.config" />
1413
<File Path="tools/Resources.tt" />
1514
</Folder>
15+
<Folder Name="/.github/">
16+
<File Path=".github/copilot-instructions.md" />
17+
</Folder>
18+
<Folder Name="/.github/workflows/">
19+
<File Path=".github/workflows/copilot-setup-steps.yml" />
20+
<File Path=".github/workflows/inter-branch-merge-flow.yml" />
21+
<File Path=".github/workflows/TestCosmos.yaml" />
22+
</Folder>
1623
<Folder Name="/src/">
1724
<File Path="src/Directory.Build.props" />
1825
<Project Path="src/dotnet-ef/dotnet-ef.csproj" />

0 commit comments

Comments
 (0)