Просмотр исходного кода

Enterprise crosscompilation (#13783)

* build: crosscompilation and release of enterprise.
Leonard Gram 7 лет назад
Родитель
Сommit
6c473d33f4

+ 86 - 4
.circleci/config.yml

@@ -238,8 +238,17 @@ jobs:
     steps:
     steps:
       - checkout
       - checkout
       - run:
       - 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:
       - run:
           name: sign packages
           name: sign packages
           command: './scripts/build/sign_packages.sh'
           command: './scripts/build/sign_packages.sh'
@@ -254,6 +263,53 @@ jobs:
           paths:
           paths:
             - enterprise-dist/grafana-enterprise*
             - 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:
   deploy-enterprise-master:
     docker:
     docker:
       - image: circleci/python:2.7-stretch
       - image: circleci/python:2.7-stretch
@@ -267,6 +323,19 @@ jobs:
           name: deploy to s3
           name: deploy to s3
           command: 'aws s3 sync ./enterprise-dist s3://$ENTERPRISE_BUCKET_NAME/master'
           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:
   deploy-master:
     docker:
     docker:
       - image: circleci/python:2.7-stretch
       - image: circleci/python:2.7-stretch
@@ -313,7 +382,7 @@ workflows:
     jobs:
     jobs:
       - build-all:
       - build-all:
           filters: *filter-only-master
           filters: *filter-only-master
-      - build-enterprise:
+      - build-all-enterprise:
           filters: *filter-only-master
           filters: *filter-only-master
       - codespell:
       - codespell:
           filters: *filter-only-master
           filters: *filter-only-master
@@ -356,13 +425,15 @@ workflows:
             - gometalinter
             - gometalinter
             - mysql-integration-test
             - mysql-integration-test
             - postgres-integration-test
             - postgres-integration-test
-            - build-enterprise
+            - build-all-enterprise
           filters: *filter-only-master
           filters: *filter-only-master
 
 
   release:
   release:
     jobs:
     jobs:
       - build-all:
       - build-all:
           filters: *filter-only-release
           filters: *filter-only-release
+      - build-all-enterprise:
+          filters: *filter-only-release
       - codespell:
       - codespell:
           filters: *filter-only-release
           filters: *filter-only-release
       - gometalinter:
       - gometalinter:
@@ -385,6 +456,17 @@ workflows:
             - mysql-integration-test
             - mysql-integration-test
             - postgres-integration-test
             - postgres-integration-test
           filters: *filter-only-release
           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:
       - grafana-docker-release:
           requires:
           requires:
             - build-all
             - build-all

+ 12 - 3
scripts/build/build-all.sh

@@ -4,6 +4,10 @@
 #   This script is executed from within the container.
 #   This script is executed from within the container.
 #
 #
 
 
+set -e
+
+EXTRA_OPTS="$@"
+
 CCARMV7=arm-linux-gnueabihf-gcc
 CCARMV7=arm-linux-gnueabihf-gcc
 CCARM64=aarch64-linux-gnu-gcc
 CCARM64=aarch64-linux-gnu-gcc
 CCOSX64=/tmp/osxcross/target/bin/o64-clang
 CCOSX64=/tmp/osxcross/target/bin/o64-clang
@@ -18,15 +22,20 @@ echo "current dir: $(pwd)"
 
 
 if [ "$CIRCLE_TAG" != "" ]; then
 if [ "$CIRCLE_TAG" != "" ]; then
   echo "Building releases from tag $CIRCLE_TAG"
   echo "Building releases from tag $CIRCLE_TAG"
-  OPT="-includeBuildNumber=false"
+  OPT="-includeBuildNumber=false ${EXTRA_OPTS}"
 else
 else
   echo "Building incremental build for $CIRCLE_BRANCH"
   echo "Building incremental build for $CIRCLE_BRANCH"
-  OPT="-buildNumber=${CIRCLE_BUILD_NUM}"
+  OPT="-buildNumber=${CIRCLE_BUILD_NUM} ${EXTRA_OPTS}"
 fi
 fi
 
 
+echo "Build arguments: $OPT"
+
 go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
 go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
 go run build.go -goarch arm64 -cc ${CCARM64} ${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
 go run build.go -goos windows -cc ${CCWIN64} ${OPT} build
 CC=${CCX64} go run build.go ${OPT} build
 CC=${CCX64} go run build.go ${OPT} build
 
 

+ 8 - 2
scripts/build/build.sh

@@ -4,6 +4,10 @@
 #   This script is executed from within the container.
 #   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
 CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
 
 
 GOPATH=/go
 GOPATH=/go
@@ -14,12 +18,14 @@ echo "current dir: $(pwd)"
 
 
 if [ "$CIRCLE_TAG" != "" ]; then
 if [ "$CIRCLE_TAG" != "" ]; then
   echo "Building releases from tag $CIRCLE_TAG"
   echo "Building releases from tag $CIRCLE_TAG"
-  OPT="-includeBuildNumber=false"
+  OPT="-includeBuildNumber=false ${EXTRA_OPTS}"
 else
 else
   echo "Building incremental build for $CIRCLE_BRANCH"
   echo "Building incremental build for $CIRCLE_BRANCH"
-  OPT="-buildNumber=${CIRCLE_BUILD_NUM}"
+  OPT="-buildNumber=${CIRCLE_BUILD_NUM} ${EXTRA_OPTS}"
 fi
 fi
 
 
+echo "Build arguments: $OPT"
+
 CC=${CCX64} go run build.go ${OPT} build
 CC=${CCX64} go run build.go ${OPT} build
 
 
 yarn install --pure-lockfile --no-progress
 yarn install --pure-lockfile --no-progress

+ 0 - 58
scripts/build/build_enterprise.sh

@@ -1,58 +0,0 @@
-#!/bin/bash
-
-#
-#   This script is executed from within the container.
-#
-
-echo "building enterprise version"
-
-GOPATH=/go
-REPO_PATH=$GOPATH/src/github.com/grafana/grafana
-
-
-cd /go/src/github.com/grafana/grafana
-echo "current dir: $(pwd)"
-
-cd ..
-git clone -b master --single-branch git@github.com:grafana/grafana-enterprise.git --depth 10
-cd grafana-enterprise
-#git checkout 7fbae9c1be3467c4a39cf6ad85278a6896ceb49f
-./build.sh
-
-cd ../grafana
-
-function exit_if_fail {
-    command=$@
-    echo "Executing '$command'"
-    eval $command
-    rc=$?
-    if [ $rc -ne 0 ]; then
-        echo "'$command' returned $rc."
-        exit $rc
-    fi
-}
-
-exit_if_fail go test ./pkg/extensions/...
-
-
-if [ "$CIRCLE_TAG" != "" ]; then
-  echo "Building a release from tag $ls"
-  go run build.go -buildNumber=${CIRCLE_BUILD_NUM} -enterprise=true -includeBuildNumber=false build
-else
-  echo "Building incremental build for $CIRCLE_BRANCH"
-  go run build.go -buildNumber=${CIRCLE_BUILD_NUM} -enterprise=true build
-fi
-
-yarn install --pure-lockfile --no-progress
-
-source /etc/profile.d/rvm.sh
-
-echo "current dir: $(pwd)"
-
-if [ "$CIRCLE_TAG" != "" ]; then
-  echo "Packaging a release from tag $CIRCLE_TAG"
-  go run build.go -buildNumber=${CIRCLE_BUILD_NUM} -enterprise=true -includeBuildNumber=false package latest
-else
-  echo "Packaging incremental build for $CIRCLE_BRANCH"
-  go run build.go -buildNumber=${CIRCLE_BUILD_NUM} -enterprise=true package latest
-fi

+ 6 - 0
scripts/build/prepare-enterprise.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+cd ..
+git clone -b master --single-branch git@github.com:grafana/grafana-enterprise.git --depth 1
+cd grafana-enterprise
+./build.sh