-
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.
Merge pull request #2 from intelops/tests
Update: Add tests, Makefile, golint-ci, and some restructuring
- Loading branch information
Showing
91 changed files
with
1,152 additions
and
476 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,30 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
branches: | ||
- "*" | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
pull-requests: read | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
cache: false | ||
- name: Run tests | ||
run: go test ./... -coverprofile=coverage.out -coverpkg=./... -covermode=atomic | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.54 | ||
args: -v --config=.golangci.yml |
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,5 @@ | ||
/example | ||
/bin | ||
coverage.out | ||
input.yaml | ||
input.json |
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,30 @@ | ||
run: | ||
timeout: 10m | ||
concurrency: 4 | ||
|
||
concurrency: 4 | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- unused | ||
- misspell | ||
- dupl | ||
- stylecheck | ||
|
||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
dupl: | ||
threshold: 400 | ||
|
||
issues: | ||
# Maximum issues count per one linter. Set to 0 to disable. Default is 50. | ||
max-issues-per-linter: 0 | ||
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3. | ||
max-same-issues: 0 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,43 @@ | ||
# Variables | ||
GOTEST=go test | ||
PKGS=./... | ||
TESTFLAGS=-v | ||
GOOS ?= linux | ||
GOARCH ?= amd64 | ||
|
||
default: help | ||
|
||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { split($$2, arr, "|"); printf " \033[36m%-20s\033[0m %s\n", $$1, arr[1]; for (i=2; i<=length(arr); i++) printf "%*s %s\n", targetWidth+22, " ", arr[i] } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
test: ## Run full test suite | ||
@echo "Running tests for all packages..." | ||
@$(GOTEST) $(TESTFLAGS) $(PKGS) | ||
|
||
|
||
testfunc: ## Runs test on a specific function specified in the arg.| Example usage `make testfunc validateInput` | ||
@echo "Running specific test function..." | ||
@$(GOTEST) $(TESTFLAGS) -run $(filter-out $@,$(MAKECMDGOALS)) $(PKGS) | ||
|
||
.PHONY: test testfunc | ||
|
||
coverage: ## Generate and view the test coverage | ||
@go test -coverprofile=coverage.out $(PKGS) | ||
@go tool cover -html=coverage.out | ||
|
||
%: | ||
@: | ||
format: ## Format the source code | ||
@echo "Formatting code..." | ||
@gofmt -s -w . | ||
|
||
vet: ## Vet the Go code for potential issues | ||
@echo "Vetting code for potential issues..." | ||
@go vet $(PKGS) | ||
|
||
lint: ## Run a linter on the codebase using golangci-lint. | ||
@docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.54.2 golangci-lint run -v | ||
|
||
|
||
build: ## builds the GenVal app for defined OS/Arch by passing GOOS=$(GOOS) GOARCH=$GOARCH args.| Example usage `make build GOOS=linux GOARCH=amd64` | ||
@GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags="-X main.Version=$(shell git describe --tags --abbrev=0)" -o ./bin/genval |
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
Oops, something went wrong.