Skip to content

Commit

Permalink
Merge pull request #1084 from sundowndev/chore/makefile
Browse files Browse the repository at this point in the history
Add Makefile
  • Loading branch information
sundowndev committed Jul 1, 2022
2 parents 47b82a6 + 1c21aff commit f8bd7ff
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 12 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ jobs:
run: (cd client && yarn install --immutable && yarn build)

- name: Build
run: |
go generate ./...
go build -v .
run: make build

- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.43.0
./bin/golangci-lint run -D errcheck
run: make lint

- name: Test
run: go test -race -coverprofile=./c.out -covermode=atomic -v ./...
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
.DS_Store
coverage
coverage.*
unit-tests.xml
.idea
api/assets.go

Expand Down
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Use bash syntax
SHELL=/bin/bash
# Go parameters
GOCMD=go
GOBINPATH=$(shell $(GOCMD) env GOPATH)/bin
GOMOD=$(GOCMD) mod
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=gotestsum
GOGET=$(GOCMD) get
GOINSTALL=$(GOCMD) install
GOTOOL=$(GOCMD) tool
GOFMT=$(GOCMD) fmt

.PHONY: FORCE

.PHONY: all
all: fmt lint test build go.mod

.PHONY: build
build:
go generate ./...
go build -v .

.PHONY: test
test:
$(GOTEST) --format testname --junitfile unit-tests.xml -- -mod=readonly -race -coverprofile=./c.out -covermode=atomic -coverpkg=.,./... ./...

.PHONY: coverage
coverage: test
$(GOTOOL) cover -func=cover.out

.PHONY: mocks
mocks:
rm -rf mocks
mockery --all

.PHONY: fmt
fmt:
$(GOFMT) ./...

.PHONY: clean
clean:
$(GOCLEAN)
rm -f bin/*

.PHONY: lint
lint:
@which golangci-lint > /dev/null 2>&1 || (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $(GOBINPATH) v1.46.2)
golangci-lint run -v --timeout=10m

.PHONY: install-tools
install-tools:
$(GOINSTALL) gotest.tools/gotestsum@v1.6.3
$(GOINSTALL) github.com/vektra/mockery/v2@latest

go.mod: FORCE
$(GOMOD) tidy
$(GOMOD) verify
go.sum: go.mod
1 change: 0 additions & 1 deletion api/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func googleSearchScan(c *gin.Context) {
// @Produce json
// @Success 200 {object} ScanResultResponse{result=remote.OVHScannerResponse}
// @Success 400 {object} JSONResponse
// @Deprecated
// @Router /numbers/{number}/scan/ovh [get]
// @Param number path string true "Input phone number" validate(required)
func ovhScan(c *gin.Context) {
Expand Down
1 change: 0 additions & 1 deletion api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ var doc = `{
],
"summary": "Perform a scan using OVH's API.",
"operationId": "ovhScan",
"deprecated": true,
"parameters": [
{
"type": "string",
Expand Down
1 change: 0 additions & 1 deletion api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@
],
"summary": "Perform a scan using OVH's API.",
"operationId": "ovhScan",
"deprecated": true,
"parameters": [
{
"type": "string",
Expand Down
1 change: 0 additions & 1 deletion api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ paths:
- Numbers
/numbers/{number}/scan/ovh:
get:
deprecated: true
operationId: ovhScan
parameters:
- description: Input phone number
Expand Down
2 changes: 1 addition & 1 deletion api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func registerClientRoute(router *gin.Engine) {
router.GET(path, func(c *gin.Context) {
c.Header("Content-Type", detectContentType(path, data))
c.Writer.WriteHeader(http.StatusOK)
c.Writer.Write(data)
_, _ = c.Writer.Write(data)
c.Abort()
})
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sundowndev/phoneinfoga/v2

go 1.13
go 1.16

require (
github.com/PuerkitoBio/goquery v1.6.1
Expand Down

0 comments on commit f8bd7ff

Please sign in to comment.