inetmock/Taskfile.yml
Peter Kurfer 896b7ded65 Introduce DNS-over-HTTPS and HTTP2 support
- add more advanced multiplexing to match on HTTP request properties
- introduce custom DNS client to cover traditional UDP/TCP and HTTPS transport with the same client
- add HTTP2 check module and server functionality where applicable
2021-10-22 06:58:22 +00:00

209 lines
5.2 KiB
YAML

version: "3"
vars:
OUT_DIR: ./out
INETMOCK_PKG: gitlab.com/inetmock/inetmock/cmd/inetmock
IMCTL_PKG: gitlab.com/inetmock/inetmock/cmd/imctl
PROTO_FILES:
sh: find ./api/ -type f -name "*.proto" -printf "%p "
DOCKER_ENDPOINT:
sh: echo "${DOCKER_ENDPOINT:-localhost}"
env:
GOOS: linux
GOARCH: amd64
CGO_ENABLED: 0
tasks:
clean:
desc: clean all generated files
cmds:
- find . -type f \( -name "*.pb.go" -or -name "*.mock.go" -or -name "*_enum.go" \) -exec rm -f {} \;
- rm -rf ./main {{ .OUT_DIR }}
format:
desc: format all source files
cmds:
- gofumpt -l -s -w ./
- goimports -local gitlab.com/inetmock/inetmock -w ./
deps:
desc: download dependencies
sources:
- go.mod
- go.sum
cmds:
- go mod download
dep-graph:
desc: generate dependency graph
sources:
- go.mod
- go.sum
cmds:
- mkdir -p {{ .OUT_DIR }}
- gomod graph "**" | dot -Gdpi=0 -T svg -o {{ .OUT_DIR }}/dependency_graph.svg
golangci-lint:
desc: run Go linter
deps:
- deps
- generate
- format
cmds:
- golangci-lint run --timeout 5m
protobuf-lint:
desc: run protobuf linter
dir: api/
sources:
- "proto/**/*.proto"
cmds:
- buf lint
lint:
desc: run all linters
deps:
- golangci-lint
- protobuf-lint
protoc:
desc: generate Go files from protobuf files
deps:
- protobuf-lint
sources:
- "api/proto/**/*.proto"
generates:
- "**/*.pb.go"
cmds:
- buf protoc --proto_path ./api/proto/ --go_out=./pkg/ --go_opt=paths=source_relative --go-grpc_out=./pkg/ --go-grpc_opt=paths=source_relative {{ .PROTO_FILES }}
go-generate:
desc: run all go:generate directives
deps:
- deps
sources:
- "**/*.go"
generates:
- "**/*.mock.go"
cmds:
- go generate -x ./...
generate:
desc: run all code generation steps
deps:
- go-generate
- protoc
test:
desc: run short running unit tests that do not need sudo
sources:
- "**/*.go"
env:
CGO_ENABLED: 1
deps:
- deps
- generate
cmds:
- mkdir -p {{ .OUT_DIR }}
- go test -race -shuffle=on -coverprofile={{ .OUT_DIR }}/cov-raw.out -covermode atomic ./...
- grep -Ev "gitlab.com/inetmock/inetmock/pkg/logging" {{ .OUT_DIR }}/cov-raw.out > {{ .OUT_DIR }}/cov.out
- go tool cover -func={{ .OUT_DIR }}/cov.out
test-all:
desc: run all unit tests
sources:
- "**/*.go"
deps:
- deps
- generate
env:
CGO_ENABLED: 1
cmds:
- mkdir -p {{ .OUT_DIR }}
- gotestsum --junitfile={{ .OUT_DIR }}/report.xml -- --tags sudo -race -shuffle=on -coverprofile={{ .OUT_DIR }}/cov-raw.out -covermode atomic ./...
- grep -Ev "gitlab.com/inetmock/inetmock/pkg/logging|_enum.go" {{ .OUT_DIR }}/cov-raw.out > {{ .OUT_DIR }}/cov.out
- gocover-cobertura < {{ .OUT_DIR }}/cov.out > {{ .OUT_DIR }}/coverage.xml
- rm -f {{ .OUT_DIR }}/cov-raw.out
integration-test:
desc: run all benchmarks/integration tests
deps:
- deps
- generate
cmds:
- cat testdata/integration.imcs | go run ./cmd/imctl check run --insecure --target {{ .DOCKER_ENDPOINT }} --log-level debug
debug-integration-test:
desc: run all benchmarks/integration tests
deps:
- deps
- generate
cmds:
- cat testdata/integration.imcs | dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient ./cmd/imctl -- check run --insecure --target {{ .DOCKER_ENDPOINT }} --log-level debug
cli-cover-report:
desc: generate a coverage report on the CLI
deps:
- test-all
cmds:
- go tool cover -func={{ .OUT_DIR }}/cov.out
html-cover-report:
desc: generate a coverage report as HTML page
deps:
- test-all
cmds:
- go tool cover -html={{ .OUT_DIR }}/cov.out -o {{ .OUT_DIR }}/coverage.html
build-inetmock:
desc: build the INetMock server part
deps:
- deps
- generate
cmds:
- mkdir -p {{ .OUT_DIR }}
- go build -ldflags='-w -s' -trimpath -o {{ .OUT_DIR }}/inetmock {{ .INETMOCK_PKG }}
debug-inetmock:
desc: run INetMock server with delve for remote debugging
cmds:
- dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient --output {{ .OUT_DIR }}/__debug_bin debug {{ .INETMOCK_PKG }} -- serve
build-imctl:
desc: build the imctl INetMock client CLI
deps:
- deps
- generate
cmds:
- mkdir -p {{ .OUT_DIR }}
- go build -ldflags='-w -s' -trimpath -o {{ .OUT_DIR }}/imctl {{ .IMCTL_PKG }}
build-all:
desc: build all binaries
deps:
- build-inetmock
- build-imctl
snapshot-release:
desc: create a snapshot/test release without publishing any artifacts
deps:
- deps
- generate
cmds:
- task: format
- goreleaser release --snapshot --skip-publish --rm-dist
release:
desc: create a release - includes artifact publishing
deps:
- deps
- generate
cmds:
- task: format
- goreleaser release --rm-dist
docs:
desc: generate docs
cmds:
- mdbook build -d ./../public ./docs