Commit 49de4ed2 by Leonard Gram Committed by GitHub

build: upgrades build pipeline from CircleCI 1.0 -> 2.0 (#11162)

build: upgrades build pipeline from CircleCI 1.0 -> 2.0
parent 77cd7f34
machine:
node:
version: 6.11.4
python:
version: 2.7.3
services:
- docker
environment:
GOPATH: "/home/ubuntu/.go_workspace"
ORG_PATH: "github.com/grafana"
REPO_PATH: "${ORG_PATH}/grafana"
GODIST: "go1.10.linux-amd64.tar.gz"
post:
- mkdir -p ~/download
- mkdir -p ~/docker
- test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
- sudo rm -rf /usr/local/go
- sudo tar -C /usr/local -xzf download/$GODIST
version: 2
dependencies:
cache_directories:
- "~/docker"
- "~/download"
override:
- rm -rf ${GOPATH}/src/${REPO_PATH}
- mkdir -p ${GOPATH}/src/${ORG_PATH}
- cp -r ~/grafana ${GOPATH}/src/${ORG_PATH}
pre:
- pip install awscli
- sudo apt-get update; sudo apt-get install rpm; sudo apt-get install expect
- ./scripts/build/build_container.sh
jobs:
test-frontend:
docker:
- image: circleci/node:6.11.4
steps:
- checkout
- run:
name: install yarn
command: 'sudo npm install -g yarn --quiet'
- restore_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
# Could we skip this step if the cache has been restored? `[ -d node_modules ] || yarn install ...` should be able to apply to build step as well
- run:
name: yarn install
command: 'yarn install --pure-lockfile --no-progress'
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- node_modules
- run:
name: frontend tests
command: './scripts/circle-test-frontend.sh'
test:
override:
- bash scripts/circle-test-frontend.sh
- bash scripts/circle-test-backend.sh
test-backend:
docker:
- image: circleci/golang:1.10
working_directory: /go/src/github.com/grafana/grafana
steps:
- checkout
- run:
name: build backend and run go tests
command: './scripts/circle-test-backend.sh'
deployment:
gh_branch:
branch: master
commands:
- ./scripts/build/deploy.sh
- ./scripts/build/sign_packages.sh
- go run build.go sha-dist
- aws s3 sync ./dist s3://$BUCKET_NAME/master
- ./scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master
- ./scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN}
- go run ./scripts/build/publish.go -apiKey ${GRAFANA_COM_API_KEY}
gh_tag:
tag: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
commands:
- ./scripts/build/deploy.sh
- ./scripts/build/sign_packages.sh
- go run build.go sha-dist
- aws s3 sync ./dist s3://$BUCKET_NAME/release
- ./scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} release
- ./scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN} ${CIRCLE_TAG}
build:
docker:
- image: grafana/build-container:v0.1
working_directory: /go/src/github.com/grafana/grafana
steps:
- checkout
- run:
name: build and package grafana
command: './scripts/build/build.sh'
- run:
name: sign packages
command: './scripts/build/sign_packages.sh'
- run:
name: sha-sum packages
command: 'go run build.go sha-dist'
- run:
name: Build Grafana.com publisher
command: 'go build -o scripts/publish scripts/build/publish.go'
- persist_to_workspace:
root: .
paths:
- dist/grafana*
- scripts/*.sh
- scripts/publish
deploy-master:
docker:
- image: circleci/python:2.7-stretch
working_directory: /go/src/github.com/grafana/grafana
steps:
- attach_workspace:
at: .
- run:
name: install awscli
command: 'sudo pip install awscli'
- run:
name: deploy to s3
command: 'aws s3 sync ./dist s3://$BUCKET_NAME/master'
- run:
name: Trigger Windows build
command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master'
- run:
name: Trigger Docker build
command: './scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN}'
- run:
name: Publish to Grafana.com
command: './scripts/publish -apiKey ${GRAFANA_COM_API_KEY}'
deploy-release:
docker:
- image: circleci/python:2.7-stretch
working_directory: /go/src/github.com/grafana/grafana
steps:
- attach_workspace:
at: dist
- run:
name: install awscli
command: 'sudo pip install awscli'
- run:
name: deploy to s3
command: 'aws s3 sync ./dist s3://$BUCKET_NAME/release'
- run:
name: Trigger Windows build
command: './scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} release'
- run:
name: Trigger Docker build
command: './scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN} ${CIRCLE_TAG}'
workflows:
version: 2
test-and-build:
jobs:
- build:
filters:
tags:
only: /.*/
- test-frontend:
filters:
tags:
only: /.*/
- test-backend:
filters:
tags:
only: /.*/
- deploy-master:
requires:
- test-backend
- test-frontend
- build
filters:
branches:
only: master
- deploy-release:
requires:
- test-backend
- test-frontend
- build
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
......@@ -21,9 +21,6 @@ fi
yarn install --pure-lockfile --no-progress
source /etc/profile.d/rvm.sh
rvm use 2.1.9 --default
gem install fpm -v 1.4
echo "current dir: $(pwd)"
......
......@@ -10,15 +10,12 @@ function exit_if_fail {
fi
}
cd /home/ubuntu/.go_workspace/src/github.com/grafana/grafana
echo "running go fmt"
exit_if_fail test -z "$(gofmt -s -l ./pkg | tee /dev/stderr)"
echo "running go vet"
exit_if_fail test -z "$(go vet ./pkg/... | tee /dev/stderr)"
cd ~/dev/go/src/github.com/grafana/grafana
echo "building backend with install to cache pkgs"
exit_if_fail time go install ./pkg/cmd/grafana-server
......
......@@ -10,12 +10,6 @@ function exit_if_fail {
fi
}
cd /home/ubuntu/.go_workspace/src/github.com/grafana/grafana
rm -rf node_modules
npm install -g yarn --quiet
yarn install --pure-lockfile --no-progress
exit_if_fail npm run test:coverage
exit_if_fail npm run build
......
......@@ -16,7 +16,7 @@ config = merge(common, {
new webpack.SourceMapDevToolPlugin({
filename: null, // if no value is provided the sourcemap is inlined
test: /\.(ts|js)($|\?)/i // process .js and .ts files only
})
}),
]
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment