Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize Project #1

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
env:
APP_NAME: ${BUILDKITE_PIPELINE_SLUG}

steps:
- label: ":golangci-lint: lint :lint-roller:"
key: "lint"
plugins:
- docker#v5.10.0:
environment:
- GOFLAGS=-buildvcs=false
image: "registry.hub.docker.com/golangci/golangci-lint:v1.57-alpine"
command: ["golangci-lint", "run", "-v", "--timeout", "5m"]

- label: ":test_tube: test"
key: "test"
plugins:
- docker-compose#v4.16.0:
cli-version: 2
run: go
config: docker-compose-ci.yml
command: ["make", "test"]
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @metal-toolbox/identity-core
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# name: goreleaser

# on:
# push:
# tags:
# - 'v*.*.*'

# jobs:
# goreleaser:
# runs-on: ubuntu-latest
# permissions:
# contents: write
# id-token: write
# packages: write
# steps:
# -
# name: Login to GHCR
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# -
# name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# -
# name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: "1.22"
# -
# name: install cosign
# uses: sigstore/cosign-installer@main
# -
# uses: anchore/sbom-action/[email protected]
# -
# name: Run GoReleaser
# uses: goreleaser/goreleaser-action@v5
# with:
# version: latest
# args: release --clean
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# COSIGN_EXPERIMENTAL: 1
# GOVERSION: "1.22"
67 changes: 67 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

bin
tmp
governor-extension-sdk
61 changes: 61 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
linters-settings:
goimports:
local-prefixes: go.metalkube.net/mf-example-microservice
gofumpt:
extra-rules: true

linters:
enable:
# default linters
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck

# additional linters
- bodyclose
- gocritic
- gocyclo
- goerr113
- gofmt
- gofumpt
- goimports
- gomnd
- govet
- misspell
- noctx
- revive
- stylecheck
- whitespace
- wsl

issues:
exclude:
# Default excludes from `golangci-lint run --help` with EXC0002 removed
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
# EXC0003 golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
# EXC0004 govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- ineffective break statement. Did you mean to break out of the outer loop
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# EXC0007 gosec: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# EXC0008 gosec: Duplicated errcheck checks
- (G104|G307)
# EXC0009 gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
exclude-use-default: false
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
all: lint test
PHONY: test coverage lint golint clean vendor docker-up docker-down unit-test
GOOS=linux
# use the working dir as the app name, this should be the repo name
APP_NAME=$(shell basename $(CURDIR))

test: | unit-test

unit-test:
@echo Running unit tests...
@go test -cover -short -tags testtools ./...

lint: golint

golint: | vendor
@echo Linting Go files...
@golangci-lint run --build-tags "-tags testtools"

bin/${APP_NAME}:
@go mod download
@CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o bin/${APP_NAME}

build: bin/${APP_NAME}

clean: docker-clean
@echo Cleaning...
@rm -f app
@rm -rf ./dist/
@rm -rf coverage.out
@go clean -testcache

vendor:
@go mod download
@go mod tidy
Loading