-
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.
- Loading branch information
1 parent
3c0eaba
commit fb977ef
Showing
11 changed files
with
1,225 additions
and
27 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,92 @@ | ||
name: go | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16" | ||
|
||
# The golangci-lint action takes care of caching by itself. | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@v2 | ||
|
||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Test | ||
run: make test | ||
|
||
- name: Code coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
fail_ci_if_error: true | ||
|
||
- name: Update GoReport Card | ||
uses: creekorful/goreportcard-action@v1.0 | ||
|
||
release: | ||
name: Release | ||
needs: | ||
- lint | ||
- test | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "1.16" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Release | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
args: release --rm-dist | ||
env: | ||
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
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,52 @@ | ||
run: | ||
modules-download-mode: readonly | ||
skip-dirs: | ||
- .git | ||
- .github | ||
- .vscode | ||
- bin | ||
- dist | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- exhaustive | ||
- exportloopref | ||
- goconst | ||
- gofmt | ||
- goimports | ||
- golint | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nolintlint | ||
- prealloc | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
|
||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
goimports: | ||
local-prefixes: github.com/axiomhq/logmanager | ||
govet: | ||
check-shadowing: true | ||
nolintlint: | ||
allow-unused: false | ||
allow-leading-space: false | ||
require-explanation: true | ||
require-specific: true |
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,28 @@ | ||
project_name: logmanager | ||
|
||
builds: | ||
- skip: true | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" | ||
|
||
milestones: | ||
- repo: | ||
owner: axiomhq | ||
name: logmanager | ||
close: true | ||
fail_on_error: false | ||
|
||
release: | ||
github: | ||
owner: axiomhq | ||
name: logmanager | ||
prerelease: auto | ||
name_template: "Logmanager v{{.Version}}" |
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,65 @@ | ||
# Contributing | ||
|
||
This project accepts contributions. In order to contribute, you should pay | ||
attention to a few guidelines: | ||
|
||
## Reporting Issues | ||
|
||
Bugs, feature requests, and development-related questions should be directed to | ||
our [GitHub issue tracker](https://github.com/axiomhq/logmanager/issues). | ||
|
||
When reporting a bug, please try and provide as much context as possible such as | ||
your operating system, Go version and anything else that might be relevant to | ||
the bug. For feature requests, please explain what you're trying to do and how | ||
the requested feature would help you do that. | ||
|
||
## Setup | ||
|
||
[Fork](https://github.com/axiomhq/logmanager), then clone this repository: | ||
|
||
``` | ||
$ git clone https://github.com/axiomhq/logmanager.git | ||
$ cd logmanager | ||
$ make | ||
``` | ||
|
||
## Submitting Modifications | ||
|
||
1. It's generally best to start by opening a new issue describing the bug or | ||
feature you're intending to fix. Even if you think it's relatively minor, | ||
it's helpful to know what people are working on. Mention in the initial issue | ||
that you are planning to work on that bug or feature so that it can be | ||
assigned to you. | ||
|
||
2. Follow the normal process of | ||
[forking](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo) | ||
the project, and setup a new branch to work in. It's important that each | ||
group of changes be done in separate branches in order to ensure that a pull | ||
request only includes the commits related to that bug or feature. | ||
|
||
3. Go makes it very simple to ensure properly formatted code, so always run | ||
`go fmt` on your code before committing it. You should also make sure that | ||
the tests and the linters pass by running: | ||
|
||
``` | ||
$ make test | ||
$ make lint | ||
``` | ||
|
||
4. Do your best to have | ||
[well-formated commit messages](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) | ||
for each change. This provides consistency throughout the project and | ||
ensures that commit messages are able to be formatted properly by various git | ||
tools. | ||
|
||
5. Finally, push the commits to your fork and submit a | ||
[pull request](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) | ||
|
||
### Once you've filed the PR: | ||
|
||
- One or more maintainers will use GitHub's review feature to review your PR. | ||
- If the maintainer asks for any changes, edit your changes, push, and ask for | ||
another review. | ||
- If the maintainer decides to suggest some improvements or alternatives, | ||
modify and make improvements. Once your changes are approved, one of the | ||
project maintainers will merge them. |
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 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,102 @@ | ||
# TOOLCHAIN | ||
GO := CGO_ENABLED=0 GOBIN=$(CURDIR)/bin go | ||
GOFMT := $(GO)fmt | ||
|
||
# ENVIRONMENT | ||
VERBOSE = | ||
|
||
# GO TOOLS | ||
GOLANGCI_LINT := bin/golangci-lint | ||
GOTESTSUM := bin/gotestsum | ||
|
||
# MISC | ||
COVERPROFILE := coverage.out | ||
DIST_DIR := dist | ||
|
||
# FLAGS | ||
GO_TEST_FLAGS := -race -coverprofile=$(COVERPROFILE) | ||
|
||
# DEPENDENCIES | ||
GOMODDEPS = go.mod go.sum | ||
|
||
# Enable verbose test output if explicitly set. | ||
GOTESTSUM_FLAGS = | ||
ifdef VERBOSE | ||
GOTESTSUM_FLAGS += --format=standard-verbose | ||
endif | ||
|
||
# FUNCTIONS | ||
# func go-list-pkg-sources(package) | ||
go-list-pkg-sources = $(GO) list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $(1) | ||
# func go-pkg-sourcefiles(package) | ||
go-pkg-sourcefiles = $(shell $(call go-list-pkg-sources,$(strip $1))) | ||
|
||
.PHONY: all | ||
all: dep fmt lint test ## Run dep, fmt, lint and test | ||
|
||
.PHONY: clean | ||
clean: ## Remove build and test artifacts | ||
@echo ">> cleaning up artifacts" | ||
@rm -rf $(COVERPROFILE) $(DIST_DIR) | ||
|
||
.PHONY: cover | ||
cover: $(COVERPROFILE) ## Calculate the code coverage score | ||
@echo ">> calculating code coverage" | ||
@$(GO) tool cover -func=$(COVERPROFILE) | tail -n1 | ||
|
||
.PHONY: dep-clean | ||
dep-clean: ## Remove obsolete dependencies | ||
@echo ">> cleaning dependencies" | ||
@$(GO) mod tidy | ||
|
||
.PHONY: dep-upgrade | ||
dep-upgrade: ## Upgrade all direct dependencies to their latest version | ||
@echo ">> upgrading dependencies" | ||
@$(GO) get -d $(shell $(GO) list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all) | ||
@make dep | ||
|
||
.PHONY: dep | ||
dep: dep-clean dep.stamp ## Install and verify dependencies and remove obsolete ones | ||
|
||
dep.stamp: $(GOMODDEPS) | ||
@echo ">> installing dependencies" | ||
@$(GO) mod download | ||
@$(GO) mod verify | ||
@touch $@ | ||
|
||
.PHONY: fmt | ||
fmt: ## Format and simplify the source code using `gofmt` | ||
@echo ">> formatting code" | ||
@! $(GOFMT) -s -w $(shell find . -path -prune -o -name '*.go' -print) | grep '^' | ||
|
||
.PHONY: lint | ||
lint: $(GOLANGCI_LINT) ## Lint the source code | ||
@echo ">> linting code" | ||
@$(GOLANGCI_LINT) run | ||
|
||
.PHONY: test | ||
test: $(GOTESTSUM) ## Run all unit tests. Run with VERBOSE=1 to get verbose test output ('-v' flag). | ||
@echo ">> running tests" | ||
@$(GOTESTSUM) $(GOTESTSUM_FLAGS) -- $(GO_TEST_FLAGS) ./... | ||
|
||
.PHONY: tools | ||
tools: $(GOLANGCI_LINT) $(GOTESTSUM) ## Install all tools into the projects local $GOBIN directory | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
# MISC TARGETS | ||
|
||
$(COVERPROFILE): | ||
@make test | ||
|
||
# GO TOOLS | ||
|
||
$(GOLANGCI_LINT): dep.stamp $(call go-pkg-sourcefiles, github.com/golangci/golangci-lint/cmd/golangci-lint) | ||
@echo ">> installing golangci-lint" | ||
@$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
$(GOTESTSUM): dep.stamp $(call go-pkg-sourcefiles, gotest.tools/gotestsum) | ||
@echo ">> installing gotestsum" | ||
@$(GO) install gotest.tools/gotestsum |
Oops, something went wrong.