-
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
Showing
53 changed files
with
2,589 additions
and
2,678 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 |
---|---|---|
|
@@ -10,4 +10,6 @@ dp-search-data-extractor | |
# Intellij | ||
.idea/ | ||
*.iml | ||
*.iws | ||
*.iws | ||
|
||
.go/ |
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
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,14 @@ | ||
FROM golang:1.19-bullseye AS base | ||
|
||
ENV GOCACHE=/go/.go/cache GOPATH=/go/.go/path TZ=Europe/London | ||
|
||
# Install github.com/cespare/reflex | ||
RUN GOBIN=/bin go install github.com/cespare/reflex@v0.3.1 | ||
RUN PATH=$PATH:/bin | ||
|
||
# Clean cache, as we want all modules in the container to be under /go/.go/path | ||
RUN go clean -modcache | ||
|
||
# Map between the working directories of dev and live | ||
RUN ln -s /go /dp-search-data-extractor | ||
WORKDIR /dp-search-data-extractor |
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 |
---|---|---|
@@ -1,48 +1,78 @@ | ||
BINPATH ?= build | ||
|
||
GREEN := $(shell tput -Txterm setaf 2) | ||
YELLOW := $(shell tput -Txterm setaf 3) | ||
WHITE := $(shell tput -Txterm setaf 7) | ||
CYAN := $(shell tput -Txterm setaf 6) | ||
RESET := $(shell tput -Txterm sgr0) | ||
|
||
BUILD_TIME=$(shell date +%s) | ||
GIT_COMMIT=$(shell git rev-parse HEAD) | ||
VERSION ?= $(shell git tag --points-at HEAD | grep ^v | head -n 1) | ||
|
||
LDFLAGS = -ldflags "-X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" | ||
|
||
.PHONY: all | ||
all: audit test build | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
all: delimiter-AUDIT audit delimiter-LINTERS lint delimiter-UNIT-TESTS test delimiter-COMPONENT-TESTS test-component delimiter-FINISH ## Runs multiple targets, audit, lint, test and test-component | ||
|
||
.PHONY: audit | ||
audit: | ||
audit: ## Runs checks for security vulnerabilities on dependencies (including transient ones) | ||
go list -m all | nancy sleuth | ||
|
||
.PHONY: lint | ||
lint: | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 | ||
golangci-lint run ./... | ||
|
||
.PHONY: build | ||
build: | ||
build: ## Builds binary of application code and stores in bin directory as dp-search-data-extractor | ||
go build -tags 'production' $(LDFLAGS) -o $(BINPATH)/dp-search-data-extractor | ||
|
||
.PHONY: convey | ||
convey: ## Runs unit test suite and outputs results on http://127.0.0.1:8080/ | ||
goconvey ./... | ||
|
||
.PHONY: delimiter-% | ||
delimiter-%: | ||
@echo '===================${GREEN} $* ${RESET}===================' | ||
|
||
.PHONY: debug | ||
debug: | ||
debug: ## Used to build and run code locally in debug mode | ||
go build -tags 'debug' $(LDFLAGS) -o $(BINPATH)/dp-search-data-extractor | ||
HUMAN_LOG=1 DEBUG=1 $(BINPATH)/dp-search-data-extractor | ||
|
||
.PHONY: test | ||
test: | ||
go test -count=1 -race -cover ./... | ||
.PHONY: debug-run | ||
debug-run: ## Used to run code locally in debug mode | ||
HUMAN_LOG=1 DEBUG=1 go run -tags 'debug' -race $(LDFLAGS) main.go | ||
|
||
.PHONY: fmt | ||
fmt: ## Run Go formatting on code | ||
go fmt ./... | ||
|
||
.PHONY: lint | ||
lint: ## Used in ci to run linters against Go code | ||
golangci-lint run ./... | ||
|
||
.PHONY: lint-local | ||
lint-local: ## Use locally to run linters against Go code | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 | ||
golangci-lint run ./... | ||
|
||
.PHONY: produce | ||
produce: | ||
produce: ## Runs a kafka producer to write message/messages to Kafka topic | ||
HUMAN_LOG=1 go run cmd/producer/main.go | ||
|
||
.PHONY: convey | ||
convey: | ||
goconvey ./... | ||
.PHONY: test | ||
test: ## Runs unit tests including checks for race conditions and returns coverage | ||
go test -count=1 -race -cover ./... | ||
|
||
.PHONY: test-component | ||
test-component: | ||
go test -cover -coverpkg=github.com/ONSdigital/dp-search-data-extractor/... -component | ||
test-component: ## Runs component test suite | ||
go test -cover -race -coverpkg=github.com/ONSdigital/dp-search-data-extractor/... -component | ||
|
||
.PHONY: help | ||
help: ## Show help page for list of make targets | ||
@echo '' | ||
@echo 'Usage:' | ||
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}' | ||
@echo '' | ||
@echo 'Targets:' | ||
@awk 'BEGIN {FS = ":.*?## "} { \ | ||
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ | ||
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ | ||
}' $(MAKEFILE_LIST) |
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
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
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.