Skip to content

Commit bad9961

Browse files
committed
Almost Batman. Added basic files.
1 parent 1e551c2 commit bad9961

File tree

9 files changed

+129
-0
lines changed

9 files changed

+129
-0
lines changed

.covignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.gen.
2+
_test.
3+
mock_
4+
main.go

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# EditorConfig is awesome: https://editorconfig.org
2+
3+
# Top-most EditorConfig file
4+
root = true
5+
6+
# All files
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.md text
7+
*.sh text
8+
*.json text
9+
*.yaml text
10+
*.yml text
11+
*.hery text
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Pre-Build Workflow
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
jobs:
9+
call-pre-build:
10+
uses: AmadlaOrg/GitHub-Actions/.github/workflows/golang-pre-build.yml@master

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ go.work.sum
2323

2424
# env file
2525
.env
26+
27+
# Editor
28+
.idea/
29+
30+
# Build

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
linters-settings:
2+
3+
run:
4+
5+
issues:
6+
exclude-files:
7+
- '^.*mock_.*\.go$'

.mockery.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resolve-type-alias: False
2+
issue-845-fix: True
3+
4+
packages:

.script/test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
output_dir=".reports"
6+
cov_unfiltered_out_file="${output_dir}/coverage.unfiltered.out"
7+
cov_out_file="${output_dir}/coverage.out"
8+
cov_out_xml_file="${output_dir}/coverage.xml"
9+
report_file="${output_dir}/coverage_summary.txt"
10+
11+
rm -rf ${output_dir}
12+
mkdir -p ${output_dir}
13+
echo "" > ${report_file}
14+
15+
echo "---> Testing code..."
16+
17+
go test -count=1 -tags=integration -coverpkg=./... -covermode=count -coverprofile ${cov_unfiltered_out_file} ./... | tee ${output_dir}/std.out
18+
grep -v -E -f .covignore ${cov_unfiltered_out_file} > ${cov_out_file}
19+
20+
total="$(go tool cover -func ${cov_out_file} | tail -n 1 | grep -Eo '[0-9]+\.[0-9]+')"
21+
subtotals+="\t${total}%"
22+
23+
echo -e "Total coverage:\t${total}%" | tee -a $report_file
24+
25+
# shellcheck disable=SC2002
26+
cat ${output_dir}/std.out | go-junit-report > ${output_dir}/reports.xml
27+
gocover-cobertura < ${cov_out_file} > ${cov_out_xml_file} --ignore-gen-files
28+
gcov2lcov -infile=${cov_out_file} -outfile=${output_dir}/lcov.info

Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.PHONY: install-deps
2+
install-deps: ## Installs Dependencies
3+
@echo "---> Installing Dependencies"
4+
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
5+
@go install github.com/boumenot/gocover-cobertura@latest
6+
@go install github.com/jstemmer/go-junit-report/v2@latest
7+
@go install github.com/jandelgado/gcov2lcov@latest
8+
@go install github.com/vektra/mockery/v3@latest
9+
10+
generate: ## Generate mock code
11+
@echo "---> Generating code"
12+
@go generate ./...
13+
@go run github.com/vektra/mockery/v2@latest
14+
15+
.PHONY: lint
16+
lint: ## Linting
17+
@echo "---> Linting"
18+
@golangci-lint run -v
19+
20+
.PHONY: lint-fix
21+
lint-fix: ## Lint-Fixing code
22+
@echo "---> Lint-Fixing code"
23+
@golangci-lint run --fix
24+
25+
.PHONY: test
26+
test: ## Test code
27+
@.script/test.sh
28+
29+
.PHONY: cov
30+
cov: cov ## Show test coverage
31+
@go tool cover -html=.reports/coverage.out
32+
33+
.PHONY: test-cov
34+
test-cov: test cov ## Test coverage
35+
36+
.PHONY: clean
37+
clean: ## Clean bin and coverage files
38+
@echo "---> Cleaning bin and coverage files"
39+
@rm -f bin/*
40+
@rm -f coverage.out
41+
@rm -f .reports/*
42+
43+
build: ## Build code
44+
@echo "---> Build"
45+
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -buildvcs=true -o bin/ ./
46+
47+
.PHONY: help
48+
help: ## Help
49+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sed 's/Makefile://' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

0 commit comments

Comments
 (0)