Skip to content

feat: add devcontainer for VS Code and GitHub Codespaces#317

Open
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
dlevy-msft-sql:devcontainer-clean
Open

feat: add devcontainer for VS Code and GitHub Codespaces#317
dlevy-msft-sql wants to merge 1 commit intomicrosoft:mainfrom
dlevy-msft-sql:devcontainer-clean

Conversation

@dlevy-msft-sql
Copy link

@dlevy-msft-sql dlevy-msft-sql commented Feb 2, 2026

feat: Add devcontainer for VS Code and GitHub Codespaces

Summary

This PR adds a comprehensive development container that makes it easy for anyone to contribute to go-mssqldb. Just open the repo and start coding - SQL Server is ready!

What's Included

Component Details
Go 1.24 with gopls, delve debugger, staticcheck, golangci-lint
SQL Server 2025 Developer Edition with health checks
SQL Tools go-sqlcmd - uses this driver (dogfooding! 🐕)
VS Code Extensions Go, MSSQL, Docker, GitHub Copilot, GitLens
Features Docker-in-Docker, GitHub CLI
Testing Environment variables pre-configured for integration tests

How to Use

🖥️ VS Code

  1. Install the Dev Containers extension
  2. Open this repo and click "Reopen in Container"
  3. Run go test ./... — SQL Server is ready!

☁️ GitHub Codespaces

  1. Click the Code button → CodespacesCreate codespace
  2. Wait for the environment to start
  3. Run go test ./...

Helpful Aliases

Once inside the container, these aliases are available:

gtest        # Run all tests
gtest-unit   # Run unit tests only (no SQL Server required)
gtest-short  # Run short tests
gbuild       # Build all packages
gfmt         # Format code
gvet         # Run go vet
glint        # Run golangci-lint
sql          # Connect to SQL Server (go-sqlcmd)
test-db      # Test database connection

Discoverability

  • ✅ Added "Open in Dev Containers" badge to README
  • ✅ Added Development section to README with quick start guide
  • ✅ GitHub automatically shows Codespaces button when .devcontainer exists

Files Added

.devcontainer/
├── devcontainer.json      # Main VS Code configuration
├── docker-compose.yml     # Go + SQL Server 2025 containers
├── Dockerfile             # Go dev environment with tools
├── post-create.sh         # Setup script with aliases
├── README.md              # Detailed documentation
└── mssql/
    └── setup.sql          # Database initialization (creates GoDriverTest)

.dockerignore              # Build optimization

Screenshots

After opening in Dev Container, developers see:

=== go-mssqldb Development Container Setup ===

📦 Downloading Go dependencies...
🔨 Verifying build...
🔄 Verifying SQL Server connection using go-sqlcmd (uses this driver!)...
✅ SQL Server is ready!
📋 Running setup.sql...

=== Setup Complete! ===

🔧 go-sqlcmd is installed and uses THIS driver (dogfooding!)

🔗 SQL Server Connection:
   Server: localhost,1433
   User: sa
   Database: master

🧪 Environment variables are pre-configured for tests.
   Run 'go test ./...' to execute the full test suite.

Why This Matters

  • Lowers barrier to entry for new contributors
  • Consistent environment across all developers
  • No manual SQL Server setup required
  • Works on any OS with Docker support
  • Instant productivity - clone and code

@dlevy-msft-sql dlevy-msft-sql self-assigned this Feb 2, 2026
@dlevy-msft-sql dlevy-msft-sql added enhancement New feature or request Size: S Small issue (less than one week effort, less than 250 lines of code) in-review labels Feb 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive development container support for VS Code and GitHub Codespaces, making it easier for contributors to set up a complete development environment with Go and SQL Server pre-configured.

Changes:

  • Adds devcontainer configuration with Go 1.24, SQL Server, and pre-installed development tools
  • Includes automated setup scripts, helpful aliases, and pre-configured environment variables for integration tests
  • Updates README with a Development section explaining how to use the devcontainer
  • Adds .dockerignore for optimized container builds

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.devcontainer/devcontainer.json Main devcontainer configuration with VS Code extensions, settings, and environment variables
.devcontainer/docker-compose.yml Orchestrates Go development container with SQL Server 2025 sidecar
.devcontainer/Dockerfile Defines Go 1.24 development image with tools (go-sqlcmd, golangci-lint, delve, etc.)
.devcontainer/post-create.sh Post-creation setup script that downloads dependencies, waits for SQL Server, and creates helpful aliases
.devcontainer/mssql/setup.sql SQL initialization script that creates test database and sample tables
.devcontainer/README.md Comprehensive documentation for using and customizing the devcontainer
.dockerignore Excludes unnecessary files from Docker build context
README.md Adds Development section with quick start guide for devcontainers

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 13 comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

dlevy-msft-sql added a commit to dlevy-msft-sql/go-sqlcmd that referenced this pull request Feb 2, 2026
Dockerfile:
- Fix image tag format: 1.24-bookworm (not 1-1.24-bookworm)

docker-compose.yml:
- Add both SA_PASSWORD and MSSQL_SA_PASSWORD for CI compatibility
  (different SQL Server images use different env vars)

post-create.sh:
- Add dynamic workspace detection with robust fallback
- Handles different clone names (go-sqlcmd, fork names, etc.)

setup.sql:
- Add TRY/CATCH error handling for contained database operations
- Prevents script failure on unsupported SQL Server configurations

.dockerignore:
- Add .devcontainer/ to reduce build context size

Reference: microsoft/go-mssqldb#317
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.46%. Comparing base (f49ac9b) to head (72cdb74).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
+ Coverage   75.41%   78.46%   +3.05%     
==========================================
  Files          34       34              
  Lines        6597     6598       +1     
==========================================
+ Hits         4975     5177     +202     
+ Misses       1335     1139     -196     
+ Partials      287      282       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dlevy-msft-sql dlevy-msft-sql added Priority: 0 Breaking things; must fix immediately Size: M Medium issue (two-three weeks effort, less than 1000 lines of code) Priority: 1 High priority/impact and removed Size: S Small issue (less than one week effort, less than 250 lines of code) Priority: 0 Breaking things; must fix immediately labels Feb 2, 2026
@dlevy-msft-sql dlevy-msft-sql changed the title feat: Add devcontainer for VS Code and GitHub Codespaces feat: add devcontainer for VS Code and GitHub Codespaces Feb 5, 2026
- Go 1.24 with gopls, delve, staticcheck, golangci-lint
- SQL Server 2025 (Developer Edition) with health checks
- go-sqlcmd installed (uses go-mssqldb - dogfooding!)
- Pre-configured VS Code extensions (Go, MSSQL, Copilot, etc.)
- Environment variables pre-set for integration tests
- Add Development section to README with quick start guide
- Add 'Open in Dev Containers' badge to README
- Update CI workflow with improved SQL Server readiness checks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Priority: 1 High priority/impact Size: M Medium issue (two-three weeks effort, less than 1000 lines of code)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants