-
Notifications
You must be signed in to change notification settings - Fork 70
Handle build info more accurately #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,40 +5,47 @@ SHELL := /bin/bash -o pipefail | |
| # the output is consistent across environments. | ||
| VERSION ?= $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD) | ||
|
|
||
| # allows for passing additional args to the build e.g. | ||
| # make build GO_ARGS='--ldflags "-s -w"' | ||
| GO_ARGS ?= "" | ||
|
|
||
| # Enables support for tools such as https://github.com/rakyll/gotest | ||
| TEST_COMMAND ?= go test | ||
|
|
||
| # The compute tests can sometimes exceed the default 10m limit. | ||
| TESTARGS ?= -timeout 15m ./{cmd,pkg}/... | ||
| TEST_ARGS ?= -timeout 15m ./{cmd,pkg}/... | ||
|
|
||
| CLI_ENV ?= "development" | ||
|
|
||
| # TODO: This is duplicated in .goreleaser and we should figure out how to clean | ||
| # this up so we have one source of truth. | ||
| LDFLAGS = -ldflags "\ | ||
| -X 'github.com/fastly/cli/pkg/revision.AppVersion=${VERSION}' \ | ||
| -X 'github.com/fastly/cli/pkg/revision.GitCommit=$(shell git rev-parse --short HEAD || echo unknown)' \ | ||
| -X 'github.com/fastly/cli/pkg/revision.GoVersion=$(shell go version)' \ | ||
| -X 'github.com/fastly/cli/pkg/revision.Environment=${CLI_ENV}' \ | ||
| " | ||
| GOHOSTOS ?= $(shell go env GOHOSTOS || echo unknown) | ||
| GOHOSTARCH ?= $(shell go env GOHOSTARCH || echo unknown) | ||
|
|
||
| GO_FILES = $(shell find cmd pkg -type f -name '*.go') | ||
|
|
||
| # You can pass flags to goreleaser via GORELEASER_ARGS | ||
| # --skip-validate will skip the checks | ||
| # --rm-dist will save you deleting the dist dir | ||
| # --single-target will be quicker and only build for your os & architecture | ||
| # e.g. | ||
| # make fastly GORELEASER_ARGS="--skip-validate --rm-dist" | ||
| fastly: $(GO_FILES) | ||
06kellyjac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @go build -trimpath $(LDFLAGS) -o "$@" ./cmd/fastly | ||
| @GOHOSTOS="${GOHOSTOS}" GOHOSTARCH="${GOHOSTARCH}" goreleaser build ${GORELEASER_ARGS} | ||
|
|
||
|
|
||
| # useful for attaching a debugger such as https://github.com/go-delve/delve | ||
| debug: | ||
| @go build -gcflags="all=-N -l" $(LDFLAGS) -o "fastly" ./cmd/fastly | ||
| @go build -gcflags="all=-N -l" $(GO_ARGS) -o "fastly" ./cmd/fastly | ||
|
|
||
| .PHONY: all | ||
| all: dependencies config tidy fmt vet staticcheck gosec test build install | ||
|
|
||
| # update goreleaser inline with the release GHA workflow | ||
| .PHONY: dependencies | ||
| dependencies: | ||
| go install github.com/securego/gosec/v2/cmd/gosec@latest | ||
| go install honnef.co/go/tools/cmd/staticcheck@latest | ||
| go install github.com/mgechev/revive@latest | ||
| go install github.com/goreleaser/[email protected] | ||
|
|
||
| .PHONY: tidy | ||
| tidy: | ||
|
|
@@ -67,15 +74,15 @@ staticcheck: | |
|
|
||
| .PHONY: test | ||
| test: config | ||
| @$(TEST_COMMAND) -race $(TESTARGS) | ||
| @$(TEST_COMMAND) -race $(TEST_ARGS) | ||
|
|
||
| .PHONY: build | ||
| build: config | ||
| go build $(LDFLAGS) ./cmd/fastly | ||
| go build $(GO_ARGS) ./cmd/fastly | ||
|
|
||
| .PHONY: install | ||
| install: config | ||
| go install $(LDFLAGS) ./cmd/fastly | ||
| go install $(GO_ARGS) ./cmd/fastly | ||
|
|
||
| .PHONY: changelog | ||
| changelog: | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.