-
Notifications
You must be signed in to change notification settings - Fork 227
Add SQL Server installation steps to Copilot setup workflow #2285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -189,6 +189,129 @@ jobs: | |||||||||||||
| Write-Host "Running DSCv3 to validate correct operation..." | ||||||||||||||
| dsc --version | ||||||||||||||
|
|
||||||||||||||
| - name: Install SQL Server on Ubuntu | ||||||||||||||
| shell: bash | ||||||||||||||
| run: | | ||||||||||||||
| echo "Installing SQL Server 2022 on Ubuntu..." | ||||||||||||||
|
|
||||||||||||||
| # Import the public repository GPG keys | ||||||||||||||
| echo "::group::Import Microsoft GPG keys" | ||||||||||||||
| curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Register the SQL Server Ubuntu repository | ||||||||||||||
| echo "::group::Register SQL Server repository" | ||||||||||||||
| sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list)" -y | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Update package list and install SQL Server | ||||||||||||||
| echo "::group::Install SQL Server package" | ||||||||||||||
| sudo apt-get update | ||||||||||||||
| sudo apt-get install -y mssql-server | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Configure SQL Server with mssql-conf (unattended setup) | ||||||||||||||
| echo "::group::Configure SQL Server" | ||||||||||||||
| sudo MSSQL_SA_PASSWORD='P@ssw0rd1' \ | ||||||||||||||
| MSSQL_PID='Developer' \ | ||||||||||||||
| MSSQL_TCP_PORT=1433 \ | ||||||||||||||
| ACCEPT_EULA='Y' \ | ||||||||||||||
| /opt/mssql/bin/mssql-conf -n setup | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Verify SQL Server is running | ||||||||||||||
| echo "::group::Verify SQL Server status" | ||||||||||||||
| sudo systemctl status mssql-server --no-pager --lines=5 | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| echo "SQL Server 2022 installation completed successfully" | ||||||||||||||
|
Comment on lines
+192
to
+227
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify SQL Server 2022 compatibility with Ubuntu in GitHub Actions runners. The workflow hardcodes the Ubuntu 20.04 repository URLs and configuration (lines 204, 241) while GitHub Actions ubuntu-latest runners typically use Ubuntu 22.04 or newer. This mismatch could cause installation failures or use of incompatible packages. 🌐 Web query: 💡 Result: Short answer: ubuntu-latest pointed to Ubuntu 22.04 for most of 2024. Ubuntu 24.04 was published as an image in May 2024 and GitHub began rolling the ubuntu-latest label to 24.04 on Dec 5, 2024 (rollout completed Jan 17, 2025). [1][2][3] Sources:
Fix hardcoded Microsoft SQL Server apt repo (ubuntu/20.04) — ensure runner OS and repo match The workflow registers packages.microsoft.com/config/ubuntu/20.04/... but github's ubuntu-latest was 22.04 for most of 2024 and rolled to 24.04 (rollout started Dec 5, 2024; completed Jan 17, 2025). Using a 20.04 repo on 22.04/24.04 runners can break apt and mssql-server installation.
Location: .github/workflows/copilot-setup-steps.yml lines 192-227 (add-apt-repository wget for packages.microsoft.com/config/ubuntu/20.04/...). |
||||||||||||||
|
|
||||||||||||||
| - name: Install SQL Server Command Line Tools | ||||||||||||||
| shell: bash | ||||||||||||||
| run: | | ||||||||||||||
| echo "Installing SQL Server command line tools..." | ||||||||||||||
|
|
||||||||||||||
| # Import Microsoft GPG keys (if not already done) | ||||||||||||||
| echo "::group::Import Microsoft GPG keys for tools" | ||||||||||||||
| curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc > /dev/null | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Register Microsoft Ubuntu repository for tools | ||||||||||||||
| echo "::group::Register Microsoft tools repository" | ||||||||||||||
| curl -fsSL https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Install mssql-tools18 and unixODBC | ||||||||||||||
| echo "::group::Install mssql-tools18" | ||||||||||||||
| sudo apt-get update | ||||||||||||||
| sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18 unixodbc-dev | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Add tools to PATH | ||||||||||||||
| echo "::group::Configure PATH for SQL tools" | ||||||||||||||
| echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc | ||||||||||||||
| echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bash_profile | ||||||||||||||
| echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
|
||||||||||||||
| # Test sqlcmd connectivity | ||||||||||||||
| echo "::group::Test SQL Server connectivity" | ||||||||||||||
| /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'P@ssw0rd1' -Q "SELECT @@VERSION" -b | ||||||||||||||
| echo "::endgroup::" | ||||||||||||||
|
Comment on lines
+259
to
+260
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Password exposed in command line and logs. The SA password is passed directly to sqlcmd in the command line, which will be visible in workflow logs and potentially in process lists. Use environment variables or input redirection to avoid password exposure: - /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'P@ssw0rd1' -Q "SELECT @@VERSION" -b
+ # Set password as environment variable to avoid command line exposure
+ export SQLCMDPASSWORD='$SA_PASSWORD'
+ /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -Q "SELECT @@VERSION" -b
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| echo "SQL Server command line tools installed successfully" | ||||||||||||||
|
|
||||||||||||||
| - name: Configure SQL Server Environment for Integration Tests | ||||||||||||||
| shell: pwsh | ||||||||||||||
| run: | | ||||||||||||||
| Write-Host "Configuring SQL Server environment for SqlServerDsc integration tests..." | ||||||||||||||
|
|
||||||||||||||
| # Set SqlServerDsc CI environment variable | ||||||||||||||
| Write-Host "Setting SqlServerDsc CI environment variable..." | ||||||||||||||
| $env:SqlServerDscCI = $true | ||||||||||||||
| echo "SqlServerDscCI=true" >> $env:GITHUB_ENV | ||||||||||||||
|
|
||||||||||||||
| # Configure SQL Server connection parameters for Linux | ||||||||||||||
| Write-Host "Setting SQL Server connection parameters for integration tests..." | ||||||||||||||
|
|
||||||||||||||
| # Set SA password for integration tests | ||||||||||||||
| $env:SQL_SA_PASSWORD = 'P@ssw0rd1' | ||||||||||||||
| echo "SQL_SA_PASSWORD=P@ssw0rd1" >> $env:GITHUB_ENV | ||||||||||||||
|
Comment on lines
+278
to
+279
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: SA password exposed in environment variables. Setting the SA password as an environment variable (line 279) makes it accessible to all subsequent steps and visible in the GitHub Actions environment, which poses a security risk. Consider using GitHub secrets or a more secure approach: - # Set SA password for integration tests
- $env:SQL_SA_PASSWORD = 'P@ssw0rd1'
- echo "SQL_SA_PASSWORD=P@ssw0rd1" >> $env:GITHUB_ENV
+ # Use the same password generated during installation
+ $env:SQL_SA_PASSWORD = $env:SA_PASSWORD
+ echo "::add-mask::$($env:SQL_SA_PASSWORD)"
+ echo "SQL_SA_PASSWORD=$($env:SQL_SA_PASSWORD)" >> $env:GITHUB_ENV📝 Committable suggestion
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| Write-Host "SQL Server will use the default instance (MSSQLSERVER)" | ||||||||||||||
| Write-Host "This is because SQL Server on Linux does not support named instances" | ||||||||||||||
|
|
||||||||||||||
| # Test SQL Server connectivity using SqlServer module | ||||||||||||||
| Write-Host "Testing SQL Server connectivity using PowerShell SqlServer module..." | ||||||||||||||
| try { | ||||||||||||||
| # Connect to default instance on localhost | ||||||||||||||
| $connectionString = "Server=localhost;Database=master;User Id=sa;Password=P@ssw0rd1;TrustServerCertificate=true;Encrypt=false;" | ||||||||||||||
| $connection = New-Object System.Data.SqlClient.SqlConnection($connectionString) | ||||||||||||||
|
Comment on lines
+288
to
+289
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security concern: Password in connection string. The connection string contains a hardcoded password that will be visible in logs and potentially stored in memory. Use integrated authentication or a more secure connection approach: - $connectionString = "Server=localhost;Database=master;User Id=sa;Password=P@ssw0rd1;TrustServerCertificate=true;Encrypt=false;"
+ $connectionString = "Server=localhost;Database=master;User Id=sa;Password=$($env:SQL_SA_PASSWORD);TrustServerCertificate=true;Encrypt=false;"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| $connection.Open() | ||||||||||||||
|
|
||||||||||||||
| $command = $connection.CreateCommand() | ||||||||||||||
| $command.CommandText = "SELECT @@VERSION, @@SERVERNAME, SERVERPROPERTY('Edition')" | ||||||||||||||
| $reader = $command.ExecuteReader() | ||||||||||||||
|
|
||||||||||||||
| if ($reader.Read()) { | ||||||||||||||
| Write-Host "SQL Server Version: $($reader[0])" | ||||||||||||||
| Write-Host "Server Name: $($reader[1])" | ||||||||||||||
| Write-Host "Edition: $($reader[2])" | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| $reader.Close() | ||||||||||||||
| $connection.Close() | ||||||||||||||
|
|
||||||||||||||
| Write-Host "SQL Server connectivity test successful!" | ||||||||||||||
| Write-Host "Integration tests will use the default instance (MSSQLSERVER)" | ||||||||||||||
| } | ||||||||||||||
| catch { | ||||||||||||||
| Write-Error "Failed to connect to SQL Server: $($_.Exception.Message)" | ||||||||||||||
| exit 1 | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| Write-Host "SQL Server environment configuration complete" | ||||||||||||||
|
|
||||||||||||||
| - name: Install .NET Tools | ||||||||||||||
| shell: pwsh | ||||||||||||||
| run: | | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security concern: Hardcoded SA password in workflow.
The SQL Server SA password is hardcoded as 'P@ssw0rd1' directly in the workflow file. This creates several security issues:
Consider using GitHub secrets or environment variables for sensitive credentials:
Or generate a random password at runtime:
📝 Committable suggestion
🤖 Prompt for AI Agents