-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: repository and source structure (PR #25)
## Feat Totally refactored (simpler source structure) * feat: new Docker image (more secure and light weight. Debian -> Alpine) * feat: codeQL-analysis.yml * feat: auto mod updater (auto PR on go.mod update) * feat: auto merge on go.mod update only (via mergify) * feat: include go.sum ## Fix * fix: #23 bad indentation * fix: golangci-lint warnings * fix: use latest goclangci-lint for lint check * fix: mergify.yml (deprecated "strict" config) * fix: redundant checks (only on push to main) * fix: remove bin directory ## Chore * Update platform-test.yaml * Update golangci-lint.yaml * Update version-tests.yaml --- Closing #23 Closing #24
- Loading branch information
Showing
54 changed files
with
1,935 additions
and
1,616 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,18 @@ | ||
# ============================================================================= | ||
# Pre Defined Variables | ||
# ============================================================================= | ||
# User provided Go version of Docker image | ||
ARG VARIANT | ||
# Default Go version. Choices: 1, 1.15, 1.14 | ||
ARG VARIANT_DEFAULT="1" | ||
# Default Language | ||
ARG LC_ALL_DEFAULT='en_US.utf8' | ||
ARG LANG_DEFAULT='en_US.utf8' | ||
# Default Node.js settings | ||
ARG INSTALL_NODE_DEFAULT="false" | ||
ARG NODE_VERSION_DEFAULT="lts/*" | ||
|
||
# ============================================================================= | ||
# Define Dockerfile. | ||
# | ||
# For image contents see: | ||
# https://github.com/microsoft/vscode-dev-containers/tree/v0.145.1/containers/go/.devcontainer/base.Dockerfile | ||
# ============================================================================= | ||
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT:-$VARIANT_DEFAULT} | ||
|
||
# Declare user args to receive while building an image. | ||
ARG LANG | ||
ARG LC_ALL | ||
ARG INSTALL_NODE | ||
ARG NODE_VERSION | ||
|
||
ENV \ | ||
LANG="${LANG:-$LANG_DEFAULT}" \ | ||
LC_ALL="${LC_ALL:-$LC_ALL_DEFAULT}" \ | ||
PATH="/usr/local/go/bin:${PATH}" \ | ||
# Enforce go module mode | ||
GO111MODULE='on' \ | ||
# Fix: https://github.com/microsoft/vscode-dev-containers/issues/51 | ||
SHELL="/bin/bash" | ||
|
||
#RUN localedef -f UTF-8 | ||
|
||
# [Option] Install Node.js | ||
ARG INSTALL_NODE="${INSTALL_NODE:-INSTALL_NODE_DEFAULT}" | ||
ARG NODE_VERSION="${NODE_VERSION:-NODE_VERSION_DEFAULT}" | ||
RUN if [ "${INSTALL_NODE}" = "true" ]; then \ | ||
echo 'Installing Node.js'; \ | ||
su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; \ | ||
fi | ||
|
||
# Bash script file to run right after the container was created. | ||
# See: "postCreateCommand" section in "devcontainer.json" and "postCreateCommand.sh" | ||
# file. | ||
COPY postCreateCommand.sh /postCreateCommand.sh | ||
|
||
# Install additional OS packages. | ||
RUN export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update \ | ||
&& apt-get -y upgrade \ | ||
&& apt-get -y install --no-install-recommends \ | ||
# The `rg` is a string search command from files. ex) rg ./cmd foo | ||
ripgrep \ | ||
# Directory tree viewer for documentation. | ||
tree \ | ||
# xz to untar xz compressed files | ||
xz-utils \ | ||
# missing locales | ||
locales | ||
|
||
# ShellCheck - Static analyzer and formatter for shell script | ||
# Note: Install the latest shellcheck. See: https://github.com/koalaman/shellcheck/issues/704 | ||
RUN url_download="https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.$(uname -m).tar.xz" \ | ||
&& path_tmp_dir="$(pwd)/tmp_install_dir" \ | ||
&& wget -P "${path_tmp_dir}/" "$url_download"\ | ||
&& tar xvf ${path_tmp_dir}/shellcheck* -C "${path_tmp_dir}/" \ | ||
&& cp "${path_tmp_dir}/shellcheck-latest/shellcheck" "$(dirname $(which tree))/shellcheck" \ | ||
# Smoke test | ||
&& shellcheck --version \ | ||
&& rm -r "$path_tmp_dir" | ||
|
||
# golangci-lint - The fast Go linters runner. Version=latest | ||
# binary will be installed under: $(go env GOPATH)/bin/golangci-lint | ||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin \ | ||
# Smoke test | ||
&& golangci-lint --version | ||
|
||
# Install anything else needed to go get | ||
RUN go get -u -v \ | ||
# gopls (language server) | ||
# `gopls` will install the packages in the URL below as well. | ||
# https://github.com/golang/vscode-go/blob/master/docs/tools.md#table-of-contents | ||
"golang.org/x/tools/gopls@latest" \ | ||
# go-carpet (Cover area checker) | ||
"github.com/msoap/go-carpet" \ | ||
# shfmt (shellformat) is a shell script linter | ||
"mvdan.cc/sh/v3/cmd/shfmt" \ | ||
# gp enables to share go files over Go Playground | ||
"github.com/tenntenn/goplayground/cmd/gp" \ | ||
# gomarkdoc generates documentation in markdown | ||
"github.com/princjef/gomarkdoc/cmd/gomarkdoc" \ | ||
#"github.com/rogpeppe/godef" \ | ||
# ------------------------------------------------------------------------- | ||
# irregular install (Download source and build) | ||
# ------------------------------------------------------------------------- | ||
&& cd "${GOPATH}/pkg/mod" \ | ||
&& go get -v -d \ | ||
# gocode and gocode-modules is no-good to install as module | ||
"github.com/stamblerre/gocode" \ | ||
# cobra (sub-command creation) | ||
"github.com/spf13/cobra" \ | ||
# gomock | ||
"github.com/golang/mock/gomock" \ | ||
# gocode and gocode-modules | ||
&& cd ${GOPATH}/pkg/mod/github.com/stamblerre/gocode* \ | ||
&& go build -o "${GOPATH}/bin/gocode-gomod" . \ | ||
# cobra command | ||
&& cd ${GOPATH}/pkg/mod/github.com/spf13/cobra*/cobra \ | ||
&& go build -o "${GOPATH}/bin/cobra" . \ | ||
# mockgen | ||
&& cd ${GOPATH}/pkg/mod/github.com/golang/mock*/mockgen \ | ||
&& go install \ | ||
# List bin files | ||
&& echo "- List dir: ${GOPATH}/bin" && ls -l "${GOPATH}/bin" | ||
|
||
# Miscellaneous | ||
RUN \ | ||
# Set path for go | ||
echo 'export PATH="/go/bin:/usr/local/go/bin:${PATH}"' >> "${HOME}/.bashrc" | ||
|
||
# [Optional] Uncomment this line to install global node packages. | ||
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1 | ||
# [Choice] https://github.com/KEINOS/VSCode-Dev-Container-Go/pkgs/container/vscode-dev-container-go | ||
ARG VARIANT="latest" | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Main Stage | ||
# ----------------------------------------------------------------------------- | ||
# ghcr.io/keinos/vscode-dev-container-go is an Alpine-based container image which | ||
# provides a VSCode development environment over Docker. This image is weekly | ||
# scanned for vulnerability and security with Synk, Dockle and Trivy. For detals | ||
# see: ./README.md | ||
FROM ghcr.io/keinos/vscode-dev-container-go:${VARIANT} | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
# USER root | ||
# RUN apk add --no-cache <your-package-list-here> | ||
|
||
USER vscode | ||
RUN cd /tmp && go install golang.org/x/lint/golint@latest |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,48 @@ | ||
// 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.191.1/containers/go | ||
{ | ||
"name": "Go", | ||
"name": "Go Dev", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"args": { | ||
// Go version: 1, 1.15, 1.14 | ||
"VARIANT": "1.15", | ||
// Options | ||
"INSTALL_NODE": "false", | ||
"NODE_VERSION": "lts/*" | ||
// Choices: https://github.com/KEINOS/VSCode-Dev-Container-Go/pkgs/container/vscode-dev-container-go | ||
"VARIANT": "latest" | ||
} | ||
}, | ||
"runArgs": [ | ||
"--cap-add=SYS_PTRACE", | ||
"--security-opt", "seccomp=unconfined", | ||
"--env-file",".devcontainer/devcontainer.env" | ||
], | ||
// Set VSCode settings | ||
"runArgs": [ | ||
"--rm", | ||
"--cap-add=SYS_PTRACE", | ||
"--security-opt", | ||
"seccomp=unconfined" | ||
], | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"go.toolsManagement.checkForUpdates": "local", | ||
"go.useLanguageServer": true, | ||
"go.gopath": "/go", | ||
"go.goroot": "/usr/local/go", | ||
"go.lintFlags": ["--enable-all", "--new"], | ||
"go.toolsGopath": "/go/bin", | ||
"go.toolsManagement.checkForUpdates": "proxy", | ||
"go.useLanguageServer": true, | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"terminal.integrated.shellArgs.linux": ["-l"] | ||
"terminal.integrated.profiles.linux": { | ||
"bash (login)": { | ||
"path": "/bin/bash", | ||
"args": [] | ||
} | ||
}, | ||
"shellformat.path": "/go/bin/shfmt" | ||
}, | ||
|
||
// VSCode extension ID to be installed | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"golang.Go", | ||
"editorconfig.editorconfig", | ||
"foxundermoon.shell-format", | ||
"ms-ceintl.vscode-language-pack-ja", | ||
"ms-ceintl.vscode-language-pack-es", | ||
"ms-azuretools.vscode-docker", | ||
"ms-vsonline.vsonline", | ||
"github.github-vscode-theme", | ||
"github.vscode-pull-request-github", | ||
"davidanson.vscode-markdownlint" | ||
"foxundermoon.shell-format" | ||
], | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "/bin/bash /postCreateCommand.sh;" | ||
"postCreateCommand": "go mod download", | ||
|
||
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. | ||
//"remoteUser": "vscode" | ||
} | ||
// Comment out to connect as root to debug container. | ||
// "remoteUser": "root" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# ============================================================================= | ||
# Test Container for Vaious Go Versions | ||
# ============================================================================= | ||
# Default version | ||
ARG VARIANT="1.15-alpine" | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Main Stage | ||
# ----------------------------------------------------------------------------- | ||
FROM golang:${VARIANT} | ||
|
||
ENV GO111MODULE=on | ||
|
||
RUN apk add --no-cache \ | ||
git \ | ||
alpine-sdk \ | ||
build-base | ||
|
||
WORKDIR /workspaces | ||
|
||
ENTRYPOINT go mod download && go test -race ./... |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Security Policy | ||
|
||
## Supported Go Versions | ||
|
||
We run the tests every week scheduled with the below Go versions. | ||
|
||
| Version | Supported | | ||
| :------ | :----------------: | | ||
| 1.15.15+ | :white_check_mark: | | ||
| 1.16.8+ | :white_check_mark: | | ||
| 1.17.1+ | :white_check_mark: | | ||
|
||
## Code Scaning | ||
|
||
[![CodeQL](https://github.com/KEINOS/dev-go/actions/workflows/codeQL-analysis.yml/badge.svg)](https://github.com/KEINOS/dev-go/actions/workflows/codeQL-analysis.yml) | ||
|
||
## Security Status | ||
|
||
- Check the current "[Security overview](https://github.com/KEINOS/dev-go/security)" status. | ||
|
||
## Reporting a Vulnerability | ||
|
||
- Please [issue](https://github.com/KEINOS/dev-go/issues) them. |
Oops, something went wrong.