Add Docker setup and SQL Server container support to Copilot workflow#2286
Add Docker setup and SQL Server container support to Copilot workflow#2286johlju wants to merge 1 commit intodsccommunity:mainfrom
Conversation
WalkthroughIntroduces a GitHub Actions workflow to set up Docker, run a SQL Server 2022 Linux container, install Microsoft SQL command-line tools, and verify connectivity via sqlcmd. The entire setup sequence is duplicated consecutively in the same workflow. Updates CHANGELOG to note SQL Server container support and removal of certain integration tests. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor GA as GitHub Actions Runner
participant DO as Docker Engine
participant IMG as mcr.microsoft.com/mssql/server:2022-latest
participant CT as SQL Server Container
participant PKG as Package Manager
participant CLI as mssql-tools/sqlcmd
GA->>GA: Check/install Docker, enable & start service
GA->>DO: docker --version / hello-world
GA->>DO: docker pull IMG
GA->>DO: docker volume create mssql-data
GA->>DO: docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=...' -p 1433:1433 --name sql2022 ...
DO->>CT: Start container
GA->>DO: Wait and inspect/logs
GA->>PKG: Add MS repo, install mssql-tools18 (fallback to mssql-tools)
GA->>CLI: Verify sqlcmd availability
loop Retry until ready
GA->>CT: sqlcmd -Q "SELECT 1"
alt Success
GA->>CT: sqlcmd -Q "CREATE DATABASE TestDb"
else Failure
Note over GA,CT: Log attempt, wait, retry
end
end
GA->>DO: docker stats --no-stream
Note over GA: Entire sequence is duplicated and runs again
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Pre-merge checks✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
CHANGELOG.md (1)
10-12: Italicize product names per Markdown style guidelines.Use italics for product names. Wording is fine; optionally link the tracking issue if one exists.
-- Added SQL Server on Linux container support to AI workflow for cross-platform - testing and development assistance with Docker containerized SQL Server 2022 - instances. +- Added _SQL Server_ on Linux container support to AI workflow for cross‑platform + testing and development assistance with Docker‑containerized _SQL Server 2022_ + instances..github/workflows/copilot-setup-steps.yml (2)
158-186: Trim Docker setup; avoid ineffective group change and rate‑limited hello‑world.
usermod -aG docker $USERwon’t take effect in this session; drop it.- Prefer
docker infoover pullinghello-worldto avoid rate limits and save time.- # Add current user to docker group for permissions - sudo usermod -aG docker $USER - - # Verify Docker is working - docker --version - sudo docker run --rm hello-world + # Verify Docker is working + docker --version + sudo docker info
286-345: Avoid printing credentials; tighten failure diagnostics.
- Don’t echo a connection string containing a password.
- Keep success output minimal; rely on masked env vars if needed.
- echo "Connection details:" - echo " Server: localhost,$SQLSERVER_PORT" - echo " User: sa" - echo " Connection String: $SQLSERVER_CONNECTION_STRING" + echo "Connection details:" + echo " Server: localhost,$SQLSERVER_PORT" + echo " User: sa" + echo " Connection String (password masked)"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/copilot-setup-steps.yml(1 hunks)CHANGELOG.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.md
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-markdown.instructions.md)
**/*.md: Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
Use 2 spaces for indentation in Markdown documents
Use '1.' for all items in ordered lists (1/1/1 numbering style)
Disable MD013 for tables/code blocks exceeding 80 characters via an inline comment
Require empty lines before and after code blocks and headings (except before line 1)
Escape backslashes in file paths only, not inside code blocks
All fenced code blocks must specify a language identifier
Format parameter names as bold
Format values/literals as inline code
Format resource/module/product names as italic
Format commands, file names, and paths as inline code
Files:
CHANGELOG.md
⚙️ CodeRabbit configuration file
**/*.md: # Markdown Style Guidelines
- Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
- Use 2 spaces for indentation
- Use '1.' for all items in ordered lists (1/1/1 numbering style)
- Disable
MD013rule by adding a comment for tables/code blocks exceeding 80 characters- Empty lines required before/after code blocks and headings (except before line 1)
- Escape backslashes in file paths only (not in code blocks)
- Code blocks must specify language identifiers
Text Formatting
- Parameters: bold
- Values/literals:
inline code- Resource/module/product names: italic
- Commands/files/paths:
inline code
Files:
CHANGELOG.md
CHANGELOG.md
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-changelog.instructions.md)
CHANGELOG.md: Always update the Unreleased section in CHANGELOG.md
Use Keep a Changelog format
Describe notable changes briefly, with no more than 2 items per change type
Reference issues using the format issue #<issue_number>
No empty lines between list items in the same section
Skip adding an entry if the same change already exists in the Unreleased section
No duplicate sections or items in the Unreleased sectionAlways update the Unreleased section of CHANGELOG.md
Files:
CHANGELOG.md
⚙️ CodeRabbit configuration file
CHANGELOG.md: # Changelog Guidelines
- Always update the Unreleased section in CHANGELOG.md
- Use Keep a Changelog format
- Describe notable changes briefly, ≤2 items per change type
- Reference issues using format issue #<issue_number>
- No empty lines between list items in same section
- Skip adding entry if same change already exists in Unreleased section
- No duplicate sections or items in Unreleased section
Files:
CHANGELOG.md
**
⚙️ CodeRabbit configuration file
**: # DSC Community GuidelinesTerminology
- Command: Public command
- Function: Private function
- Resource: DSC class-based resource
Build & Test Workflow Requirements
- Run PowerShell script files from repository root
- Setup build and test environment (once per
pwshsession):./build.ps1 -Tasks noop- Build project before running tests:
./build.ps1 -Tasks build- Always run tests in new
pwshsession:Invoke-Pester -Path @({test paths}) -Output DetailedFile Organization
- Public commands:
source/Public/{CommandName}.ps1- Private functions:
source/Private/{FunctionName}.ps1- Unit tests:
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1- Integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Requirements
- Follow instructions over existing code patterns
- Follow PowerShell style and test guideline instructions strictly
- Always update CHANGELOG.md Unreleased section
- Localize all strings using string keys; remove any orphaned string keys
- Check DscResource.Common before creating private functions
- Separate reusable logic into private functions
- DSC resources should always be created as class-based resources
- Add unit tests for all commands/functions/resources
- Add integration tests for all public commands and resources
Files:
CHANGELOG.md
🧠 Learnings (1)
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to tests/**/*.ps1 : When referencing CI SQL instances in tests, use: Database Engine=DSCSQLTEST, Reporting Services=SSRS, Power BI Report Server=PBIRS
Applied to files:
CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: Setup PowerShell Development Environment
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
| - name: Setup SQL Server on Linux Container | ||
| shell: bash | ||
| run: | | ||
| echo "Setting up SQL Server Linux container..." | ||
|
|
||
| # Set SQL Server environment variables | ||
| SQLSERVER_SA_PASSWORD="MyStr0ng!Passw0rd123" | ||
| SQLSERVER_CONTAINER_NAME="sqlserver-linux-ci" | ||
| SQLSERVER_PORT="1433" | ||
|
|
||
| echo "::group::Pull SQL Server Linux container image" | ||
| echo "Pulling SQL Server 2022 Linux container image..." | ||
| sudo docker pull mcr.microsoft.com/mssql/server:2022-latest | ||
| echo "Container image pulled successfully" | ||
| echo "::endgroup::" | ||
|
|
||
| echo "::group::Run SQL Server Linux container" | ||
| echo "Starting SQL Server Linux container..." | ||
|
|
||
| # Create volume for SQL Server data persistence | ||
| sudo docker volume create sqlserver-data | ||
|
|
||
| # Run SQL Server container with proper configuration | ||
| sudo docker run -e 'ACCEPT_EULA=Y' \ | ||
| -e "MSSQL_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" \ | ||
| -e 'MSSQL_PID=Developer' \ | ||
| -p "${SQLSERVER_PORT}:1433" \ | ||
| --name "${SQLSERVER_CONTAINER_NAME}" \ | ||
| --hostname sqlserver-linux \ | ||
| -v sqlserver-data:/var/opt/mssql \ | ||
| -d mcr.microsoft.com/mssql/server:2022-latest | ||
|
|
||
| echo "Waiting for SQL Server container to start..." | ||
| sleep 30 | ||
|
|
||
| # Check if container is running | ||
| if sudo docker ps | grep -q "${SQLSERVER_CONTAINER_NAME}"; then | ||
| echo "SQL Server Linux container started successfully" | ||
|
|
||
| # Display container information | ||
| echo "Container status:" | ||
| sudo docker ps --filter "name=${SQLSERVER_CONTAINER_NAME}" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | ||
|
|
||
| # Check SQL Server logs for startup confirmation | ||
| echo "Checking SQL Server startup logs..." | ||
| sudo docker logs "${SQLSERVER_CONTAINER_NAME}" 2>&1 | tail -10 | ||
|
|
||
| # Set environment variables for later steps | ||
| echo "SQLSERVER_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" >> "$GITHUB_ENV" | ||
| echo "SQLSERVER_CONTAINER_NAME=${SQLSERVER_CONTAINER_NAME}" >> "$GITHUB_ENV" | ||
| echo "SQLSERVER_PORT=${SQLSERVER_PORT}" >> "$GITHUB_ENV" | ||
| echo "SQLSERVER_CONNECTION_STRING=Server=localhost,${SQLSERVER_PORT};User Id=sa;Password=${SQLSERVER_SA_PASSWORD};TrustServerCertificate=true" >> "$GITHUB_ENV" | ||
| else | ||
| echo "::error::Failed to start SQL Server Linux container" | ||
| sudo docker logs "${SQLSERVER_CONTAINER_NAME}" || true | ||
| exit 1 | ||
| fi | ||
| echo "::endgroup::" | ||
|
|
There was a problem hiding this comment.
Stop leaking the SA password; generate, mask, and avoid printing secrets.
- Password is hardcoded, exported to GITHUB_ENV, and printed in the connection string.
- Generate a strong per‑run password, mask it via add‑mask, and do not echo it.
- Make the container step idempotent and wait on readiness via logs instead of a fixed sleep.
- # Set SQL Server environment variables
- SQLSERVER_SA_PASSWORD="MyStr0ng!Passw0rd123"
+ # Set SQL Server environment variables (generate per-run)
+ SQLSERVER_SA_PASSWORD="$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9!@#%^*()_+=' | head -c 24)"
+ echo "::add-mask::$SQLSERVER_SA_PASSWORD"
SQLSERVER_CONTAINER_NAME="sqlserver-linux-ci"
SQLSERVER_PORT="1433"
@@
- # Create volume for SQL Server data persistence
- sudo docker volume create sqlserver-data
+ # Ensure a clean slate (idempotent)
+ sudo docker rm -f "${SQLSERVER_CONTAINER_NAME}" >/dev/null 2>&1 || true
+ sudo docker volume create sqlserver-data >/dev/null 2>&1 || true
@@
- echo "Waiting for SQL Server container to start..."
- sleep 30
+ echo "Waiting for SQL Server to become ready..."
+ # Wait up to 120s for readiness message in logs
+ for i in {1..24}; do
+ if sudo docker logs "${SQLSERVER_CONTAINER_NAME}" 2>&1 | grep -q "SQL Server is now ready for client connections"; then
+ break
+ fi
+ sleep 5
+ done
@@
- # Set environment variables for later steps
- echo "SQLSERVER_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" >> "$GITHUB_ENV"
+ # Set environment variables for later steps (password is masked)
+ echo "SQLSERVER_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" >> "$GITHUB_ENV"
echo "SQLSERVER_CONTAINER_NAME=${SQLSERVER_CONTAINER_NAME}" >> "$GITHUB_ENV"
echo "SQLSERVER_PORT=${SQLSERVER_PORT}" >> "$GITHUB_ENV"
- echo "SQLSERVER_CONNECTION_STRING=Server=localhost,${SQLSERVER_PORT};User Id=sa;Password=${SQLSERVER_SA_PASSWORD};TrustServerCertificate=true" >> "$GITHUB_ENV"
+ echo "SQLSERVER_CONNECTION_STRING=Server=localhost,${SQLSERVER_PORT};User Id=sa;TrustServerCertificate=true" >> "$GITHUB_ENV"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Setup SQL Server on Linux Container | |
| shell: bash | |
| run: | | |
| echo "Setting up SQL Server Linux container..." | |
| # Set SQL Server environment variables | |
| SQLSERVER_SA_PASSWORD="MyStr0ng!Passw0rd123" | |
| SQLSERVER_CONTAINER_NAME="sqlserver-linux-ci" | |
| SQLSERVER_PORT="1433" | |
| echo "::group::Pull SQL Server Linux container image" | |
| echo "Pulling SQL Server 2022 Linux container image..." | |
| sudo docker pull mcr.microsoft.com/mssql/server:2022-latest | |
| echo "Container image pulled successfully" | |
| echo "::endgroup::" | |
| echo "::group::Run SQL Server Linux container" | |
| echo "Starting SQL Server Linux container..." | |
| # Create volume for SQL Server data persistence | |
| sudo docker volume create sqlserver-data | |
| # Run SQL Server container with proper configuration | |
| sudo docker run -e 'ACCEPT_EULA=Y' \ | |
| -e "MSSQL_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" \ | |
| -e 'MSSQL_PID=Developer' \ | |
| -p "${SQLSERVER_PORT}:1433" \ | |
| --name "${SQLSERVER_CONTAINER_NAME}" \ | |
| --hostname sqlserver-linux \ | |
| -v sqlserver-data:/var/opt/mssql \ | |
| -d mcr.microsoft.com/mssql/server:2022-latest | |
| echo "Waiting for SQL Server container to start..." | |
| sleep 30 | |
| # Check if container is running | |
| if sudo docker ps | grep -q "${SQLSERVER_CONTAINER_NAME}"; then | |
| echo "SQL Server Linux container started successfully" | |
| # Display container information | |
| echo "Container status:" | |
| sudo docker ps --filter "name=${SQLSERVER_CONTAINER_NAME}" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | |
| # Check SQL Server logs for startup confirmation | |
| echo "Checking SQL Server startup logs..." | |
| sudo docker logs "${SQLSERVER_CONTAINER_NAME}" 2>&1 | tail -10 | |
| # Set environment variables for later steps | |
| echo "SQLSERVER_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" >> "$GITHUB_ENV" | |
| echo "SQLSERVER_CONTAINER_NAME=${SQLSERVER_CONTAINER_NAME}" >> "$GITHUB_ENV" | |
| echo "SQLSERVER_PORT=${SQLSERVER_PORT}" >> "$GITHUB_ENV" | |
| echo "SQLSERVER_CONNECTION_STRING=Server=localhost,${SQLSERVER_PORT};User Id=sa;Password=${SQLSERVER_SA_PASSWORD};TrustServerCertificate=true" >> "$GITHUB_ENV" | |
| else | |
| echo "::error::Failed to start SQL Server Linux container" | |
| sudo docker logs "${SQLSERVER_CONTAINER_NAME}" || true | |
| exit 1 | |
| fi | |
| echo "::endgroup::" | |
| - name: Setup SQL Server on Linux Container | |
| shell: bash | |
| run: | | |
| echo "Setting up SQL Server Linux container..." | |
| # Set SQL Server environment variables (generate per-run) | |
| SQLSERVER_SA_PASSWORD="$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9!@#%^*()_+=' | head -c 24)" | |
| echo "::add-mask::$SQLSERVER_SA_PASSWORD" | |
| SQLSERVER_CONTAINER_NAME="sqlserver-linux-ci" | |
| SQLSERVER_PORT="1433" | |
| echo "::group::Pull SQL Server Linux container image" | |
| echo "Pulling SQL Server 2022 Linux container image..." | |
| sudo docker pull mcr.microsoft.com/mssql/server:2022-latest | |
| echo "Container image pulled successfully" | |
| echo "::endgroup::" | |
| echo "::group::Run SQL Server Linux container" | |
| echo "Starting SQL Server Linux container..." | |
| # Ensure a clean slate (idempotent) | |
| sudo docker rm -f "${SQLSERVER_CONTAINER_NAME}" >/dev/null 2>&1 || true | |
| sudo docker volume create sqlserver-data >/dev/null 2>&1 || true | |
| # Run SQL Server container with proper configuration | |
| sudo docker run -e 'ACCEPT_EULA=Y' \ | |
| -e "MSSQL_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" \ | |
| -e 'MSSQL_PID=Developer' \ | |
| -p "${SQLSERVER_PORT}:1433" \ | |
| --name "${SQLSERVER_CONTAINER_NAME}" \ | |
| --hostname sqlserver-linux \ | |
| -v sqlserver-data:/var/opt/mssql \ | |
| -d mcr.microsoft.com/mssql/server:2022-latest | |
| echo "Waiting for SQL Server to become ready..." | |
| # Wait up to 120s for readiness message in logs | |
| for i in {1..24}; do | |
| if sudo docker logs "${SQLSERVER_CONTAINER_NAME}" 2>&1 | grep -q "SQL Server is now ready for client connections"; then | |
| break | |
| fi | |
| sleep 5 | |
| done | |
| # Check if container is running | |
| if sudo docker ps | grep -q "${SQLSERVER_CONTAINER_NAME}"; then | |
| echo "SQL Server Linux container started successfully" | |
| # Display container information | |
| echo "Container status:" | |
| sudo docker ps --filter "name=${SQLSERVER_CONTAINER_NAME}" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | |
| # Check SQL Server logs for startup confirmation | |
| echo "Checking SQL Server startup logs..." | |
| sudo docker logs "${SQLSERVER_CONTAINER_NAME}" 2>&1 | tail -10 | |
| # Set environment variables for later steps (password is masked) | |
| echo "SQLSERVER_SA_PASSWORD=${SQLSERVER_SA_PASSWORD}" >> "$GITHUB_ENV" | |
| echo "SQLSERVER_CONTAINER_NAME=${SQLSERVER_CONTAINER_NAME}" >> "$GITHUB_ENV" | |
| echo "SQLSERVER_PORT=${SQLSERVER_PORT}" >> "$GITHUB_ENV" | |
| echo "SQLSERVER_CONNECTION_STRING=Server=localhost,${SQLSERVER_PORT};User Id=sa;TrustServerCertificate=true" >> "$GITHUB_ENV" | |
| else | |
| echo "::error::Failed to start SQL Server Linux container" | |
| sudo docker logs "${SQLSERVER_CONTAINER_NAME}" || true | |
| exit 1 | |
| fi | |
| echo "::endgroup::" |
🤖 Prompt for AI Agents
In .github/workflows/copilot-setup-steps.yml around lines 187-245, the SA
password is hardcoded, exported and printed which leaks secrets; replace that
with a securely generated per-run password (e.g. use openssl or /dev/urandom
base64), immediately mask it with the GitHub Actions mask command
(::add-mask::${SQLSERVER_SA_PASSWORD}) and do not echo or print the password
anywhere (including connection strings); write the masked value to GITHUB_ENV
but avoid printing the file contents; make the container step idempotent by
checking if the named container already exists (start/stop/remove as
appropriate) instead of blindly creating, and replace the fixed sleep with a
readiness loop that polls docker logs for a SQL Server ready message (with a
sensible timeout and non-zero exit on failure) before exporting connection
details (export only non-secret parts or use templated connection string that
references the masked secret at runtime).
| - name: Install SQL Server Command Line Tools | ||
| shell: bash | ||
| run: | | ||
| echo "Installing SQL Server command line tools (sqlcmd)..." | ||
|
|
||
| echo "::group::Install mssql-tools" | ||
| # Install the Microsoft SQL Server command-line tools | ||
| if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then | ||
| echo "Microsoft repository not found, adding it..." | ||
| sudo install -m 0755 -d /etc/apt/keyrings | ||
| curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg >/dev/null | ||
| sudo chmod a+r /etc/apt/keyrings/microsoft.gpg | ||
| DISTRO_CODENAME="$(lsb_release -cs)" | ||
| echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/microsoft-ubuntu-${DISTRO_CODENAME}-prod ${DISTRO_CODENAME} main" | sudo tee "/etc/apt/sources.list.d/microsoft-${DISTRO_CODENAME}-prod.list" >/dev/null | ||
| sudo apt-get update | ||
| fi | ||
|
|
||
| # Accept EULA for mssql-tools (required for non-interactive installation) | ||
| echo 'mssql-tools accept-eula/accept-eula-license boolean true' | sudo debconf-set-selections | ||
|
|
||
| # Install mssql-tools18 (latest version with enhanced security) | ||
| if sudo apt-get install -y mssql-tools18; then | ||
| echo "mssql-tools18 installed successfully" | ||
| # Add sqlcmd to PATH for current session | ||
| export PATH="$PATH:/opt/mssql-tools18/bin" | ||
| echo "/opt/mssql-tools18/bin" | sudo tee -a /etc/environment | ||
| echo "PATH=$PATH:/opt/mssql-tools18/bin" >> "$GITHUB_ENV" | ||
| else | ||
| echo "::warning::mssql-tools18 installation failed, trying mssql-tools" | ||
| # Fallback to older version if needed | ||
| sudo apt-get install -y mssql-tools | ||
| export PATH="$PATH:/opt/mssql-tools/bin" | ||
| echo "/opt/mssql-tools/bin" | sudo tee -a /etc/environment | ||
| echo "PATH=$PATH:/opt/mssql-tools/bin" >> "$GITHUB_ENV" | ||
| fi | ||
|
|
||
| # Verify sqlcmd installation | ||
| which sqlcmd || echo "::warning::sqlcmd not found in PATH" | ||
| echo "::endgroup::" | ||
|
|
There was a problem hiding this comment.
Fix mssql-tools install: noninteractive EULA + correct PATH handling; don’t write raw path to /etc/environment.
- Use
ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractiveto avoid prompts. - Remove writes of a bare path line to
/etc/environment(invalid format). - Append to PATH via GITHUB_ENV only.
- # Accept EULA for mssql-tools (required for non-interactive installation)
- echo 'mssql-tools accept-eula/accept-eula-license boolean true' | sudo debconf-set-selections
-
- # Install mssql-tools18 (latest version with enhanced security)
- if sudo apt-get install -y mssql-tools18; then
+ # Install mssql-tools18 (noninteractive)
+ export DEBIAN_FRONTEND=noninteractive
+ export ACCEPT_EULA=Y
+ if sudo -E apt-get install -y mssql-tools18; then
echo "mssql-tools18 installed successfully"
# Add sqlcmd to PATH for current session
export PATH="$PATH:/opt/mssql-tools18/bin"
- echo "/opt/mssql-tools18/bin" | sudo tee -a /etc/environment
- echo "PATH=$PATH:/opt/mssql-tools18/bin" >> "$GITHUB_ENV"
+ echo "PATH=$PATH" >> "$GITHUB_ENV"
else
echo "::warning::mssql-tools18 installation failed, trying mssql-tools"
# Fallback to older version if needed
- sudo apt-get install -y mssql-tools
+ sudo -E apt-get install -y mssql-tools
export PATH="$PATH:/opt/mssql-tools/bin"
- echo "/opt/mssql-tools/bin" | sudo tee -a /etc/environment
- echo "PATH=$PATH:/opt/mssql-tools/bin" >> "$GITHUB_ENV"
+ echo "PATH=$PATH" >> "$GITHUB_ENV"
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Install SQL Server Command Line Tools | |
| shell: bash | |
| run: | | |
| echo "Installing SQL Server command line tools (sqlcmd)..." | |
| echo "::group::Install mssql-tools" | |
| # Install the Microsoft SQL Server command-line tools | |
| if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then | |
| echo "Microsoft repository not found, adding it..." | |
| sudo install -m 0755 -d /etc/apt/keyrings | |
| curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg >/dev/null | |
| sudo chmod a+r /etc/apt/keyrings/microsoft.gpg | |
| DISTRO_CODENAME="$(lsb_release -cs)" | |
| echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/microsoft-ubuntu-${DISTRO_CODENAME}-prod ${DISTRO_CODENAME} main" | sudo tee "/etc/apt/sources.list.d/microsoft-${DISTRO_CODENAME}-prod.list" >/dev/null | |
| sudo apt-get update | |
| fi | |
| # Accept EULA for mssql-tools (required for non-interactive installation) | |
| echo 'mssql-tools accept-eula/accept-eula-license boolean true' | sudo debconf-set-selections | |
| # Install mssql-tools18 (latest version with enhanced security) | |
| if sudo apt-get install -y mssql-tools18; then | |
| echo "mssql-tools18 installed successfully" | |
| # Add sqlcmd to PATH for current session | |
| export PATH="$PATH:/opt/mssql-tools18/bin" | |
| echo "/opt/mssql-tools18/bin" | sudo tee -a /etc/environment | |
| echo "PATH=$PATH:/opt/mssql-tools18/bin" >> "$GITHUB_ENV" | |
| else | |
| echo "::warning::mssql-tools18 installation failed, trying mssql-tools" | |
| # Fallback to older version if needed | |
| sudo apt-get install -y mssql-tools | |
| export PATH="$PATH:/opt/mssql-tools/bin" | |
| echo "/opt/mssql-tools/bin" | sudo tee -a /etc/environment | |
| echo "PATH=$PATH:/opt/mssql-tools/bin" >> "$GITHUB_ENV" | |
| fi | |
| # Verify sqlcmd installation | |
| which sqlcmd || echo "::warning::sqlcmd not found in PATH" | |
| echo "::endgroup::" | |
| - name: Install SQL Server Command Line Tools | |
| shell: bash | |
| run: | | |
| echo "Installing SQL Server command line tools (sqlcmd)..." | |
| echo "::group::Install mssql-tools" | |
| # Install the Microsoft SQL Server command-line tools | |
| if ! grep -q "packages.microsoft.com" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then | |
| echo "Microsoft repository not found, adding it..." | |
| sudo install -m 0755 -d /etc/apt/keyrings | |
| curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg >/dev/null | |
| sudo chmod a+r /etc/apt/keyrings/microsoft.gpg | |
| DISTRO_CODENAME="$(lsb_release -cs)" | |
| echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/microsoft-ubuntu-${DISTRO_CODENAME}-prod ${DISTRO_CODENAME} main" | sudo tee "/etc/apt/sources.list.d/microsoft-${DISTRO_CODENAME}-prod.list" >/dev/null | |
| sudo apt-get update | |
| fi | |
| # Install mssql-tools18 (noninteractive) | |
| export DEBIAN_FRONTEND=noninteractive | |
| export ACCEPT_EULA=Y | |
| if sudo -E apt-get install -y mssql-tools18; then | |
| echo "mssql-tools18 installed successfully" | |
| # Add sqlcmd to PATH for current session | |
| export PATH="$PATH:/opt/mssql-tools18/bin" | |
| echo "PATH=$PATH" >> "$GITHUB_ENV" | |
| else | |
| echo "::warning::mssql-tools18 installation failed, trying mssql-tools" | |
| # Fallback to older version if needed | |
| sudo -E apt-get install -y mssql-tools | |
| export PATH="$PATH:/opt/mssql-tools/bin" | |
| echo "PATH=$PATH" >> "$GITHUB_ENV" | |
| fi | |
| # Verify sqlcmd installation | |
| which sqlcmd || echo "::warning::sqlcmd not found in PATH" | |
| echo "::endgroup::" |
🤖 Prompt for AI Agents
.github/workflows/copilot-setup-steps.yml around lines 246-285: the mssql-tools
install block needs non-interactive EULA acceptance and correct PATH handling;
set environment variables ACCEPT_EULA=Y and DEBIAN_FRONTEND=noninteractive when
invoking apt-get/install commands (or export them in the shell block) so
installs never prompt, remove writing a bare path line to /etc/environment (it's
not valid), keep exporting the tool directory to PATH for the current session
(export PATH="$PATH:/opt/mssql-tools18/bin" or /opt/mssql-tools/bin) and only
append the path to GITHUB_ENV (echo "PATH=$PATH:/opt/mssql-tools18/bin" >>
"$GITHUB_ENV") so subsequent steps see it; leave the fallback logic for
mssql-tools but apply the same noninteractive env and GITHUB_ENV append there as
well.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2286 +/- ##
====================================
Coverage 94% 94%
====================================
Files 149 149
Lines 9163 9163
====================================
Hits 8687 8687
Misses 476 476
🚀 New features to boost your workflow:
|
|
Closing this as this would be to limiting for the integration tests, but in the future we could add a job that actually run commands and class-based resources against SQL Server in a linux container. |
Pull Request (PR) description
testing and development assistance with Docker containerized SQL Server 2022
instances.
This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is