Skip to content

Commit

Permalink
Packagespec v0.1.2/master (#9995)
Browse files Browse the repository at this point in the history
* packagespec v0.1.2 - prep: remove unneeded code

* packagespec v0.1.2 - packagespec init

* packagespec v0.1.2 - make packages

* packagespec v0.1.3 - make packages
  • Loading branch information
samsalisbury authored Sep 28, 2020
1 parent d626f58 commit 9ef96e4
Show file tree
Hide file tree
Showing 54 changed files with 5,108 additions and 4,100 deletions.
1,574 changes: 1,067 additions & 507 deletions .circleci/config.yml

Large diffs are not rendered by default.

1,706 changes: 1,217 additions & 489 deletions .circleci/config/@build-release.yml

Large diffs are not rendered by default.

229 changes: 0 additions & 229 deletions .circleci/config/@build-release.yml.tpl

This file was deleted.

2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor/* linguist-vendored
website/* linguist-documentation

/packagespec.mk linguist-generated
79 changes: 7 additions & 72 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ ci-lint:
prep: fmtcheck
@sh -c "'$(CURDIR)/scripts/goversioncheck.sh' '$(GO_VERSION_MIN)'"
@$(GO_CMD) generate $($(GO_CMD) list ./... | grep -v /vendor/)
@# Remove old (now broken) husky git hooks.
@[ ! -d .git/hooks ] || grep -l '^# husky$$' .git/hooks/* | xargs rm -f
@if [ -d .git/hooks ]; then cp .hooks/* .git/hooks/; fi

PACKAGES_LOCK_DIR := $(shell find . -mindepth 1 -maxdepth 1 \
-type d -name 'packages*.lock')

# bootstrap the build by downloading additional tools needed to build
ci-bootstrap:
@for tool in $(EXTERNAL_TOOLS_CI) ; do \
Expand Down Expand Up @@ -249,76 +244,14 @@ hana-database-plugin:
mongodb-database-plugin:
@CGO_ENABLED=0 $(GO_CMD) build -o bin/mongodb-database-plugin ./plugins/database/mongodb/mongodb-database-plugin

# WRITE_GENERATED_FILE_HEADER overwrites the file specified, replacing its contents with
# the header warning people not to attempt to edit or merge the file. You should call this
# before writing the generated contents to the file.
# Args: 1: File to write; 2: Command to generate it; 3: Source files to edit/merge instead.
define WRITE_GENERATED_FILE_HEADER
echo "### ***" > $(1); \
echo "### WARNING: DO NOT manually EDIT or MERGE this file, it is generated by '$(2)'." >> $(1); \
echo "### INSTEAD: Edit or merge the source in $(3) then run '$(2)'." >> $(1); \
echo "### ***" >> $(1)
endef

## begin packagespec integration ##

# The plan is to generate this packagespec integration section automatically.
# By keeping it in a contiguous block for now, it will be easier to
# auto-generate when we get to it.

SPEC_FILE_PATTERN := packages*.yml
# SPEC is the human-managed description of which packages we are able to build.
SPEC := $(shell find . -mindepth 1 -maxdepth 1 -name '$(SPEC_FILE_PATTERN)')
ifneq ($(words $(SPEC)),1)
$(error Found $(words $(SPEC)) $(SPEC_FILE_PATTERN) files, need exactly 1: $(SPEC))
endif
SPEC_FILENAME := $(notdir $(SPEC))
SPEC_MODIFIER := $(SPEC_FILENAME:packages%.yml=%)
# LOCKDIR contains the lockfile and layer files.
LOCKDIR := packages$(SPEC_MODIFIER).lock
LOCKFILE := $(LOCKDIR)/pkgs.yml

export PACKAGE_SPEC_ID LAYER_SPEC_ID PRODUCT_REVISION PRODUCT_VERSION

# PACKAGESPEC_TARGETS are convenience aliases for targets defined in $(LOCKDIR)/Makefile
PACKAGESPEC_TARGETS := \
build build-all build-ci \
aliases meta package \
package-meta stage-config stage \
watch-ci publish-config publish list-staged-builds

$(PACKAGESPEC_TARGETS):
@PRODUCT_REPO_ROOT="$(shell git rev-parse --show-toplevel)" $(MAKE) -C $(LOCKDIR) $@

# packages regenerates $(LOCKDIR) from $(SPEC) using packagespec. This is only for
# internal HashiCorp use, as it has dependencies not available to OSS contributors.
packages:
@command -v packagespec > /dev/null 2>&1 || { \
echo "Please install packagespec."; \
echo "Note: packagespec is only available to HashiCorp employees at present."; \
exit 1; \
}
@packagespec lock -specfile $(SPEC) -lockdir $(LOCKDIR)
@$(MAKE) ci-config

.PHONY: $(PACKAGESPEC_TARGETS) packages
## end packagespec integration ##
# Tell packagespec where to write its CircleCI config.
PACKAGESPEC_CIRCLECI_CONFIG := .circleci/config/@build-release.yml

CI_WORKFLOW_TPL := .circleci/config/@build-release.yml.tpl
CI_WORKFLOW := .circleci/config/@build-release.yml

.PHONY: ci-update-release-packages $(CI_WORKFLOW)
ci-update-release-packages: $(CI_WORKFLOW)
@echo $^

$(CI_WORKFLOW): $(LOCKFILE) $(CI_WORKFLOW_TPL)
@\
echo "==> Updating $@ to match $<"; \
$(call WRITE_GENERATED_FILE_HEADER,$@,make $@,$^); \
cat $< | gomplate -f $(CI_WORKFLOW_TPL) -d 'package-list=stdin://?type=application/yaml' >> $@
# Tell packagespec to re-run 'make ci-config' whenever updating its own CI config.
PACKAGESPEC_HOOK_POST_CI_CONFIG := $(MAKE) ci-config

.PHONY: ci-config
ci-config: ci-update-release-packages
ci-config: $(PACKAGESPEC_CIRCLECI_CONFIG)
@$(MAKE) -C .circleci ci-config
.PHONY: ci-verify
ci-verify:
Expand All @@ -327,3 +260,5 @@ ci-verify:
.PHONY: bin default prep test vet bootstrap ci-bootstrap fmt fmtcheck mysql-database-plugin mysql-legacy-database-plugin cassandra-database-plugin influxdb-database-plugin postgresql-database-plugin mssql-database-plugin hana-database-plugin mongodb-database-plugin static-assets ember-dist ember-dist-dev static-dist static-dist-dev assetcheck check-vault-in-path check-browserstack-creds test-ui-browserstack packages build build-ci

.NOTPARALLEL: ember-dist ember-dist-dev static-assets

-include packagespec.mk
6 changes: 4 additions & 2 deletions packages-oss.lock/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9ef96e4

Please sign in to comment.