Add SQL Server e2e test suite with containerized instance #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| httpbin: | |
| image: mccutchen/go-httpbin:latest | |
| ports: | |
| - 8888:8080 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.25' | |
| - name: Run CI | |
| env: | |
| HTTPBIN_URL: http://localhost:8888 | |
| DB_PATH: /tmp/taskapp-test.db | |
| run: make ci | |
| - name: Build | |
| run: make build | |
| - name: Smoke test - version | |
| run: ./sql-proxy -version | |
| - name: Smoke test - validate config | |
| run: ./sql-proxy -validate -config testdata/config.ci.yaml | |
| test-mysql: | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: testpass | |
| MYSQL_DATABASE: testdb | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping -h 127.0.0.1" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| httpbin: | |
| image: mccutchen/go-httpbin:latest | |
| ports: | |
| - 8888:8080 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.25' | |
| - name: Run MySQL integration tests | |
| env: | |
| MYSQL_HOST: 127.0.0.1 | |
| MYSQL_PORT: 3306 | |
| MYSQL_USER: root | |
| MYSQL_PASSWORD: testpass | |
| MYSQL_DATABASE: testdb | |
| run: go test -v -run "MySQL" ./internal/db/ | |
| - name: Build | |
| run: go build -o sql-proxy . | |
| - name: Validate MySQL example configs | |
| env: | |
| MYSQL_PASSWORD: testpass | |
| run: | | |
| for f in examples/mysql/*.yaml; do | |
| echo "=== $f ===" | |
| ./sql-proxy -validate -config "$f" || exit 1 | |
| done | |
| - name: Run MySQL e2e tests | |
| env: | |
| MYSQL_HOST: 127.0.0.1 | |
| MYSQL_PORT: 3306 | |
| MYSQL_USER: root | |
| MYSQL_PASSWORD: testpass | |
| MYSQL_DATABASE: testdb | |
| HTTPBIN_URL: http://localhost:8888 | |
| TASKAPP_CONFIG: testdata/taskapp-mysql.yaml | |
| run: ./e2e/taskapp_test.sh | |
| - name: Show MySQL e2e server logs | |
| if: always() | |
| run: cat /tmp/e2e-server.log 2>/dev/null || true | |
| test-sqlserver: | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| services: | |
| sqlserver: | |
| image: mcr.microsoft.com/mssql/server:2022-latest | |
| env: | |
| ACCEPT_EULA: "Y" | |
| MSSQL_SA_PASSWORD: "TestPass123!" | |
| ports: | |
| - 1433:1433 | |
| options: >- | |
| --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'TestPass123!' -C -Q 'SELECT 1'" | |
| --health-interval=10s | |
| --health-timeout=10s | |
| --health-retries=10 | |
| httpbin: | |
| image: mccutchen/go-httpbin:latest | |
| ports: | |
| - 8888:8080 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '1.25' | |
| - name: Create test database | |
| run: | | |
| docker exec $(docker ps -q --filter "ancestor=mcr.microsoft.com/mssql/server:2022-latest") \ | |
| /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'TestPass123!' -C \ | |
| -Q "CREATE DATABASE testdb" | |
| - name: Build | |
| run: go build -o sql-proxy . | |
| - name: Run SQL Server e2e tests | |
| env: | |
| MSSQL_HOST: 127.0.0.1 | |
| MSSQL_PORT: 1433 | |
| MSSQL_USER: sa | |
| MSSQL_PASSWORD: "TestPass123!" | |
| MSSQL_DATABASE: testdb | |
| HTTPBIN_URL: http://localhost:8888 | |
| TASKAPP_CONFIG: testdata/taskapp-sqlserver.yaml | |
| run: ./e2e/taskapp_test.sh | |
| - name: Show SQL Server e2e server logs | |
| if: always() | |
| run: cat /tmp/e2e-server.log 2>/dev/null || true |