From 903e65ae8d3e5f65d6b05ff411fbd99b114c5db4 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 13 Nov 2022 09:09:31 +1100 Subject: [PATCH 1/2] add devcontainer folder --- .devcontainer/Dockerfile | 13 +++++++ .devcontainer/devcontainer.json | 68 +++++++++++++++++++++++++++++++++ .gitignore | 1 + 3 files changed, 82 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..03c43d411 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,13 @@ +# adapted from https://github.com/devcontainers/images/blob/main/src/go/.devcontainer/Dockerfile + +# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.19, 1.18, 1-bullseye, 1.19-bullseye, 1.18-bullseye, 1-buster, 1.19-buster, 1.18-buster +ARG VARIANT=1-bullseye +FROM golang:${VARIANT} + +RUN go install mvdan.cc/gofumpt@latest +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0 +RUN golangci-lint --version + +# [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 000000000..3c8537052 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,68 @@ +// adapted from https://github.com/devcontainers/images/blob/main/src/go/.devcontainer/devcontainer.json +{ + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:1": { + "installZsh": "true", + "username": "vscode", + "uid": "1000", + "gid": "1000", + "upgradePackages": "true" + }, + "ghcr.io/devcontainers/features/go:1": { + "version": "none" + }, + "ghcr.io/devcontainers/features/git:1": { + "version": "latest", + "ppa": "false" + } + }, + "overrideFeatureInstallOrder": [ + "ghcr.io/devcontainers/features/common-utils" + ], + // not sure if we actually need these + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "[go]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "go.lintTool": "golangci-lint", + "gopls": { + "formatting.gofumpt": true, + "usePlaceholders": false // add parameter placeholders when completing a function + }, + "files.eol": "\n" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go" + ] + } + }, + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + + // See https://www.kenmuse.com/blog/avoiding-dubious-ownership-in-dev-containers/ + "postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}", + + // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.gitignore b/.gitignore index e9ed453a2..9e9059b19 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ lazygit.exe !.circleci/ !.github/ !.vscode/ +!.devcontainer/ # these are for our integration tests !.git_keep From fb170b55a216c9ebb2d107215953a7cf938af702 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 13 Nov 2022 11:31:04 +1100 Subject: [PATCH 2/2] add some tasks --- .vscode/tasks.json | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..6b6943b12 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,52 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Generate cheatsheet", + "type": "process", + "command": "go run scripts/cheatsheet/main.go " + }, + { + "label": "Bump gocui", + "type": "shell", + "command": "./scripts/bump_gocui.sh" + }, + { + "label": "Run current file integration test", + "type": "shell", + "command": "go run cmd/integration_test/main.go cli ${relativeFile}", + "problemMatcher": [], + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "label": "Run current file integration test (slow)", + "type": "shell", + "command": "go run cmd/integration_test/main.go cli --slow ${relativeFile}", + "problemMatcher": [], + "group": { + "kind": "test", + } + }, + { + "label": "Run current file integration test (sandbox)", + "type": "shell", + "command": "go run cmd/integration_test/main.go cli --sandbox ${relativeFile}", + "problemMatcher": [], + "group": { + "kind": "test", + } + } + ], + "inputs": [ + { + "id": "testname", + "description": "Test name/path (e.g. 'commit/commit'):", + "type": "promptString" + }, + ] +}