Moves release build into Docker container and adds web asset check at dist time.

This commit is contained in:
James Phillips 2016-02-17 23:16:47 -08:00
parent 9ccfb68bce
commit 7beec098c8
6 changed files with 94 additions and 87 deletions

72
Vagrantfile vendored
View File

@ -1,72 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = '2'
@script = <<SCRIPT
GOVERSION="1.6"
SRCROOT="/opt/go"
SRCPATH="/opt/gopath"
# Get the ARCH
ARCH=`uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|'`
# Install Go
sudo apt-get update
sudo apt-get install -y build-essential git-core zip curl
# Install Go
cd /tmp
curl -s -O https://storage.googleapis.com/golang/go${GOVERSION}.linux-${ARCH}.tar.gz
tar -xvf go${GOVERSION}.linux-${ARCH}.tar.gz
sudo mv go $SRCROOT
sudo chmod 775 $SRCROOT
sudo chown vagrant:vagrant $SRCROOT
# Setup the GOPATH; even though the shared folder spec gives the consul
# directory the right user/group, we need to set it properly on the
# parent path to allow subsequent "go get" commands to work. We can't do
# normal -R here because VMWare complains if we try to update the shared
# folder permissions, so we just update the folders that matter.
sudo mkdir -p $SRCPATH
find /opt/gopath -type d -maxdepth 3 | xargs sudo chown vagrant:vagrant
cat <<EOF >/tmp/gopath.sh
export GOPATH="$SRCPATH"
export GOROOT="$SRCROOT"
export PATH="$SRCROOT/bin:$SRCPATH/bin:\$PATH"
EOF
sudo mv /tmp/gopath.sh /etc/profile.d/gopath.sh
sudo chmod 0755 /etc/profile.d/gopath.sh
source /etc/profile.d/gopath.sh
# Install go tools
go get golang.org/x/tools/cmd/cover
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision 'shell', inline: @script, privileged: false
config.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/consul'
%w[vmware_fusion vmware_workstation].each do |p|
config.vm.provider p do |v|
v.vmx['memsize'] = '2048'
v.vmx['numvcpus'] = '2'
v.vmx['cpuid.coresPerSocket'] = '1'
end
end
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
config.vm.define '64bit' do |n1|
n1.vm.box = 'hashicorp/precise64'
end
config.push.define "www", strategy: "local-exec" do |push|
push.script = "scripts/website_push.sh"
end
end

View File

@ -4,6 +4,7 @@
set -e
export GO15VENDOREXPERIMENT=1
export CGO_ENABLED=0
# Get the parent directory of where this script is.
SOURCE="${BASH_SOURCE[0]}"

View File

@ -0,0 +1,27 @@
FROM ubuntu:trusty
ENV GOVERSION 1.6
RUN apt-get update -y && \
apt-get install --no-install-recommends -y -q \
build-essential \
ca-certificates \
curl \
git \
ruby \
ruby-dev \
zip && \
gem install bundler
RUN mkdir /goroot && \
mkdir /gopath && \
curl https://storage.googleapis.com/golang/go${GOVERSION}.linux-amd64.tar.gz | \
tar xzf - -C /goroot --strip-components=1
ENV GOPATH /gopath
ENV GOROOT /goroot
ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
RUN mkdir -p $GOPATH/src/github.com/hashicorp/consul
WORKDIR $GOPATH/src/github.com/hashicorp/consul
CMD ./scripts/dist_build.sh

View File

@ -3,7 +3,7 @@ set -e
export GO15VENDOREXPERIMENT=1
# Get the version from the command line
# Get the version from the command line.
VERSION=$1
if [ -z $VERSION ]; then
echo "Please specify a version."
@ -15,23 +15,23 @@ SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
# Change into that dir because we expect that
# Change into that dir because we expect that.
cd $DIR
# Generate the tag
# Generate the tag.
if [ -z $NOTAG ]; then
echo "==> Tagging..."
git commit --allow-empty -a --gpg-sign=348FFC4C -m "Release v$VERSION"
git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master
fi
# Generate the UI
if [ -z $NOUI ]; then
echo "==> Generating Consul UI..."
make -f ui/Makefile dist
# Do a hermetic build inside a Docker container.
if [ -z $NOBUILD ]; then
docker build -t hashicorp/consul-builder scripts/consul-builder/
docker run --rm -v "$(pwd)":/gopath/src/github.com/hashicorp/consul hashicorp/consul-builder
fi
# Zip all the files
# Zip all the files.
rm -rf ./pkg/dist
mkdir -p ./pkg/dist
for FILENAME in $(find ./pkg -mindepth 1 -maxdepth 1 -type f); do
@ -39,7 +39,7 @@ for FILENAME in $(find ./pkg -mindepth 1 -maxdepth 1 -type f); do
cp ./pkg/${FILENAME} ./pkg/dist/consul_${VERSION}_${FILENAME}
done
# Make the checksums
# Make the checksums.
pushd ./pkg/dist
shasum -a256 * > ./consul_${VERSION}_SHA256SUMS
if [ -z $NOSIGN ]; then
@ -48,10 +48,4 @@ if [ -z $NOSIGN ]; then
fi
popd
# Upload
if [ -z $NORELEASE ]; then
echo "==> Uploading binaries..."
hc-releases -upload=./pkg/dist
fi
exit 0

47
scripts/dist_build.sh Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -e
export GO15VENDOREXPERIMENT=1
# Get the parent directory of where this script is.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
# Change into that dir because we expect that.
cd $DIR
# Make sure build tools are abailable.
make -f GNUMakefile tools
# Build the standalone version of the web assets for the sanity check.
pushd ui
bundle
make dist
popd
# Fixup the timestamps to match what's checked in. This will allow us to cleanly
# verify that the checked-in content is up to date without spurious diffs of the
# file mod times.
pushd pkg
cat ../command/agent/bindata_assetfs.go | ../scripts/fixup_times.sh
popd
# Regenerate the built-in web assets. If there are any diffs after doing this
# then we know something is up.
make -f GNUMakefile static-assets
if ! git diff --quiet command/agent/bindata_assetfs.go; then
echo "Checked-in web assets are out of date, build aborted"
exit 1
fi
# Now we are ready to do a clean build of everything. The "all" build will blow
# away our pkg folder so we have to regenerate the ui once more. This is probably
# for the best since we have meddled with the timestamps.
rm -rf pkg
make -f GNUMakefile all
pushd ui
make dist
popd
exit 0

10
scripts/fixup_times.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
regex='bindataFileInfo.*name: \"(.+)\".*time.Unix.(.+),'
while read line; do
if [[ $line =~ $regex ]]; then
file=${BASH_REMATCH[1]}
ts=${BASH_REMATCH[2]}
touch --date @$ts $file
fi
done