pulumi/Makefile
Paul Stack 1d3c9edb6c
Ensure that make brew works as expected rather than passing empty version (#6566)
Fixes:#6565

As part of #6460, the logic for determing the version of the build was
moved to be a dependency on pulumictl.

Unfortunately, the homebrew installs use the "make dist" command to
build + install Pulumi to the user maching and as that would have a
dependency on pulumictl and it not existing on the user machine, it
would pass an empty version to the ldflag

This then manifested to the user as:

```
▶ pulumi version
warning: A new version of Pulumi is available. To upgrade from version '0.0.0' to '2.22.0', run
   $ brew upgrade pulumi
or visit https://pulumi.com/docs/reference/install/ for manual instructions and release notes.
```

We are able to mitigate this behaviour by bringing back the get-version
script and using that script as part of the make brew installation

We can see that the versions are the same between the 2 different
installation techniques

```
make dist <------- uses pulumict
DIST:
go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=2.24.0-alpha.1616029310+787eb70a" github.com/pulumi/pulumi/sdk/v2/dotnet/cmd/pulumi-language-dotnet
DIST:
BUILD:
```

```
make brew <----- uses the legacy script
▶ make brew
BREW:
go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=v2.24.0-alpha.1616029310+g787eb70a2" github.com/pulumi/pulumi/sdk/v2/dotnet/cmd/pulumi-language-dotnet
BREW:
```

A full post mortem will be carried out to ensure we mitigate these
types of errors going forward and that we are able to better test
these types of situations
2021-03-18 02:07:02 +00:00

85 lines
2.7 KiB
Makefile

PROJECT_NAME := Pulumi SDK
SUB_PROJECTS := sdk/dotnet sdk/nodejs sdk/python sdk/go
include build/common.mk
PROJECT := github.com/pulumi/pulumi/pkg/v2/cmd/pulumi
PROJECT_PKGS := $(shell cd ./pkg && go list ./... | grep -v /vendor/)
TESTS_PKGS := $(shell cd ./tests && go list ./... | grep -v tests/templates | grep -v /vendor/)
VERSION := $(shell pulumictl get version)
TESTPARALLELISM := 10
ensure::
$(call STEP_MESSAGE)
@echo "cd sdk && go mod download"; cd sdk && go mod download
@echo "cd pkg && go mod download"; cd pkg && go mod download
@echo "cd tests && go mod download"; cd tests && go mod download
build-proto::
cd sdk/proto && ./generate.sh
.PHONY: generate
generate::
$(call STEP_MESSAGE)
echo "Generate static assets bundle for docs generator"
cd pkg && go generate ./codegen/docs/gen.go
build:: generate
cd pkg && go install -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=${VERSION}" ${PROJECT}
build_debug:: generate
cd pkg && go install -gcflags="all=-N -l" -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=${VERSION}" ${PROJECT}
install:: generate
cd pkg && GOBIN=$(PULUMI_BIN) go install -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=${VERSION}" ${PROJECT}
install_all:: install
dist:: build
cd pkg && go install -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=${VERSION}" ${PROJECT}
# NOTE: the brew target intentionally avoids the dependency on `build`, as it does not require the language SDKs.
brew:: BREW_VERSION := $(shell scripts/get-version HEAD)
brew::
cd pkg && go install -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=${BREW_VERSION}" ${PROJECT}
lint::
for DIR in "pkg" "sdk" "tests" ; do \
pushd $$DIR ; golangci-lint run -c ../.golangci.yml --timeout 5m ; popd ; \
done
test_fast:: build
cd pkg && $(GO_TEST_FAST) ${PROJECT_PKGS}
test_build:: $(SUB_PROJECTS:%=%_install)
cd tests/integration/construct_component/testcomponent && yarn install && yarn link @pulumi/pulumi && yarn run tsc
test_all:: build test_build $(SUB_PROJECTS:%=%_install)
cd pkg && $(GO_TEST) ${PROJECT_PKGS}
cd tests && $(GO_TEST) -p=1 ${TESTS_PKGS}
.PHONY: publish_tgz
publish_tgz:
$(call STEP_MESSAGE)
./scripts/publish_tgz.sh
.PHONY: publish_packages
publish_packages:
$(call STEP_MESSAGE)
./scripts/publish_packages.sh
.PHONY: test_containers
test_containers:
$(call STEP_MESSAGE)
./scripts/test-containers.sh ${VERSION}
# The travis_* targets are entrypoints for CI.
.PHONY: travis_cron travis_push travis_pull_request travis_api
travis_cron: install dist all
travis_push: install dist publish_tgz only_test publish_packages
travis_pull_request:
$(call STEP_MESSAGE)
@echo moved to GitHub Actions
travis_api: install dist all