Skip to content
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

Support codespace development #1434

Merged
merged 4 commits into from Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .devcontainer/Dockerfile
@@ -0,0 +1,15 @@
# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster
ARG VARIANT=1.17-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}

# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>



43 changes: 43 additions & 0 deletions .devcontainer/devcontainer.json
@@ -0,0 +1,43 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/python-3-postgres
// Update the VARIANT arg in docker-compose.yml to pick a Python version
{
"name": "sqlc",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",

"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Set *default* container specific settings.json values on container create.
"settings": {
"sqltools.connections": [{
"name": "Container database",
"driver": "PostgreSQL",
"previewLimit": 50,
"server": "postgresql",
"port": 5432,
"database": "dinotest",
"username": "postgres",
"password": "mysecretpassword"
}],
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg",
"mtxr.sqltools-driver-mysql"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [5000, 5432],

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
46 changes: 46 additions & 0 deletions .devcontainer/docker-compose.yml
@@ -0,0 +1,46 @@
version: '3.8'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
VARIANT: 1.17-bullseye

volumes:
- ..:/workspace:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

environment:
PG_HOST: postgresql
PG_USER: postgres
PG_DATABASE: dinotest
PG_PASSWORD: mysecretpassword
MYSQL_DATABASE: dinotest
MYSQL_HOST: mysql
MYSQL_ROOT_PASSWORD: mysecretpassword

mysql:
image: "mysql:8"
ports:
- "3306:3306"
restart: unless-stopped
environment:
MYSQL_DATABASE: dinotest
MYSQL_ROOT_PASSWORD: mysecretpassword

postgresql:
image: "postgres:13"
ports:
- "5432:5432"
restart: unless-stopped
environment:
POSTGRES_DB: dinotest
POSTGRES_PASSWORD: mysecretpassword
POSTGRES_USER: postgres

# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
10 changes: 9 additions & 1 deletion Makefile
@@ -1,4 +1,4 @@
.PHONY: build test test-examples regen start psql mysqlsh
.PHONY: build build-endtoend test test-ci test-examples test-endtoend regen start psql mysqlsh

build:
go build ./...
Expand All @@ -9,6 +9,14 @@ test:
test-examples:
go test --tags=examples ./...

build-endtoend:
cd ./internal/endtoend/testdata && go build ./...

test-endtoend:
cd ./internal/endtoend/testdata && go test ./...

test-ci: test-examples build-endtoend test-endtoend

regen: sqlc-dev
go run ./scripts/regenerate/

Expand Down