Skip to content

Commit 956bd0a

Browse files
authored
ci/packagespec (#9653)
* add packagespec build system - The majority of changes in this commit are files generated by packagespec (everything in the packages-oss.lock directory). * add .yamllint * update to packagespec@fd54aea4 * ci: bust packagespec cache - Change to packagespec results in package IDs that can use git tag refs, not just commit refs. * update to packagepsec@5fc121d0 - This busts all caches, because of a change to the way we no longer traverse from tag refs to commit refs, due to the potential confusion this can cause. - See hashicorp/packagespec@fd54aea for the original change to packagespec necessitating this. * update to packagespec@5e6c87b6 - This completes the change to allowing git tag refs to be used for source IDs, begun in f130b940a8fbe3e9398225b08ea1d63420bef7b6 * update to packagespec@4d3c9e8b - This busts cache, needed to apply previous change. * remove RELEASE_BUILD_WORKFLOW_NAME * update packagespec, add watch-ci target * fix package names (do not refer to EDITION) * remove EDITION input from packages-oss.yml * bump package cache, update packagespec * update packagespec, add 'aliases' target * update packagespec; less output noise * ci: give release bundle file a better name - When performing a release build, this will include the build ID as part of the name, making it easier to distinguish from other builds. * ci: create aliases tarball artifact * ci: cache package metadata files * ci: add metadata artifact * ci: bust circleci package cache * Revert "ci: bust circleci package cache" This reverts commit 1320d182613466f0999d63f5742db12ac17f8e92. * ci: remove aliases artifact * ci: use buildID not workflowName to id artifacts * packages: add BUNDLE_NAME metadata * do not cache package metadata with binaries * ci: bump package cache * ci: debugging * ci: fix package cache; update packagespec * ci: update packagespec to 10e7beb2 * ci: write package metadata and aliases * ci: switch to .zip artifacts * switch package bundle back to tar.gz (from zip) - Because of the way zip works, the zip archive was over 2GB rather than under 750MB as with tar.gz. * bump packagespec, adds list-staged-builds * update packagespec * add publish stub + general tidy up * bump packagespec * bump packagespec; add make publish-config * Makefile: tidy up packagespec targets * pass PRODUCT_REPO_ROOT to packagespec * bump go to 1.14.6 * packages-oss.yml: use more explicit base image * bump packagespec to b899b7c1 * bump packagespec to f040ce8f * packages-oss.yml: pin base image to digest - This digest is pointed to by debian:buster-20200720 - Using a specific digest ensures that builds use the same base image in all contexts * add release-repo; bump packagespec * remove BUILD_TAGS and -tags flag * bump packagespec to e444f742 * bump to go1.14.7 * ci: bump to go1.14.7
1 parent 469fc39 commit 956bd0a

File tree

57 files changed

+8412
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+8412
-64
lines changed

.circleci/config.yml

Lines changed: 1343 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.circleci/config/@build-release.yml

Lines changed: 1329 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
{{- $data := (datasource "package-list") -}}
2+
{{- /*
3+
BUILD_ID is set by the staging workflow to produce an identifiable build.
4+
*/ -}}
5+
{{- $buildID := (env.Getenv "BUILD_ID" "standalone") -}}
6+
{{- $workflowName := (env.Getenv "RELEASE_BUILD_WORKFLOW_NAME" "build-standalone") -}}
7+
{{- $packages := $data.packages -}}
8+
{{- $layers := $data.layers -}}
9+
{{- $revision := (env.Getenv "PRODUCT_REVISION") -}}
10+
{{- define "cache-key"}}{{template "cache-version"}}-{{.}}{{end -}}
11+
{{- define "cache-version"}}cache002{{end -}}
12+
{{- /*
13+
Any change to cache-version invalidates all build layer and package caches.
14+
*/ -}}
15+
# Current cache version: {{template "cache-version"}}
16+
17+
executors:
18+
releaser:
19+
docker:
20+
- image: circleci/buildpack-deps
21+
environment:
22+
PRODUCT_REVISION: "{{if $revision}}{{$revision}}{{end}}"
23+
AUTO_INSTALL_TOOLS: 'YES'
24+
shell: /usr/bin/env bash -euo pipefail -c
25+
26+
workflows:
27+
{{$workflowName}}:
28+
jobs:
29+
- cache-builder-images:
30+
filters:
31+
branches:
32+
only:
33+
- /build-.*/
34+
- /ci.*/
35+
{{- range $packages}}
36+
- {{.meta.BUILD_JOB_NAME}}: { requires: [ cache-builder-images ] }
37+
{{- end }}
38+
- bundle-releases:
39+
requires:
40+
{{- range $packages}}
41+
- {{.meta.BUILD_JOB_NAME}}{{end}}
42+
jobs:
43+
cache-builder-images:
44+
executor: releaser
45+
steps:
46+
- setup_remote_docker
47+
- checkout
48+
- write-build-layer-cache-keys
49+
50+
# Load best available cached image.
51+
52+
{{- $targetLayerType := "build-static-assets" }}
53+
{{- $targetLayer := .}}
54+
{{- range $layers}}
55+
{{- if eq .type $targetLayerType }}
56+
{{- $targetLayer = .}}
57+
- restore_cache:
58+
keys:
59+
{{- range .meta.circleci.CACHE_KEY_PREFIX_LIST}}
60+
- {{template "cache-key" .}}
61+
{{- end}}
62+
- run:
63+
name: Finish early if loaded exact match from cache.
64+
command: |
65+
if [ -f {{.archivefile}} ]; then
66+
echo "Exact match found in cache, skipping build."
67+
circleci-agent step halt
68+
else
69+
echo "No exact match found, proceeding with build."
70+
fi
71+
- run: LAYER_SPEC_ID={{.name}} make -C packages*.lock load-builder-cache
72+
{{- end}}{{end}}
73+
74+
# No exact match was found, so build each layer up to target type.
75+
76+
{{- $finished := false }}
77+
{{- range $layers}}
78+
{{- if not $finished }}
79+
{{- $finished = eq .type $targetLayerType}}
80+
- run: make -f packages*.lock/layer.mk {{.name}}-image
81+
{{- end}}
82+
{{- end}}
83+
84+
# Save the target layer archive.
85+
86+
- run: make -f packages*.lock/layer.mk {{$targetLayer.name}}-save
87+
88+
# Store the target layer archive as all the relevant cache names.
89+
90+
{{- $lastArchive := $targetLayer.archivefile}}
91+
{{- range $i, $l := $targetLayer.meta.builtin.LAYER_LIST}}
92+
{{- $currentArchive := $l.archive}}
93+
{{- if ne $currentArchive $lastArchive }}
94+
- run: mv {{$lastArchive}} {{$currentArchive}}
95+
{{- end}}
96+
- save_cache:
97+
key: {{template "cache-key" (index $targetLayer.meta.circleci.CACHE_KEY_PREFIX_LIST $i)}}
98+
paths:
99+
- {{$currentArchive}}
100+
{{- $lastArchive = $currentArchive }}
101+
{{- end}}
102+
103+
{{- range $packages}}
104+
{{.meta.BUILD_JOB_NAME}}:
105+
executor: releaser
106+
environment:
107+
- PACKAGE_SPEC_ID: {{.packagespecid}}
108+
steps:
109+
- setup_remote_docker
110+
- checkout
111+
112+
# Restore the package cache first, we might not need to rebuild.
113+
- write-package-cache-key
114+
- restore_cache:
115+
key: '{{template "cache-key" .meta.circleci.PACKAGE_CACHE_KEY}}'
116+
- run:
117+
name: Check the cache status.
118+
command: |
119+
if ! { PKG=$(find .buildcache/packages/store -maxdepth 1 -mindepth 1 -name '*.zip' 2> /dev/null) && [ -n "$PKG" ]; }; then
120+
echo "No package found, continuing with build."
121+
exit 0
122+
fi
123+
echo "Package already cached, skipping build."
124+
circleci-agent step halt
125+
126+
# We need to rebuild, so load the builder cache.
127+
- write-build-layer-cache-keys
128+
- restore_cache:
129+
keys:
130+
{{- range .meta.circleci.BUILDER_CACHE_KEY_PREFIX_LIST}}
131+
- {{template "cache-key" .}}
132+
{{- end}}
133+
- run: make -C packages*.lock load-builder-cache
134+
- run: make -C packages*.lock package
135+
- run: ls -lahR .buildcache/packages
136+
# Save package cache.
137+
- save_cache:
138+
key: '{{template "cache-key" .meta.circleci.PACKAGE_CACHE_KEY}}'
139+
paths:
140+
- .buildcache/packages/store
141+
# Save builder image cache if necessary.
142+
# The range should only iterate over a single layer.
143+
{{- $pkg := . -}}
144+
{{- range $idx, $layerInfo := .meta.builtin.BUILD_LAYERS }}
145+
{{- if eq $layerInfo.type "warm-go-build-vendor-cache" }}
146+
{{- with $layerInfo }}
147+
{{- $circleCICacheKey := (index $pkg.meta.circleci.BUILDER_CACHE_KEY_PREFIX_LIST $idx) }}
148+
- run:
149+
name: Check builder cache status
150+
command: |
151+
if [ -f {{.archive}} ]; then
152+
echo "Builder image already cached, skipping cache step."
153+
circleci-agent step halt
154+
fi
155+
- run: make -f packages*.lock/layer.mk {{.name}}-save
156+
- save_cache:
157+
key: '{{template "cache-key" $circleCICacheKey}}'
158+
paths:
159+
- {{.archive}}
160+
{{- end}}
161+
{{- end}}
162+
{{- end}}
163+
{{end}}
164+
165+
bundle-releases:
166+
executor: releaser
167+
steps:
168+
- checkout
169+
- write-all-package-cache-keys
170+
{{- range $packages}}
171+
- load-{{.meta.BUILD_JOB_NAME}}
172+
- run:
173+
environment:
174+
PACKAGE_SPEC_ID: {{.packagespecid}}
175+
name: Write package metadata for {{.meta.BUILD_JOB_NAME}}
176+
command: |
177+
make package-meta
178+
{{- end}}
179+
- run:
180+
name: Write package aliases
181+
command:
182+
make aliases
183+
- run:
184+
name: List Build Cache
185+
command: ls -lahR .buildcache
186+
187+
# Surface the package store directory as an artifact.
188+
# This makes each zipped package separately downloadable.
189+
- store_artifacts:
190+
path: .buildcache/packages
191+
destination: packages-{{$buildID}}
192+
193+
# Surface a tarball of the whole package store as an artifact.
194+
- run: tar -czf packages-{{$buildID}}.tar.gz .buildcache/packages
195+
- store_artifacts:
196+
path: packages-{{$buildID}}.tar.gz
197+
destination: packages-{{$buildID}}.tar.gz
198+
199+
# Surface a tarball of just the metadata files.
200+
- run: tar -czf meta-{{$buildID}}.tar.gz .buildcache/packages/store/*.json
201+
- store_artifacts:
202+
path: meta-{{$buildID}}.tar.gz
203+
destination: meta-{{$buildID}}.tar.gz
204+
205+
commands:
206+
{{- range $packages }}
207+
load-{{.meta.BUILD_JOB_NAME}}:
208+
steps:
209+
- restore_cache:
210+
key: '{{template "cache-key" .meta.circleci.PACKAGE_CACHE_KEY}}'
211+
{{end}}
212+
213+
write-build-layer-cache-keys:
214+
steps:
215+
- run:
216+
name: Write builder layer cache keys
217+
command: make -C packages*.lock write-builder-cache-keys
218+
219+
write-package-cache-key:
220+
steps:
221+
- run:
222+
name: Write package cache key
223+
command: make -C packages*.lock write-package-cache-key
224+
225+
write-all-package-cache-keys:
226+
steps:
227+
- run:
228+
name: Write package cache key
229+
command: make -C packages*.lock write-all-package-cache-keys

.circleci/config/@config.yml

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,6 @@
11
---
22
version: 2.1
33

4-
references:
5-
images:
6-
node: &NODE_IMAGE node:10-buster # Pin Node.js to major version (ex: 10)
4+
orbs:
5+
slack: circleci/slack@3.2.0
76

8-
cache:
9-
go-sum: &GO_SUM_CACHE_KEY go-sum-v1-{{ checksum "go.sum" }}
10-
yarn-lock: &YARN_LOCK_CACHE_KEY yarn-lock-v6-{{ checksum "ui/yarn.lock" }}
11-
12-
# more commands defined in commands/
13-
commands:
14-
restore_yarn_cache:
15-
steps:
16-
- restore_cache:
17-
key: *YARN_LOCK_CACHE_KEY
18-
save_yarn_cache:
19-
steps:
20-
- save_cache:
21-
key: *YARN_LOCK_CACHE_KEY
22-
paths:
23-
- ui/node_modules
24-
25-
executors:
26-
go-machine:
27-
machine: true
28-
shell: /usr/bin/env bash -euo pipefail -c
29-
environment:
30-
GO111MODULE: "off"
31-
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
32-
GO_VERSION: 1.14.7 # Pin Go to patch version (ex: 1.2.3)
33-
GOTESTSUM_VERSION: 0.5.2 # Pin gotestsum to patch version (ex: 1.2.3)
34-
GO_TAGS: ""
35-
working_directory: /go/src/github.com/hashicorp/vault
36-
node:
37-
docker:
38-
- image: *NODE_IMAGE
39-
environment:
40-
JOBS: 2
41-
shell: /usr/bin/env bash -euo pipefail -c
42-
working_directory: /go/src/github.com/hashicorp/vault
43-
python:
44-
docker:
45-
- image: python:3-alpine
46-
shell: /usr/bin/env bash -euo pipefail -c
47-
working_directory: /go/src/github.com/hashicorp/vault
48-
alpine:
49-
docker:
50-
- image: alpine:3.10.2
51-
shell: /bin/sh
52-
working_directory: /go/src/github.com/hashicorp/vault
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
restore_yarn_cache:
2+
steps:
3+
- restore_cache:
4+
key: &YARN_LOCK_CACHE_KEY yarn-lock-v6-{{ checksum "ui/yarn.lock" }}
5+
save_yarn_cache:
6+
steps:
7+
- save_cache:
8+
key: *YARN_LOCK_CACHE_KEY
9+
paths:
10+
- ui/node_modules
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
go-machine:
2+
machine: true
3+
shell: /usr/bin/env bash -euo pipefail -c
4+
environment:
5+
GO111MODULE: "off"
6+
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
7+
GO_VERSION: 1.14.7 # Pin Go to patch version (ex: 1.2.3)
8+
GOTESTSUM_VERSION: 0.5.2 # Pin gotestsum to patch version (ex: 1.2.3)
9+
GO_TAGS: ""
10+
working_directory: /go/src/github.com/hashicorp/vault
11+
node:
12+
docker:
13+
- image: node:10-buster
14+
shell: /usr/bin/env bash -euo pipefail -c
15+
working_directory: /go/src/github.com/hashicorp/vault
16+
python:
17+
docker:
18+
- image: python:3-alpine
19+
shell: /usr/bin/env bash -euo pipefail -c
20+
working_directory: /go/src/github.com/hashicorp/vault
21+
alpine:
22+
docker:
23+
- image: alpine:3.10.2
24+
shell: /bin/sh
25+
working_directory: /go/src/github.com/hashicorp/vault

.yamllint

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
extends: relaxed
4+
5+
rules:
6+
comments: disable
7+
comments-indentation: disable
8+
line-length: disable
9+
commas:
10+
max-spaces-after: -1

0 commit comments

Comments
 (0)