CircleCI: Build and publish Docker images in same job (#23092)

* CircleCI: Build and publish Docker images in same job
* CircleCI: Adjust dependency graph
* CircleCI: Specify grabpl concurrency
* CircleCI: Adjust resource classes
This commit is contained in:
Arve Knudsen 2020-03-26 17:25:01 +01:00 committed by GitHub
parent a4308fffe7
commit c191bf64aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,7 @@ jobs:
- run: - run:
name: Install Grafana Build Pipeline name: Install Grafana Build Pipeline
command: | command: |
curl -fLO https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v0.2.4/grabpl curl -fLO https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v0.2.5/grabpl
chmod +x grabpl chmod +x grabpl
mkdir bin mkdir bin
mv grabpl bin/ mv grabpl bin/
@ -205,7 +205,6 @@ jobs:
build-oss-windows-installer: build-oss-windows-installer:
executor: windows-installer executor: windows-installer
resource_class: large
steps: steps:
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
@ -238,7 +237,6 @@ jobs:
build-enterprise-windows-installer: build-enterprise-windows-installer:
executor: windows-installer executor: windows-installer
resource_class: large
steps: steps:
- run: - run:
name: Exit if forked PR name: Exit if forked PR
@ -312,7 +310,6 @@ jobs:
package-oss: package-oss:
executor: grafana-build executor: grafana-build
resource_class: large
steps: steps:
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
@ -333,16 +330,16 @@ jobs:
if [[ -n $CIRCLE_TAG ]]; then if [[ -n $CIRCLE_TAG ]]; then
# A release build # A release build
/tmp/workspace/bin/grabpl package --edition oss $CIRCLE_TAG /tmp/workspace/bin/grabpl package --jobs 4 --edition oss $CIRCLE_TAG
elif [[ $CIRCLE_BRANCH == "chore/test-release-pipeline" ]]; then elif [[ $CIRCLE_BRANCH == "chore/test-release-pipeline" ]]; then
# We're testing the release pipeline # We're testing the release pipeline
/tmp/workspace/bin/grabpl package --edition oss v6.7.0-beta1 /tmp/workspace/bin/grabpl package --jobs 4 --edition oss v6.7.0-beta1
elif [[ $CIRCLE_BRANCH == "master" ]]; then elif [[ $CIRCLE_BRANCH == "master" ]]; then
# A master build # A master build
/tmp/workspace/bin/grabpl package --edition oss --build-id $CIRCLE_WORKFLOW_ID /tmp/workspace/bin/grabpl package --jobs 4 --edition oss --build-id $CIRCLE_WORKFLOW_ID
else else
# A PR build # A PR build
/tmp/workspace/bin/grabpl package --edition oss --build-id $CIRCLE_WORKFLOW_ID --variants \ /tmp/workspace/bin/grabpl package --jobs 4 --edition oss --build-id $CIRCLE_WORKFLOW_ID --variants \
linux-x64,linux-x64-musl,osx64,win64 linux-x64,linux-x64-musl,osx64,win64
fi fi
- run: - run:
@ -365,7 +362,6 @@ jobs:
package-enterprise: package-enterprise:
executor: grafana-build executor: grafana-build
resource_class: large
steps: steps:
- run: - run:
name: Exit if forked PR name: Exit if forked PR
@ -388,16 +384,16 @@ jobs:
command: | command: |
if [[ -n $CIRCLE_TAG ]]; then if [[ -n $CIRCLE_TAG ]]; then
# A release build # A release build
/tmp/workspace/bin/grabpl package --edition enterprise $CIRCLE_TAG /tmp/workspace/bin/grabpl package --jobs 4 --edition enterprise $CIRCLE_TAG
elif [[ $CIRCLE_BRANCH == "chore/test-release-pipeline" ]]; then elif [[ $CIRCLE_BRANCH == "chore/test-release-pipeline" ]]; then
# We're testing the release pipeline # We're testing the release pipeline
/tmp/workspace/bin/grabpl package --edition enterprise v6.7.0-beta1 /tmp/workspace/bin/grabpl package --jobs 4 --edition enterprise v6.7.0-beta1
elif [[ $CIRCLE_BRANCH == "master" ]]; then elif [[ $CIRCLE_BRANCH == "master" ]]; then
# A master build # A master build
/tmp/workspace/bin/grabpl package --edition enterprise --build-id $CIRCLE_WORKFLOW_ID /tmp/workspace/bin/grabpl package --jobs 4 --edition enterprise --build-id $CIRCLE_WORKFLOW_ID
else else
# A PR build # A PR build
/tmp/workspace/bin/grabpl package --edition enterprise --build-id $CIRCLE_WORKFLOW_ID --variants \ /tmp/workspace/bin/grabpl package --jobs 4 --edition enterprise --build-id $CIRCLE_WORKFLOW_ID --variants \
linux-x64,linux-x64-musl,osx64,win64 linux-x64,linux-x64-musl,osx64,win64
fi fi
- run: - run:
@ -420,7 +416,6 @@ jobs:
publish-packages: publish-packages:
description: "Publish packages" description: "Publish packages"
resource_class: large
parameters: parameters:
edition: edition:
type: string type: string
@ -502,8 +497,7 @@ jobs:
when: on_success when: on_success
build-docker-images: build-docker-images:
description: "Build Docker images" description: "Build/publish Docker images"
resource_class: large
parameters: parameters:
edition: edition:
type: string type: string
@ -536,64 +530,28 @@ jobs:
command: | command: |
if [[ -n $CIRCLE_TAG || $CIRCLE_BRANCH == "chore/test-release-pipeline" || $CIRCLE_BRANCH == "master" ]]; then if [[ -n $CIRCLE_TAG || $CIRCLE_BRANCH == "chore/test-release-pipeline" || $CIRCLE_BRANCH == "master" ]]; then
# It's a full build # It's a full build
/tmp/workspace/bin/grabpl build-docker --edition << parameters.edition >> \ /tmp/workspace/bin/grabpl build-docker --jobs 4 --edition << parameters.edition >> \
--ubuntu=<< parameters.ubuntu >> --ubuntu=<< parameters.ubuntu >>
else else
# We're testing a branch # We're testing a branch
/tmp/workspace/bin/grabpl build-docker --edition << parameters.edition >> \ /tmp/workspace/bin/grabpl build-docker --jobs 4 --edition << parameters.edition >> \
--ubuntu=<< parameters.ubuntu >> --archs amd64 --ubuntu=<< parameters.ubuntu >> --archs amd64
fi fi
mkdir -p << parameters.edition >>/docker
mv docker/*.tar << parameters.edition >>/docker/
- persist_to_workspace:
root: .
paths:
- << parameters.edition >>/docker/*.tar
- run: - run:
name: CI job failed name: Exit if PR
command: ./scripts/ci-job-failed.sh
when: on_fail
- run:
name: CI job succeeded
command: ./scripts/ci-job-succeeded.sh
when: on_success
publish-docker-images:
description: Publish Docker images
resource_class: large
parameters:
edition:
type: string
ubuntu:
type: boolean
executor: docker
steps:
- run:
name: Exit if forked PR
command: | command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then if [[ -z $CIRCLE_TAG && $CIRCLE_BRANCH != "chore/test-release-pipeline" && $CIRCLE_BRANCH != "master" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful" echo "Nothing to do for PRs, so marking this step successful"
circleci step halt circleci step halt
fi fi
- attach_workspace:
at: /tmp/workspace
- checkout
- run:
name: CI job started
command: ./scripts/ci-job-started.sh
- run:
name: Copy artifacts from workspace
command: |
cp -r /tmp/workspace/<< parameters.edition >>/docker .
cp -r /tmp/workspace/<< parameters.edition >>/dist .
- run: - run:
name: Publish Docker images name: Publish Docker images
command: | command: |
if [[ $CIRCLE_BRANCH == "chore/test-release-pipeline" ]]; then if [[ $CIRCLE_BRANCH == "chore/test-release-pipeline" ]]; then
# We're testing the release pipeline # We're testing the release pipeline
/tmp/workspace/bin/grabpl publish-docker --edition << parameters.edition >> --ubuntu=<< parameters.ubuntu >> --dry-run /tmp/workspace/bin/grabpl publish-docker --jobs 4 --edition << parameters.edition >> --ubuntu=<< parameters.ubuntu >> --dry-run
else else
/tmp/workspace/bin/grabpl publish-docker --edition << parameters.edition >> --ubuntu=<< parameters.ubuntu >> /tmp/workspace/bin/grabpl publish-docker --jobs 4 --edition << parameters.edition >> --ubuntu=<< parameters.ubuntu >>
fi fi
- run: - run:
name: CI job failed name: CI job failed
@ -605,7 +563,6 @@ jobs:
when: on_success when: on_success
end-to-end-tests: end-to-end-tests:
resource_class: large
docker: docker:
- image: circleci/node:12-browsers - image: circleci/node:12-browsers
steps: steps:
@ -641,7 +598,6 @@ jobs:
destination: logs destination: logs
mysql-integration-test: mysql-integration-test:
resource_class: large
docker: docker:
- image: circleci/golang:1.13.4 - image: circleci/golang:1.13.4
- image: circleci/mysql:5.6-ram - image: circleci/mysql:5.6-ram
@ -673,7 +629,6 @@ jobs:
when: on_success when: on_success
postgres-integration-test: postgres-integration-test:
resource_class: large
docker: docker:
- image: circleci/golang:1.13.4 - image: circleci/golang:1.13.4
- image: circleci/postgres:9.3-ram - image: circleci/postgres:9.3-ram
@ -722,7 +677,6 @@ jobs:
lint-go: lint-go:
docker: docker:
- image: circleci/golang:1.13.4 - image: circleci/golang:1.13.4
resource_class: large
working_directory: /go/src/github.com/grafana/grafana working_directory: /go/src/github.com/grafana/grafana
environment: environment:
# we need CGO because of go-sqlite3 # we need CGO because of go-sqlite3
@ -756,7 +710,6 @@ jobs:
-conf=./scripts/go/configs/gosec.json ./pkg/... -conf=./scripts/go/configs/gosec.json ./pkg/...
test-frontend: test-frontend:
resource_class: large
docker: docker:
- image: circleci/node:12 - image: circleci/node:12
steps: steps:
@ -932,6 +885,8 @@ workflows:
name: build-oss-backend-armv6 name: build-oss-backend-armv6
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
edition: oss edition: oss
@ -939,6 +894,8 @@ workflows:
name: build-oss-backend-armv7 name: build-oss-backend-armv7
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
edition: oss edition: oss
@ -946,6 +903,8 @@ workflows:
name: build-oss-backend-armv7-musl name: build-oss-backend-armv7-musl
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
edition: oss edition: oss
@ -953,6 +912,8 @@ workflows:
name: build-oss-backend-arm64 name: build-oss-backend-arm64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
edition: oss edition: oss
@ -960,6 +921,8 @@ workflows:
name: build-oss-backend-arm64-musl name: build-oss-backend-arm64-musl
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
edition: oss edition: oss
@ -967,6 +930,8 @@ workflows:
name: build-oss-backend-osx64 name: build-oss-backend-osx64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
edition: oss edition: oss
@ -974,6 +939,8 @@ workflows:
name: build-oss-backend-win64 name: build-oss-backend-win64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
edition: oss edition: oss
@ -981,6 +948,8 @@ workflows:
name: build-oss-backend-linux-x64 name: build-oss-backend-linux-x64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
edition: oss edition: oss
@ -988,12 +957,16 @@ workflows:
name: build-oss-backend-linux-x64-musl name: build-oss-backend-linux-x64-musl
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-frontend: - build-frontend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
name: build-oss-frontend name: build-oss-frontend
edition: oss edition: oss
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
name: build-enterprise-backend-armv6 name: build-enterprise-backend-armv6
@ -1001,6 +974,8 @@ workflows:
variant: armv6 variant: armv6
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
name: build-enterprise-backend-armv7 name: build-enterprise-backend-armv7
@ -1008,6 +983,8 @@ workflows:
variant: armv7 variant: armv7
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
name: build-enterprise-backend-armv7-musl name: build-enterprise-backend-armv7-musl
@ -1015,6 +992,8 @@ workflows:
variant: armv7-musl variant: armv7-musl
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
name: build-enterprise-backend-arm64 name: build-enterprise-backend-arm64
@ -1022,6 +1001,8 @@ workflows:
variant: arm64 variant: arm64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
filters: *filter-master-or-release filters: *filter-master-or-release
name: build-enterprise-backend-arm64-musl name: build-enterprise-backend-arm64-musl
@ -1029,6 +1010,8 @@ workflows:
variant: arm64-musl variant: arm64-musl
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
name: build-enterprise-backend-osx64 name: build-enterprise-backend-osx64
@ -1036,6 +1019,8 @@ workflows:
variant: osx64 variant: osx64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
name: build-enterprise-backend-win64 name: build-enterprise-backend-win64
@ -1043,6 +1028,8 @@ workflows:
variant: win64 variant: win64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
name: build-enterprise-backend-linux-x64 name: build-enterprise-backend-linux-x64
@ -1050,6 +1037,8 @@ workflows:
variant: linux-x64 variant: linux-x64
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-backend: - build-backend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
name: build-enterprise-backend-linux-x64-musl name: build-enterprise-backend-linux-x64-musl
@ -1057,12 +1046,16 @@ workflows:
variant: linux-x64-musl variant: linux-x64-musl
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-frontend: - build-frontend:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
name: build-enterprise-frontend name: build-enterprise-frontend
edition: enterprise edition: enterprise
requires: requires:
- install-grabpl - install-grabpl
- test-backend
- test-frontend
- build-release-publisher: - build-release-publisher:
filters: *filter-master-or-release filters: *filter-master-or-release
- codespell: - codespell:
@ -1091,11 +1084,15 @@ workflows:
requires: requires:
- install-grabpl - install-grabpl
- lint-go - lint-go
- test-backend
- test-frontend
- postgres-integration-test: - postgres-integration-test:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
requires: requires:
- install-grabpl - install-grabpl
- lint-go - lint-go
- test-backend
- test-frontend
- package-oss: - package-oss:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
requires: requires:
@ -1147,7 +1144,7 @@ workflows:
- release-next-packages: - release-next-packages:
filters: *filter-only-master filters: *filter-only-master
requires: requires:
- test-frontend - end-to-end-tests
- release-packages: - release-packages:
filters: *filter-only-release filters: *filter-only-release
requires: requires:
@ -1170,13 +1167,17 @@ workflows:
- build-enterprise-windows-installer - build-enterprise-windows-installer
- end-to-end-tests - end-to-end-tests
- build-release-publisher - build-release-publisher
- publish-storybook - publish-storybook:
requires:
- test-backend
- test-frontend
- build-docker-images: - build-docker-images:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
name: build-oss-docker-images name: build-oss-docker-images
edition: oss edition: oss
ubuntu: false ubuntu: false
requires: requires:
- end-to-end-tests
- package-oss - package-oss
- build-oss-windows-installer - build-oss-windows-installer
- build-docker-images: - build-docker-images:
@ -1185,6 +1186,7 @@ workflows:
edition: oss edition: oss
ubuntu: true ubuntu: true
requires: requires:
- end-to-end-tests
- package-oss - package-oss
- build-oss-windows-installer - build-oss-windows-installer
- build-docker-images: - build-docker-images:
@ -1193,6 +1195,7 @@ workflows:
edition: enterprise edition: enterprise
ubuntu: false ubuntu: false
requires: requires:
- end-to-end-tests
- package-enterprise - package-enterprise
- build-enterprise-windows-installer - build-enterprise-windows-installer
- build-docker-images: - build-docker-images:
@ -1201,50 +1204,22 @@ workflows:
edition: enterprise edition: enterprise
ubuntu: true ubuntu: true
requires: requires:
- end-to-end-tests
- package-enterprise - package-enterprise
- build-enterprise-windows-installer - build-enterprise-windows-installer
- end-to-end-tests: - end-to-end-tests:
# No filters, meaning this job runs for all branches # No filters, meaning this job runs for all branches
requires: requires:
- package-oss - package-oss
- publish-docker-images:
filters: *filter-master-or-release
name: publish-oss-docker-images
edition: oss
ubuntu: false
requires:
- build-oss-docker-images
- end-to-end-tests
- publish-docker-images:
filters: *filter-master-or-release
name: publish-oss-ubuntu-docker-images
edition: oss
ubuntu: true
requires:
- build-oss-ubuntu-docker-images
- end-to-end-tests
- publish-docker-images:
filters: *filter-master-or-release
name: publish-enterprise-docker-images
edition: enterprise
ubuntu: false
requires:
- build-enterprise-docker-images
- end-to-end-tests
- publish-docker-images:
filters: *filter-master-or-release
name: publish-enterprise-ubuntu-docker-images
edition: enterprise
ubuntu: true
requires:
- build-enterprise-ubuntu-docker-images
- end-to-end-tests
- build-docs-website: - build-docs-website:
filters: *filter-not-release-or-master filters: *filter-not-release-or-master
requires:
- mysql-integration-test
- postgres-integration-test
- deploy-to-kubernetes: - deploy-to-kubernetes:
filters: *filter-only-master filters: *filter-only-master
requires: requires:
- publish-enterprise-docker-images - build-enterprise-docker-images
nightly: nightly:
triggers: triggers: