From bd9d2b848c0d389a42e9211186ef0fed83ec411e Mon Sep 17 00:00:00 2001 From: DJ Schleen Date: Thu, 29 Feb 2024 15:44:07 -0700 Subject: [PATCH] Extended devcontainer functionality (#205) * configuration of nerdfont in devcontainer --- .devcontainer/devcontainer.json | 75 ++++++++++++++++++++++++++++++--- .devcontainer/post-create.sh | 6 +++ .gitignore | 5 ++- Makefile | 4 +- 4 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 .devcontainer/post-create.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1ca0923..01962fd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,69 @@ { - "image": "mcr.microsoft.com/devcontainers/universal:2", - "features": { - "ghcr.io/devcontainers/features/aws-cli:1": {}, - "ghcr.io/devcontainers/features/go:1": {}, - "ghcr.io/devcontainers-contrib/features/starship:1": {} - } -} + "name": "devcontainer-test", + "image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm", + "features": { + "ghcr.io/devcontainers-contrib/features/starship:1": {}, + "ghcr.io/azutake/devcontainer-features/go-packages-install:0": { + "packages": [ + "github.com/devops-kung-fu/hookz@latest", + "github.com/jandelgado/gcov2lcov@latest", + "github.com/kisielk/errcheck@latest", + "github.com/fzipp/gocyclo/cmd/gocyclo@latest", + "golang.org/x/vuln/cmd/govulncheck@latest", + "honnef.co/go/tools/cmd/staticcheck@latest" + ] + } + }, + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.fontFamily": "Cascadia Code", + "editor.formatOnSave": true, + "go.buildTags": "", + "go.toolsEnvVars": { + "CGO_ENABLED": "0" + }, + "go.useLanguageServer": true, + "go.testEnvVars": { + "CGO_ENABLED": "1" + }, + "go.testFlags": [ + "-v", + "-race" + ], + "go.testTimeout": "10s", + "go.coverOnSingleTest": true, + "go.coverOnSingleTestFile": true, + "go.coverOnTestPackage": true, + "go.lintTool": "golangci-lint", + "go.lintOnSave": "package", + "[go]": { + "editor.codeActionsOnSave": { + "source.organizeImports": "always" + } + }, + "markiscodecoverage.coverageThreshold": 95, + "markiscodecoverage.enableOnStartup": true, + "markiscodecoverage.searchCriteria": "*.lcov*" + }, + "extensions": [ + "ms-vscode.go", + "golang.go", + "github.vscode-pull-request-github", + "github.vscode-github-actions", + "aleksandra.go-group-imports", + "oderwat.indent-rainbow", + "yzhang.markdown-all-in-one", + "quicktype.quicktype", + "jebbs.plantuml", + "foxundermoon.shell-format", + "ahebrank.yaml2json", + "amazonwebservices.aws-toolkit-vscode", + "markis.code-coverage", + //"defaltd.go-coverage-viewer", + "Gruntfuggly.todo-tree" // Highlights TODO comments" + ] + } + }, + "postCreateCommand": "/usr/bin/zsh ./.devcontainer/post-create.sh > ~/post-create.log" +} \ No newline at end of file diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 0000000..778912a --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,6 @@ +mkdir -p $HOME/.local/share/fonts +wget https://github.com/ryanoasis/nerd-fonts/releases/latest/download/CascadiaCode.zip +unzip CascadiaCode.zip -d $HOME/.local/share/fonts +rm CascadiaCode.zip + +go mod download && go mod tidy diff --git a/.gitignore b/.gitignore index f1e4b6d..6295d95 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,7 @@ bomber /rest *-results.html -coverage.html \ No newline at end of file +coverage.html +coverage.lcov + +*.log diff --git a/Makefile b/Makefile index 2a9251a..e575e11 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,10 @@ build: ## Builds the application go build test: ## Runs tests and coverage - go test -v -coverprofile=coverage.out ./... && go tool cover -func=coverage.out + go test -v -coverprofile=coverage.out ./... + go tool cover -func=coverage.out go tool cover -html=coverage.out -o coverage.html + gcov2lcov -infile=coverage.out -outfile=coverage.lcov check: build ## Tests the pre-commit hooks if they exist hookz reset --verbose --debug --verbose-output