Skip to content

Commit

Permalink
Enterprise crosscompilation (grafana#13783)
Browse files Browse the repository at this point in the history
* build: crosscompilation and release of enterprise.
  • Loading branch information
xlson authored Oct 22, 2018
1 parent 16a2b20 commit 6c473d3
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 67 deletions.
90 changes: 86 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,17 @@ jobs:
steps:
- checkout
- run:
name: build, test and package grafana enterprise
command: './scripts/build/build_enterprise.sh'
name: prepare build tools
command: '/tmp/bootstrap.sh'
- run:
name: checkout enterprise
command: './scripts/build/prepare_enterprise.sh'
- run:
name: test enterprise
command: 'go test ./pkg/extensions/...'
- run:
name: build and package enterprise
command: './scripts/build/build.sh -enterprise'
- run:
name: sign packages
command: './scripts/build/sign_packages.sh'
Expand All @@ -254,6 +263,53 @@ jobs:
paths:
- enterprise-dist/grafana-enterprise*

build-all-enterprise:
docker:
- image: grafana/build-container:1.2.0
working_directory: /go/src/github.com/grafana/grafana
steps:
- checkout
- run:
name: prepare build tools
command: '/tmp/bootstrap.sh'
- run:
name: checkout enterprise
command: './scripts/build/prepare_enterprise.sh'
- restore_cache:
key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
- run:
name: download phantomjs binaries
command: './scripts/build/download-phantomjs.sh'
- save_cache:
key: phantomjs-binaries-{{ checksum "scripts/build/download-phantomjs.sh" }}
paths:
- /tmp/phantomjs
- run:
name: test enterprise
command: 'go test ./pkg/extensions/...'
- run:
name: build and package grafana
command: './scripts/build/build-all.sh -enterprise'
- run:
name: sign packages
command: './scripts/build/sign_packages.sh'
- run:
name: verify signed packages
command: |
mkdir -p ~/.rpmdb/pubkeys
curl -s https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana > ~/.rpmdb/pubkeys/grafana.key
./scripts/build/verify_signed_packages.sh dist/*.rpm
- run:
name: sha-sum packages
command: 'go run build.go sha-dist'
- run:
name: move enterprise packages into their own folder
command: 'mv dist enterprise-dist'
- persist_to_workspace:
root: .
paths:
- enterprise-dist/grafana-enterprise*

deploy-enterprise-master:
docker:
- image: circleci/python:2.7-stretch
Expand All @@ -267,6 +323,19 @@ jobs:
name: deploy to s3
command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/master'

deploy-enterprise-release:
docker:
- image: circleci/python:2.7-stretch
steps:
- attach_workspace:
at: .
- run:
name: install awscli
command: 'sudo pip install awscli'
- run:
name: deploy to s3
command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/release'

deploy-master:
docker:
- image: circleci/python:2.7-stretch
Expand Down Expand Up @@ -313,7 +382,7 @@ workflows:
jobs:
- build-all:
filters: *filter-only-master
- build-enterprise:
- build-all-enterprise:
filters: *filter-only-master
- codespell:
filters: *filter-only-master
Expand Down Expand Up @@ -356,13 +425,15 @@ workflows:
- gometalinter
- mysql-integration-test
- postgres-integration-test
- build-enterprise
- build-all-enterprise
filters: *filter-only-master

release:
jobs:
- build-all:
filters: *filter-only-release
- build-all-enterprise:
filters: *filter-only-release
- codespell:
filters: *filter-only-release
- gometalinter:
Expand All @@ -385,6 +456,17 @@ workflows:
- mysql-integration-test
- postgres-integration-test
filters: *filter-only-release
- deploy-enterprise-release:
requires:
- build-all
- build-all-enterprise
- test-backend
- test-frontend
- codespell
- gometalinter
- mysql-integration-test
- postgres-integration-test
filters: *filter-only-release
- grafana-docker-release:
requires:
- build-all
Expand Down
15 changes: 12 additions & 3 deletions scripts/build/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# This script is executed from within the container.
#

set -e

EXTRA_OPTS="$@"

CCARMV7=arm-linux-gnueabihf-gcc
CCARM64=aarch64-linux-gnu-gcc
CCOSX64=/tmp/osxcross/target/bin/o64-clang
Expand All @@ -18,15 +22,20 @@ echo "current dir: $(pwd)"

if [ "$CIRCLE_TAG" != "" ]; then
echo "Building releases from tag $CIRCLE_TAG"
OPT="-includeBuildNumber=false"
OPT="-includeBuildNumber=false ${EXTRA_OPTS}"
else
echo "Building incremental build for $CIRCLE_BRANCH"
OPT="-buildNumber=${CIRCLE_BUILD_NUM}"
OPT="-buildNumber=${CIRCLE_BUILD_NUM} ${EXTRA_OPTS}"
fi

echo "Build arguments: $OPT"

go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build

# MacOS build is broken atm. See Issue #13763
#go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build

go run build.go -goos windows -cc ${CCWIN64} ${OPT} build
CC=${CCX64} go run build.go ${OPT} build

Expand Down
10 changes: 8 additions & 2 deletions scripts/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# This script is executed from within the container.
#

set -e

EXTRA_OPTS="$@"

CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc

GOPATH=/go
Expand All @@ -14,12 +18,14 @@ echo "current dir: $(pwd)"

if [ "$CIRCLE_TAG" != "" ]; then
echo "Building releases from tag $CIRCLE_TAG"
OPT="-includeBuildNumber=false"
OPT="-includeBuildNumber=false ${EXTRA_OPTS}"
else
echo "Building incremental build for $CIRCLE_BRANCH"
OPT="-buildNumber=${CIRCLE_BUILD_NUM}"
OPT="-buildNumber=${CIRCLE_BUILD_NUM} ${EXTRA_OPTS}"
fi

echo "Build arguments: $OPT"

CC=${CCX64} go run build.go ${OPT} build

yarn install --pure-lockfile --no-progress
Expand Down
58 changes: 0 additions & 58 deletions scripts/build/build_enterprise.sh

This file was deleted.

6 changes: 6 additions & 0 deletions scripts/build/prepare-enterprise.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cd ..
git clone -b master --single-branch [email protected]:grafana/grafana-enterprise.git --depth 1
cd grafana-enterprise
./build.sh

0 comments on commit 6c473d3

Please sign in to comment.