github.com/twelho/conform@v0.0.0-20231016230407-c25e9238598a/Makefile (about)

     1  # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
     2  #
     3  # Generated on 2022-09-19T13:49:50Z by kres 9ea8a33.
     4  
     5  # common variables
     6  
     7  SHA := $(shell git describe --match=none --always --abbrev=8 --dirty)
     8  TAG := $(shell git describe --tag --always --dirty)
     9  BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
    10  ARTIFACTS := _out
    11  REGISTRY ?= ghcr.io
    12  USERNAME ?= siderolabs
    13  REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
    14  GOLANGCILINT_VERSION ?= v1.49.0
    15  GOFUMPT_VERSION ?= v0.3.1
    16  GO_VERSION ?= 1.19
    17  GOIMPORTS_VERSION ?= v0.1.12
    18  PROTOBUF_GO_VERSION ?= 1.28.1
    19  GRPC_GO_VERSION ?= 1.2.0
    20  GRPC_GATEWAY_VERSION ?= 2.11.3
    21  VTPROTOBUF_VERSION ?= 0.3.0
    22  DEEPCOPY_VERSION ?= v0.5.5
    23  TESTPKGS ?= ./...
    24  KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest
    25  CONFORMANCE_IMAGE ?= ghcr.io/siderolabs/conform:latest
    26  
    27  # docker build settings
    28  
    29  BUILD := docker buildx build
    30  PLATFORM ?= linux/amd64
    31  PROGRESS ?= auto
    32  PUSH ?= false
    33  CI_ARGS ?=
    34  COMMON_ARGS = --file=Dockerfile
    35  COMMON_ARGS += --progress=$(PROGRESS)
    36  COMMON_ARGS += --platform=$(PLATFORM)
    37  COMMON_ARGS += --push=$(PUSH)
    38  COMMON_ARGS += --build-arg=ARTIFACTS=$(ARTIFACTS)
    39  COMMON_ARGS += --build-arg=SHA=$(SHA)
    40  COMMON_ARGS += --build-arg=TAG=$(TAG)
    41  COMMON_ARGS += --build-arg=USERNAME=$(USERNAME)
    42  COMMON_ARGS += --build-arg=REGISTRY=$(REGISTRY)
    43  COMMON_ARGS += --build-arg=TOOLCHAIN=$(TOOLCHAIN)
    44  COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION=$(GOLANGCILINT_VERSION)
    45  COMMON_ARGS += --build-arg=GOFUMPT_VERSION=$(GOFUMPT_VERSION)
    46  COMMON_ARGS += --build-arg=GOIMPORTS_VERSION=$(GOIMPORTS_VERSION)
    47  COMMON_ARGS += --build-arg=PROTOBUF_GO_VERSION=$(PROTOBUF_GO_VERSION)
    48  COMMON_ARGS += --build-arg=GRPC_GO_VERSION=$(GRPC_GO_VERSION)
    49  COMMON_ARGS += --build-arg=GRPC_GATEWAY_VERSION=$(GRPC_GATEWAY_VERSION)
    50  COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION=$(VTPROTOBUF_VERSION)
    51  COMMON_ARGS += --build-arg=DEEPCOPY_VERSION=$(DEEPCOPY_VERSION)
    52  COMMON_ARGS += --build-arg=TESTPKGS=$(TESTPKGS)
    53  TOOLCHAIN ?= docker.io/golang:1.19-alpine
    54  
    55  # help menu
    56  
    57  export define HELP_MENU_HEADER
    58  # Getting Started
    59  
    60  To build this project, you must have the following installed:
    61  
    62  - git
    63  - make
    64  - docker (19.03 or higher)
    65  
    66  ## Creating a Builder Instance
    67  
    68  The build process makes use of experimental Docker features (buildx).
    69  To enable experimental features, add 'experimental: "true"' to '/etc/docker/daemon.json' on
    70  Linux or enable experimental features in Docker GUI for Windows or Mac.
    71  
    72  To create a builder instance, run:
    73  
    74  	docker buildx create --name local --use
    75  
    76  
    77  If you already have a compatible builder instance, you may use that instead.
    78  
    79  ## Artifacts
    80  
    81  All artifacts will be output to ./$(ARTIFACTS). Images will be tagged with the
    82  registry "$(REGISTRY)", username "$(USERNAME)", and a dynamic tag (e.g. $(IMAGE):$(TAG)).
    83  The registry and username can be overridden by exporting REGISTRY, and USERNAME
    84  respectively.
    85  
    86  endef
    87  
    88  all: unit-tests conform image-conform lint
    89  
    90  .PHONY: clean
    91  clean:  ## Cleans up all artifacts.
    92  	@rm -rf $(ARTIFACTS)
    93  
    94  target-%:  ## Builds the specified target defined in the Dockerfile. The build result will only remain in the build cache.
    95  	@$(BUILD) --target=$* $(COMMON_ARGS) $(TARGET_ARGS) $(CI_ARGS) .
    96  
    97  local-%:  ## Builds the specified target defined in the Dockerfile using the local output type. The build result will be output to the specified local destination.
    98  	@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)"
    99  
   100  lint-golangci-lint:  ## Runs golangci-lint linter.
   101  	@$(MAKE) target-$@
   102  
   103  lint-gofumpt:  ## Runs gofumpt linter.
   104  	@$(MAKE) target-$@
   105  
   106  .PHONY: fmt
   107  fmt:  ## Formats the source code
   108  	@docker run --rm -it -v $(PWD):/src -w /src golang:$(GO_VERSION) \
   109  		bash -c "export GO111MODULE=on; export GOPROXY=https://proxy.golang.org; \
   110  		go install mvdan.cc/gofumpt@$(GOFUMPT_VERSION) && \
   111  		gofumpt -w ."
   112  
   113  lint-goimports:  ## Runs goimports linter.
   114  	@$(MAKE) target-$@
   115  
   116  .PHONY: base
   117  base:  ## Prepare base toolchain
   118  	@$(MAKE) target-$@
   119  
   120  .PHONY: unit-tests
   121  unit-tests:  ## Performs unit tests
   122  	@$(MAKE) local-$@ DEST=$(ARTIFACTS)
   123  
   124  .PHONY: unit-tests-race
   125  unit-tests-race:  ## Performs unit tests with race detection enabled.
   126  	@$(MAKE) target-$@
   127  
   128  .PHONY: coverage
   129  coverage:  ## Upload coverage data to codecov.io.
   130  	bash -c "bash <(curl -s https://codecov.io/bash) -f $(ARTIFACTS)/coverage.txt -X fix"
   131  
   132  .PHONY: $(ARTIFACTS)/conform-darwin-amd64
   133  $(ARTIFACTS)/conform-darwin-amd64:
   134  	@$(MAKE) local-conform-darwin-amd64 DEST=$(ARTIFACTS)
   135  
   136  .PHONY: conform-darwin-amd64
   137  conform-darwin-amd64: $(ARTIFACTS)/conform-darwin-amd64  ## Builds executable for conform-darwin-amd64.
   138  
   139  .PHONY: $(ARTIFACTS)/conform-darwin-arm64
   140  $(ARTIFACTS)/conform-darwin-arm64:
   141  	@$(MAKE) local-conform-darwin-arm64 DEST=$(ARTIFACTS)
   142  
   143  .PHONY: conform-darwin-arm64
   144  conform-darwin-arm64: $(ARTIFACTS)/conform-darwin-arm64  ## Builds executable for conform-darwin-arm64.
   145  
   146  .PHONY: $(ARTIFACTS)/conform-linux-amd64
   147  $(ARTIFACTS)/conform-linux-amd64:
   148  	@$(MAKE) local-conform-linux-amd64 DEST=$(ARTIFACTS)
   149  
   150  .PHONY: conform-linux-amd64
   151  conform-linux-amd64: $(ARTIFACTS)/conform-linux-amd64  ## Builds executable for conform-linux-amd64.
   152  
   153  .PHONY: $(ARTIFACTS)/conform-linux-arm64
   154  $(ARTIFACTS)/conform-linux-arm64:
   155  	@$(MAKE) local-conform-linux-arm64 DEST=$(ARTIFACTS)
   156  
   157  .PHONY: conform-linux-arm64
   158  conform-linux-arm64: $(ARTIFACTS)/conform-linux-arm64  ## Builds executable for conform-linux-arm64.
   159  
   160  .PHONY: conform
   161  conform: conform-darwin-amd64 conform-darwin-arm64 conform-linux-amd64 conform-linux-arm64  ## Builds executables for conform.
   162  
   163  .PHONY: lint-markdown
   164  lint-markdown:  ## Runs markdownlint.
   165  	@$(MAKE) target-$@
   166  
   167  .PHONY: lint
   168  lint: lint-golangci-lint lint-gofumpt lint-goimports lint-markdown  ## Run all linters for the project.
   169  
   170  .PHONY: image-conform
   171  image-conform:  ## Builds image for conform.
   172  	@$(MAKE) target-$@ TARGET_ARGS="--tag=$(REGISTRY)/$(USERNAME)/conform:$(TAG)"
   173  
   174  .PHONY: rekres
   175  rekres:
   176  	@docker pull $(KRES_IMAGE)
   177  	@docker run --rm -v $(PWD):/src -w /src -e GITHUB_TOKEN $(KRES_IMAGE)
   178  
   179  .PHONY: help
   180  help:  ## This help menu.
   181  	@echo "$$HELP_MENU_HEADER"
   182  	@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
   183  
   184  .PHONY: release-notes
   185  release-notes:
   186  	mkdir -p $(ARTIFACTS)
   187  	@ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG)
   188  
   189  .PHONY: conformance
   190  conformance:
   191  	@docker pull $(CONFORMANCE_IMAGE)
   192  	@docker run --rm -it -v $(PWD):/src -w /src $(CONFORMANCE_IMAGE) enforce
   193