Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xERR0R committed Mar 7, 2023
2 parents 6c61689 + f2e4886 commit 12ebe2a
Show file tree
Hide file tree
Showing 120 changed files with 8,375 additions and 2,971 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ node_modules
.gitignore
*.md
LICENSE
vendor
vendor
e2e/
35 changes: 0 additions & 35 deletions .github/workflows/ci-build.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/close_stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v6
- uses: actions/stale@v7
with:
stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/development-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
echo "TAGS: ${TAGS}"
- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/golangci-lint.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Makefile

on:
push:
pull_request:

permissions:
security-events: write
actions: read
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
make:
name: make
runs-on: ubuntu-latest
strategy:
matrix:
include:
- make: build
go: true
docker: false
- make: test
go: true
docker: false
- make: race
go: true
docker: false
- make: docker-build
go: false
docker: true
- make: e2e-test
go: true
docker: true
- make: goreleaser
go: false
docker: false
- make: lint
go: true
docker: false

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
if: matrix.go == true
with:
go-version-file: go.mod

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
if: matrix.docker == true

- name: make ${{ matrix.make }}
run: make ${{ matrix.make }}
if: matrix.make != 'goreleaser'
env:
GO_SKIP_GENERATE: 1

- name: Upload results to codecov
uses: codecov/codecov-action@v3
if: matrix.make == 'test'

- name: Check GoReleaser configuration
uses: goreleaser/goreleaser-action@v4
if: matrix.make == 'goreleaser'
with:
args: check
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
echo "BUILD_TIME: ${BUILD_TIME}"
- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
Expand All @@ -81,7 +81,7 @@ jobs:
cache-to: type=gha,mode=max

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.idea/
.vscode/
*.iml
*.test
/*.pem
bin/
dist/
Expand Down
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ linters:
- gofmt
- goimports
- gomnd
- gomoddirectives
- gomodguard
- gosec
- gosimple
Expand All @@ -39,6 +38,7 @@ linters:
- nilerr
- nilnil
- nlreturn
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
Expand All @@ -51,13 +51,18 @@ linters:
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
- wsl
disable:
- noctx
- contextcheck
- scopelint
- structcheck
- deadcode
- varcheck
- forbidigo

disable-all: false
presets:
Expand All @@ -77,3 +82,4 @@ issues:
linters:
- gochecknoglobals
- dupl
- gosec
18 changes: 9 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ archives:
- format_overrides:
- goos: windows
format: zip
replacements:
darwin: macOS
linux: Linux
freebsd: FreeBSD
openbsd: OpenBSD
netbsd: NetBSD
windows: Windows
386: i386
amd64: x86_64
name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
snapshot:
name_template: "{{ .Tag }}-{{.ShortCommit}}"
checksum:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ ENV BLOCKY_CONFIG_FILE=/app/config.yml

ENTRYPOINT ["/app/blocky"]

HEALTHCHECK --interval=1m --timeout=3s CMD ["/app/blocky", "healthcheck"]
HEALTHCHECK --start-period=1m --timeout=3s CMD ["/app/blocky", "healthcheck"]
36 changes: 25 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean build swagger test lint run fmt docker-build help
.PHONY: all clean generate build swagger test e2e-test lint run fmt docker-build help
.DEFAULT_GOAL:=help

VERSION?=$(shell git describe --always --tags)
Expand All @@ -21,6 +21,9 @@ GO_BUILD_LD_FLAGS:=\

GO_BUILD_OUTPUT:=$(BIN_OUT_DIR)/$(BINARY_NAME)$(BINARY_SUFFIX)

# define version of golangci-lint here. If defined in tools.go, go mod perfoms automatically downgrade to older version which doesn't work with golang >=1.18
GOLANG_LINT_VERSION=v1.50.1

export PATH=$(shell go env GOPATH)/bin:$(shell echo $$PATH)

all: build test lint ## Build binary (with tests)
Expand All @@ -35,14 +38,17 @@ swagger: ## creates swagger documentation as html file
$(shell) node_modules/html-inline/bin/cmd.js /tmp/swagger/index.html > docs/swagger.html

serve_docs: ## serves online docs
pip install mkdocs-material
mkdocs serve

build: ## Build binary
generate: ## Go generate
ifdef GO_SKIP_GENERATE
$(info skipping go generate)
else
go generate ./...
endif

build: generate ## Build binary
go build $(GO_BUILD_FLAGS) -ldflags="$(GO_BUILD_LD_FLAGS)" -o $(GO_BUILD_OUTPUT)
ifdef BIN_USER
$(info setting owner of $(GO_BUILD_OUTPUT) to $(BIN_USER))
Expand All @@ -53,24 +59,32 @@ ifdef BIN_AUTOCAB
setcap 'cap_net_bind_service=+ep' $(GO_BUILD_OUTPUT)
endif

test: ## run tests
go run github.com/onsi/ginkgo/v2/ginkgo -v --coverprofile=coverage.txt --covermode=atomic -cover ./...
test: ## run tests
go run github.com/onsi/ginkgo/v2/ginkgo --label-filter="!e2e" --coverprofile=coverage.txt --covermode=atomic -cover ./...

e2e-test: ## run e2e tests
docker buildx build \
--build-arg VERSION=blocky-e2e \
--network=host \
-o type=docker \
-t blocky-e2e \
.
go run github.com/onsi/ginkgo/v2/ginkgo --label-filter="e2e" ./...

race: ## run tests with race detector
go run github.com/onsi/ginkgo/v2/ginkgo --race ./...
go run github.com/onsi/ginkgo/v2/ginkgo --label-filter="!e2e" --race ./...

lint: ## run golangcli-lint checks
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
golangci-lint run --timeout 5m
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANG_LINT_VERSION) run --timeout 5m

run: build ## Build and run binary
./$(BIN_OUT_DIR)/$(BINARY_NAME)

fmt: ## gofmt and goimports all go files
find . -name '*.go' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
go run mvdan.cc/gofumpt -l -w -extra .
find . -name '*.go' -exec goimports -w {} +

docker-build: ## Build docker image
go generate ./...
docker-build: generate ## Build docker image
docker buildx build \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_TIME=${BUILD_TIME} \
Expand All @@ -80,4 +94,4 @@ docker-build: ## Build docker image
.

help: ## Shows help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Loading

0 comments on commit 12ebe2a

Please sign in to comment.