diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..476cde0c24 --- /dev/null +++ b/.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 + + + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..18fd3dc8da --- /dev/null +++ b/.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" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000000..e305a3485c --- /dev/null +++ b/.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.) diff --git a/Makefile b/Makefile index 392ec3fd6a..207b9a147c 100644 --- a/Makefile +++ b/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 ./... @@ -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/