mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 04:42:35 +08:00
build: upgrades build pipeline from CircleCI 1.0 -> 2.0 (#11162)
build: upgrades build pipeline from CircleCI 1.0 -> 2.0
This commit is contained in:
188
circle.yml
188
circle.yml
@ -1,57 +1,137 @@
|
|||||||
machine:
|
version: 2
|
||||||
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
|
|
||||||
|
|
||||||
dependencies:
|
jobs:
|
||||||
cache_directories:
|
test-frontend:
|
||||||
- "~/docker"
|
docker:
|
||||||
- "~/download"
|
- image: circleci/node:6.11.4
|
||||||
override:
|
steps:
|
||||||
- rm -rf ${GOPATH}/src/${REPO_PATH}
|
- checkout
|
||||||
- mkdir -p ${GOPATH}/src/${ORG_PATH}
|
- run:
|
||||||
- cp -r ~/grafana ${GOPATH}/src/${ORG_PATH}
|
name: install yarn
|
||||||
pre:
|
command: 'sudo npm install -g yarn --quiet'
|
||||||
- pip install awscli
|
- restore_cache:
|
||||||
- sudo apt-get update; sudo apt-get install rpm; sudo apt-get install expect
|
key: dependency-cache-{{ checksum "yarn.lock" }}
|
||||||
- ./scripts/build/build_container.sh
|
# 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:
|
test-backend:
|
||||||
override:
|
docker:
|
||||||
- bash scripts/circle-test-frontend.sh
|
- image: circleci/golang:1.10
|
||||||
- bash scripts/circle-test-backend.sh
|
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:
|
build:
|
||||||
gh_branch:
|
docker:
|
||||||
branch: master
|
- image: grafana/build-container:v0.1
|
||||||
commands:
|
working_directory: /go/src/github.com/grafana/grafana
|
||||||
- ./scripts/build/deploy.sh
|
steps:
|
||||||
- ./scripts/build/sign_packages.sh
|
- checkout
|
||||||
- go run build.go sha-dist
|
- run:
|
||||||
- aws s3 sync ./dist s3://$BUCKET_NAME/master
|
name: build and package grafana
|
||||||
- ./scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} master
|
command: './scripts/build/build.sh'
|
||||||
- ./scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN}
|
- run:
|
||||||
- go run ./scripts/build/publish.go -apiKey ${GRAFANA_COM_API_KEY}
|
name: sign packages
|
||||||
gh_tag:
|
command: './scripts/build/sign_packages.sh'
|
||||||
tag: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
|
- run:
|
||||||
commands:
|
name: sha-sum packages
|
||||||
- ./scripts/build/deploy.sh
|
command: 'go run build.go sha-dist'
|
||||||
- ./scripts/build/sign_packages.sh
|
- run:
|
||||||
- go run build.go sha-dist
|
name: Build Grafana.com publisher
|
||||||
- aws s3 sync ./dist s3://$BUCKET_NAME/release
|
command: 'go build -o scripts/publish scripts/build/publish.go'
|
||||||
- ./scripts/trigger_windows_build.sh ${APPVEYOR_TOKEN} ${CIRCLE_SHA1} release
|
- persist_to_workspace:
|
||||||
- ./scripts/trigger_docker_build.sh ${TRIGGER_GRAFANA_PACKER_CIRCLECI_TOKEN} ${CIRCLE_TAG}
|
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
|
yarn install --pure-lockfile --no-progress
|
||||||
|
|
||||||
source /etc/profile.d/rvm.sh
|
source /etc/profile.d/rvm.sh
|
||||||
rvm use 2.1.9 --default
|
|
||||||
|
|
||||||
gem install fpm -v 1.4
|
|
||||||
|
|
||||||
echo "current dir: $(pwd)"
|
echo "current dir: $(pwd)"
|
||||||
|
|
||||||
|
@ -10,15 +10,12 @@ function exit_if_fail {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd /home/ubuntu/.go_workspace/src/github.com/grafana/grafana
|
|
||||||
|
|
||||||
echo "running go fmt"
|
echo "running go fmt"
|
||||||
exit_if_fail test -z "$(gofmt -s -l ./pkg | tee /dev/stderr)"
|
exit_if_fail test -z "$(gofmt -s -l ./pkg | tee /dev/stderr)"
|
||||||
|
|
||||||
echo "running go vet"
|
echo "running go vet"
|
||||||
exit_if_fail test -z "$(go vet ./pkg/... | tee /dev/stderr)"
|
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"
|
echo "building backend with install to cache pkgs"
|
||||||
exit_if_fail time go install ./pkg/cmd/grafana-server
|
exit_if_fail time go install ./pkg/cmd/grafana-server
|
||||||
|
|
||||||
|
@ -10,12 +10,6 @@ function exit_if_fail {
|
|||||||
fi
|
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 test:coverage
|
||||||
exit_if_fail npm run build
|
exit_if_fail npm run build
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ config = merge(common, {
|
|||||||
new webpack.SourceMapDevToolPlugin({
|
new webpack.SourceMapDevToolPlugin({
|
||||||
filename: null, // if no value is provided the sourcemap is inlined
|
filename: null, // if no value is provided the sourcemap is inlined
|
||||||
test: /\.(ts|js)($|\?)/i // process .js and .ts files only
|
test: /\.(ts|js)($|\?)/i // process .js and .ts files only
|
||||||
})
|
}),
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user