-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d9d4e7d
Showing
23 changed files
with
882 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
author: Simon Emms <simon@simonemms.com> | ||
license: Apache-2.0 | ||
useViper: false |
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,27 @@ | ||
{ | ||
"name": "devcontainer", | ||
"image": "ghcr.io/mrsimonemms/devcontainers/full", | ||
"features": {}, | ||
"customizations": { | ||
"vscode": { | ||
"settings": {}, | ||
"extensions": [ | ||
"donjayamanne.git-extension-pack", | ||
"EditorConfig.EditorConfig", | ||
"waderyan.gitblame", | ||
"GitHub.vscode-github-actions", | ||
"golang.go" | ||
] | ||
} | ||
}, | ||
"postStartCommand": { | ||
"copy-cobra": "ln -s $PWD/.cobra.yaml $HOME/.cobra.yaml", | ||
"cobra-install": "go install github.com/spf13/cobra-cli@latest", | ||
"golangci-lint": "go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest", | ||
"errcheck": "go install github.com/kisielk/errcheck@latest", | ||
"gofumpt": "go install mvdan.cc/gofumpt@latest", | ||
"staticcheck": "go install honnef.co/go/tools/cmd/staticcheck@latest", | ||
"goimports": "go install golang.org/x/tools/cmd/goimports@latest", | ||
"pre-commit": "pre-commit install --install-hooks -t pre-commit -t commit-msg" | ||
} | ||
} |
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 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.go] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[Makefile] | ||
indent_style = tab | ||
indent_size = 4 |
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,158 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
permissions: | ||
contents: write | ||
packages: write | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '>=1.19.0' | ||
|
||
- name: Go install | ||
run: go install ./... | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
|
||
- name: go-fmt-import | ||
uses: Jerome1337/goimports-action@v1.0.2 | ||
|
||
- name: go-vet | ||
run: go vet -v ./... | ||
|
||
- name: gofumpt | ||
run: | | ||
go install mvdan.cc/gofumpt@latest | ||
LIST_OF_FILES=$(gofumpt -l .) | ||
echo "$LIST_OF_FILES" | ||
if [ -n "$LIST_OF_FILES" ]; then | ||
exit 1 | ||
fi | ||
- name: go-err-check | ||
run: | | ||
go install github.com/kisielk/errcheck@latest | ||
errcheck ./... | ||
- name: go-static-check | ||
uses: dominikh/staticcheck-action@v1.2.0 | ||
with: | ||
install-go: false | ||
|
||
- uses: actions/setup-python@v3 | ||
|
||
- uses: pre-commit/action@v3.0.0 | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '>=1.19.0' | ||
|
||
- run: go version | ||
|
||
- name: Install Go dependencies | ||
run: go install ./... | ||
|
||
- name: Lint Go | ||
uses: golangci/golangci-lint-action@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get branch names | ||
id: branch-name | ||
uses: tj-actions/branch-names@v6 | ||
with: | ||
strip_tag_prefix: v | ||
|
||
- name: Generate Docker tag | ||
id: docker | ||
run: | | ||
if [ "${{ steps.branch-name.outputs.is_tag }}" = "true" ]; | ||
then | ||
# Latest tag | ||
IMG_NAME="ghcr.io/${GITHUB_REPOSITORY,,}:latest" | ||
# Tag name (usually vX.Y.Z) | ||
IMG_NAME="${IMG_NAME},ghcr.io/${GITHUB_REPOSITORY,,}:${{ steps.branch-name.outputs.tag }}" | ||
echo "image_name=${IMG_NAME}" >> "$GITHUB_OUTPUT" | ||
echo "platforms=linux/amd64,linux/arm64,linux/arm/v7" >> "$GITHUB_OUTPUT" | ||
else | ||
# Use branch naming convention | ||
TAG="branch-${{ steps.branch-name.outputs.current_branch }}" | ||
# Change "/" for "-" | ||
TAG="${TAG//\//-}" | ||
# Set to lowercase | ||
TAG="${TAG,,}" | ||
echo "image_name=ghcr.io/${GITHUB_REPOSITORY,,}:${TAG}" >> "$GITHUB_OUTPUT" | ||
echo "platforms=linux/amd64" >> "$GITHUB_OUTPUT" | ||
fi | ||
if [ "${{ steps.branch-name.outputs.is_tag }}" = "true" ]; | ||
then | ||
echo "version=${{ steps.branch-name.outputs.tag }}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "version=development" >> "$GITHUB_OUTPUT" | ||
fi | ||
echo "commit_id=${GITHUB_SHA}" >> "$GITHUB_OUTPUT" | ||
echo "gitRepo=github.com/${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT" | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
build-args: | | ||
GIT_COMMIT=${{ steps.docker.outputs.commit_id }} | ||
GIT_REPO=${{ steps.docker.outputs.gitRepo }} | ||
VERSION=${{ steps.docker.outputs.version }} | ||
platforms: ${{ steps.docker.outputs.platforms }} | ||
push: ${{ github.ref == 'refs/heads/main' }} | ||
tags: ${{ steps.docker.outputs.image_name }} | ||
|
||
- name: Run GoReleaser | ||
if: steps.branch-name.outputs.is_tag == 'true' | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GIT_REPO: ${{ steps.docker.outputs.gitRepo }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 @@ | ||
name: Commit lint | ||
permissions: read-all | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
jobs: | ||
commitlint: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # fetch-depth is required | ||
|
||
- uses: wagoid/commitlint-github-action@v5 |
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,10 @@ | ||
dist | ||
tmp | ||
|
||
node_modules | ||
|
||
.idea | ||
.DS_Store | ||
Thumbs.db | ||
.commit | ||
.envrc |
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,13 @@ | ||
FROM gitpod/workspace-full | ||
|
||
# Gitpod Package Manager | ||
RUN curl -sfL gpm.simonemms.com | bash \ | ||
&& gpm install pre-commit | ||
|
||
# Golang dependencies | ||
RUN go install github.com/spf13/cobra-cli@latest \ | ||
&& go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest \ | ||
&& go install github.com/kisielk/errcheck@latest \ | ||
&& go install mvdan.cc/gofumpt@latest \ | ||
&& go install honnef.co/go/tools/cmd/staticcheck@latest \ | ||
&& go install golang.org/x/tools/cmd/goimports@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
image: | ||
file: .gitpod.Dockerfile | ||
|
||
tasks: | ||
- name: Setup | ||
command: | | ||
pre-commit install --install-hooks -t pre-commit -t commit-msg | ||
gp sync-done pre-commit | ||
exit 0 | ||
- init: | | ||
if [ -f "go.mod" ]; then | ||
go install ./... | ||
fi | ||
command: | | ||
# Copy .cobra.yaml to $HOME | ||
cp .cobra.yaml $HOME/.cobra.yaml | ||
export GIT_REPO="${GITPOD_WORKSPACE_CONTEXT_URL/https:\/\//}" | ||
export PROJECT_NAME="${GIT_REPO##*/}" | ||
if [ ! -f "go.mod" ]; then | ||
echo "Creating Go module" | ||
go mod init "$GIT_REPO" | ||
fi | ||
if [ ! -f "main.go" ]; then | ||
echo "Create Cobra project" | ||
cobra-cli init | ||
go mod tidy | ||
fi | ||
vscode: | ||
extensions: | ||
- donjayamanne.git-extension-pack | ||
- EditorConfig.EditorConfig | ||
- golang.go |
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,37 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
# you may remove this if you don't need go generate | ||
- go generate ./... | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
ldflags: | ||
- -w -s -X {{ .Env.GIT_REPO }}/cmd.Version={{ .Version }} -X {{ .Env.GIT_REPO }}/cmd.GitCommit={{ .Commit }} | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
# modelines, feel free to remove those if you don't want/use them: | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj |
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 @@ | ||
style 'markdownlint.rb' |
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,33 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/compilerla/conventional-pre-commit | ||
rev: v2.3.0 | ||
hooks: | ||
- id: conventional-pre-commit | ||
stages: | ||
- commit-msg | ||
- repo: https://github.com/trussworks/pre-commit-hooks | ||
rev: v1.1.1 | ||
hooks: | ||
- id: markdown-toc | ||
- repo: https://github.com/golangci/golangci-lint | ||
rev: v1.53.2 | ||
hooks: | ||
- id: golangci-lint | ||
- repo: https://github.com/Bahjat/pre-commit-golang | ||
rev: v1.0.3 | ||
hooks: | ||
- id: go-fmt-import | ||
- id: go-vet | ||
- id: gofumpt | ||
- id: go-err-check | ||
- id: go-static-check | ||
- repo: https://github.com/markdownlint/markdownlint | ||
rev: v0.12.0 | ||
hooks: | ||
- id: markdownlint |
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,7 @@ | ||
{ | ||
"yaml.schemas": { | ||
"https://json.schemastore.org/github-workflow.json": [ | ||
".github/workflows/*.{yml,yaml}" | ||
] | ||
} | ||
} |
Oops, something went wrong.