Skip to content

Add Docker setup and SQL Server container support to Copilot workflow#2286

Closed
johlju wants to merge 1 commit intodsccommunity:mainfrom
johlju:f/copilot-setup-with-sql-install-container
Closed

Add Docker setup and SQL Server container support to Copilot workflow#2286
johlju wants to merge 1 commit intodsccommunity:mainfrom
johlju:f/copilot-setup-with-sql-install-container

Conversation

@johlju
Copy link
Copy Markdown
Member

@johlju johlju commented Sep 20, 2025

Pull Request (PR) description

  • Added SQL Server on Linux container support to AI workflow for cross-platform
    testing and development assistance with Docker containerized SQL Server 2022
    instances.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 20, 2025

Walkthrough

Introduces 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

Cohort / File(s) Summary
GitHub Actions workflow: Docker + SQL Server setup
.github/workflows/copilot-setup-steps.yml
Adds steps to install/start Docker, create docker group membership, verify Docker; pull/run SQL Server 2022 Linux container with volume and EULA; install mssql-tools18 with fallback; retry-based sqlcmd connectivity checks, DB creation test, diagnostics on failure; duplicates the entire sequence twice.
Changelog update
CHANGELOG.md
Notes addition of SQL Server on Linux container support to AI workflow; removes mention of Get-SqlDscManagedComputer integration tests.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change—adding Docker setup and SQL Server container support to the Copilot workflow—and directly reflects the primary modifications in the workflow file described in the changeset.
Description Check ✅ Passed The PR description clearly states the addition of SQL Server on Linux container support to the AI/Copilot workflow and uses the standard PR template and task checklist, which is directly related to the workflow and changelog changes in the diff.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $USER won’t take effect in this session; drop it.
  • Prefer docker info over pulling hello-world to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 62cb0b8 and 0722883.

📒 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 MD013 rule 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 section

Always 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 Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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

Comment on lines +187 to +245
- 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::"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
- 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).

Comment on lines +246 to +285
- 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::"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix mssql-tools install: noninteractive EULA + correct PATH handling; don’t write raw path to /etc/environment.

  • Use ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive to 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.

Suggested change
- 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
Copy link
Copy Markdown

codecov Bot commented Sep 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (52e707f) to head (0722883).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #2286   +/-   ##
====================================
  Coverage    94%     94%           
====================================
  Files       149     149           
  Lines      9163    9163           
====================================
  Hits       8687    8687           
  Misses      476     476           
Flag Coverage Δ
unit 94% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johlju johlju added needs review The pull request needs a code review. and removed needs review The pull request needs a code review. labels Sep 21, 2025
@johlju
Copy link
Copy Markdown
Member Author

johlju commented Sep 21, 2025

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.

@johlju johlju closed this Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant