mirror of
https://github.com/hairyhenderson/go-onerng.git
synced 2025-04-04 09:40:12 -05:00
Adding makefile and CI
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
parent
0edf8e0f00
commit
d9e2265891
2
.github/CODEOWNERS
vendored
Normal file
2
.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#
|
||||||
|
* @hairyhenderson
|
15
.github/labeler.yml
vendored
Normal file
15
.github/labeler.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
documentation:
|
||||||
|
- docs/**/*
|
||||||
|
- docs-src/**/*
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- Gopkg.lock
|
||||||
|
- Gopkg.toml
|
||||||
|
- go.mod
|
||||||
|
- go.sum
|
||||||
|
- vendor/**/*
|
||||||
|
|
||||||
|
build:
|
||||||
|
- .github/workflows/*
|
||||||
|
- .circleci/*
|
||||||
|
- Makefile
|
19
.github/workflows/build.yml
vendored
Normal file
19
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Build
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linux-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/hairyhenderson/gomplate-ci-build:latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- run: make build
|
||||||
|
- run: make test
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/hairyhenderson/gomplate-ci-build:latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- run: make lint
|
66
.github/workflows/codeql-analysis.yml
vendored
Normal file
66
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: '0 1 * * 2'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
# Override automatic language detection by changing the below list
|
||||||
|
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||||
|
language: ['go']
|
||||||
|
# Learn more...
|
||||||
|
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# We must fetch at least the immediate parents so that if this is
|
||||||
|
# a pull request then we can checkout the head.
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
# If this run was triggered by a pull request event, then checkout
|
||||||
|
# the head of the pull request instead of the merge commit.
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
10
.github/workflows/label.yml
vendored
Normal file
10
.github/workflows/label.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
name: Labeler
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
label:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/labeler@v2
|
||||||
|
with:
|
||||||
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
!*/onerng
|
bin/
|
||||||
onerng
|
c.out
|
||||||
|
deb/
|
||||||
|
78
.golangci.yml
Normal file
78
.golangci.yml
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
linters-settings:
|
||||||
|
govet:
|
||||||
|
check-shadowing: true
|
||||||
|
golint:
|
||||||
|
min-confidence: 0
|
||||||
|
gocyclo:
|
||||||
|
min-complexity: 10
|
||||||
|
maligned:
|
||||||
|
suggest-new: true
|
||||||
|
dupl:
|
||||||
|
threshold: 100
|
||||||
|
goconst:
|
||||||
|
min-len: 2
|
||||||
|
min-occurrences: 4
|
||||||
|
lll:
|
||||||
|
line-length: 140
|
||||||
|
nolintlint:
|
||||||
|
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
|
||||||
|
allow-unused: false # report any unused nolint directives
|
||||||
|
require-explanation: false # don't require an explanation for nolint directives
|
||||||
|
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
|
||||||
|
|
||||||
|
linters:
|
||||||
|
disable-all: true
|
||||||
|
enable:
|
||||||
|
- asciicheck
|
||||||
|
- bodyclose
|
||||||
|
- deadcode
|
||||||
|
- depguard
|
||||||
|
- dogsled
|
||||||
|
- dupl
|
||||||
|
# - errcheck
|
||||||
|
- exhaustive
|
||||||
|
- exportloopref
|
||||||
|
# - funlen
|
||||||
|
# - gci
|
||||||
|
# - gochecknoglobals
|
||||||
|
- gochecknoinits
|
||||||
|
# - gocognit
|
||||||
|
- goconst
|
||||||
|
# - gocritic
|
||||||
|
# - gocyclo
|
||||||
|
# - godox
|
||||||
|
- gofmt
|
||||||
|
- gofumpt
|
||||||
|
- goheader
|
||||||
|
- goimports
|
||||||
|
- golint
|
||||||
|
# - gomnd
|
||||||
|
- gomodguard
|
||||||
|
- goprintffuncname
|
||||||
|
# - gosec
|
||||||
|
- gosimple
|
||||||
|
# - govet
|
||||||
|
- ineffassign
|
||||||
|
# - interfacer
|
||||||
|
# - lll
|
||||||
|
- maligned
|
||||||
|
- misspell
|
||||||
|
- nakedret
|
||||||
|
# - nestif
|
||||||
|
# - nlreturn
|
||||||
|
- noctx
|
||||||
|
- nolintlint
|
||||||
|
- prealloc
|
||||||
|
- rowserrcheck
|
||||||
|
- scopelint
|
||||||
|
- sqlclosecheck
|
||||||
|
- staticcheck
|
||||||
|
- structcheck
|
||||||
|
- stylecheck
|
||||||
|
- typecheck
|
||||||
|
- unconvert
|
||||||
|
# - unparam
|
||||||
|
- unused
|
||||||
|
- varcheck
|
||||||
|
- whitespace
|
||||||
|
# - wsl
|
55
Makefile
Normal file
55
Makefile
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
.DEFAULT_GOAL = build
|
||||||
|
extension = $(patsubst windows,.exe,$(filter windows,$(1)))
|
||||||
|
GO := go
|
||||||
|
BIN_NAME := onerng
|
||||||
|
PREFIX := .
|
||||||
|
|
||||||
|
COMMIT ?= `git rev-parse --short HEAD 2>/dev/null`
|
||||||
|
VERSION ?= `git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1) 2>/dev/null | sed 's/v\(.*\)/\1/'`
|
||||||
|
|
||||||
|
COMMIT_FLAG := -X `go list ./version`.GitCommit=$(COMMIT)
|
||||||
|
VERSION_FLAG := -X `go list ./version`.Version=$(VERSION)
|
||||||
|
|
||||||
|
GOOS ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\1/')
|
||||||
|
GOARCH ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\2/')
|
||||||
|
|
||||||
|
ifeq ("$(TARGETVARIANT)","")
|
||||||
|
ifneq ("$(GOARM)","")
|
||||||
|
TARGETVARIANT := v$(GOARM)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ("$(GOARM)","")
|
||||||
|
GOARM ?= $(subst v,,$(TARGETVARIANT))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -Rf $(PREFIX)/bin/*
|
||||||
|
|
||||||
|
$(PREFIX)/bin/$(BIN_NAME)_%: $(shell find $(PREFIX) -type f -name '*.go')
|
||||||
|
GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- | cut -f1 -d.) CGO_ENABLED=0 \
|
||||||
|
$(GO) build \
|
||||||
|
-ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG)" \
|
||||||
|
-o $@ \
|
||||||
|
./cmd/$(BIN_NAME)
|
||||||
|
|
||||||
|
$(PREFIX)/bin/$(BIN_NAME)$(call extension,$(GOOS)): $(PREFIX)/bin/$(BIN_NAME)_$(GOOS)-$(GOARCH)$(call extension,$(GOOS))
|
||||||
|
cp $< $@
|
||||||
|
|
||||||
|
build: $(PREFIX)/bin/$(BIN_NAME)$(call extension,$(GOOS))
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
test:
|
||||||
|
$(GO) test -coverprofile=c.out ./...
|
||||||
|
else
|
||||||
|
test:
|
||||||
|
$(GO) test -race -coverprofile=c.out ./...
|
||||||
|
endif
|
||||||
|
|
||||||
|
lint:
|
||||||
|
@golangci-lint run --max-same-issues=0 --sort-results
|
||||||
|
|
||||||
|
.PHONY: clean test build lint
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
.SECONDARY:
|
8
version/version.go
Normal file
8
version/version.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Version will be overwritten automatically by the build
|
||||||
|
Version = "0.0.0"
|
||||||
|
// GitCommit will be overwritten automatically by the build
|
||||||
|
GitCommit = "HEAD"
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user