github.com/sacloud/libsacloud/v2@v2.32.3/Makefile (about)

     1  #
     2  # Copyright 2016-2022 The Libsacloud Authors
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #      http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  #
    16  AUTHOR          ?="The Libsacloud Authors"
    17  COPYRIGHT_YEAR  ?="2016-2022"
    18  COPYRIGHT_FILES ?=$$(find . -name "*.go" -print | grep -v "/vendor/")
    19  
    20  default: gen fmt set-license goimports lint test
    21  
    22  .PHONY: test
    23  test:
    24  	TESTACC= go test ./... $(TESTARGS) -v -timeout=120m -parallel=8 -race;
    25  
    26  .PHONY: testacc
    27  testacc:
    28  	TESTACC=1 go test ./... $(TESTARGS) -v -timeout=120m -parallel=8 ;
    29  
    30  .PHONY: tools
    31  tools:
    32  	GO111MODULE=off go get golang.org/x/tools/cmd/goimports
    33  	GO111MODULE=off go get golang.org/x/tools/cmd/stringer
    34  	GO111MODULE=off go get github.com/sacloud/addlicense
    35  	GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
    36  	curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.43.0/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.43.0
    37  
    38  .PHONY: clean
    39  clean:
    40  	find . -type f -name "zz_*.go" -delete
    41  
    42  .PHONY: gen
    43  gen: _gen fmt goimports set-license
    44  
    45  .PHONY: _gen
    46  _gen:
    47  	go generate ./...
    48  
    49  .PHONY: gen_fake_data
    50  gen_fake_data: _gen_fake_data fmt goimports set-license
    51  
    52  .PHONY: _gen_fake_data
    53  _gen_fake_data:
    54  	go run internal/tools/gen-api-fake-data/main.go
    55  
    56  .PHONY: goimports
    57  goimports: fmt
    58  	goimports -l -w .
    59  
    60  .PHONY: fmt
    61  fmt:
    62  	find . -name '*.go' | grep -v vendor | xargs gofmt -s -w
    63  
    64  .PHONY: godoc
    65  godoc:
    66  	@echo "booting godoc server..." ; \
    67  	docker run -it --rm -v $$PWD:/go/src/github.com/sacloud/libsacloud/v2 -p 6060:6060 golang:1.14 sh -c "go get golang.org/x/tools/cmd/godoc; echo 'URL: http://localhost:6060/pkg/github.com/sacloud/libsacloud/v2/'; godoc -http=:6060"
    68  
    69  .PHONY: lint
    70  lint:
    71  	golangci-lint run ./...
    72  
    73  .PHONY: set-license
    74  set-license:
    75  	@addlicense -c $(AUTHOR) -y $(COPYRIGHT_YEAR) $(COPYRIGHT_FILES)
    76