Commit 756ad314 by Arve Knudsen Committed by GitHub

CircleCI: Skip enterprise builds for forked PRs (#22851)

* CircleCI: Skip enterprise builds for forked PRs
parent 6310aaff
...@@ -46,16 +46,12 @@ jobs: ...@@ -46,16 +46,12 @@ jobs:
executor: grafana-build executor: grafana-build
steps: steps:
- run: - run:
name: Clone repo
command: |
mkdir -p ~/.ssh
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts
git clone -b v0.0.2 git@github.com:grafana/build-pipeline.git
- run:
name: Install Grafana Build Pipeline name: Install Grafana Build Pipeline
command: | command: |
cd build-pipeline curl -fLO https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v0.0.3/grabpl
go build -o ../bin/grabpl ./cmd/grabpl chmod +x grabpl
mkdir bin
mv grabpl bin/
- persist_to_workspace: - persist_to_workspace:
root: . root: .
paths: paths:
...@@ -70,6 +66,13 @@ jobs: ...@@ -70,6 +66,13 @@ jobs:
type: string type: string
executor: grafana-build executor: grafana-build
steps: steps:
- run:
name: Exit if enterprise and forked PR
command: |
if [[ "<< parameters.edition >>" == "enterprise" && -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -115,6 +118,13 @@ jobs: ...@@ -115,6 +118,13 @@ jobs:
type: string type: string
executor: grafana-build executor: grafana-build
steps: steps:
- run:
name: Exit if enterprise and forked PR
command: |
if [[ "<< parameters.edition >>" == "enterprise" && -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -227,6 +237,13 @@ jobs: ...@@ -227,6 +237,13 @@ jobs:
build-enterprise-windows-installer: build-enterprise-windows-installer:
executor: windows-installer executor: windows-installer
steps: steps:
- run:
name: Exit if forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -259,6 +276,13 @@ jobs: ...@@ -259,6 +276,13 @@ jobs:
release-next-packages: release-next-packages:
executor: grafana-build executor: grafana-build
steps: steps:
- run:
name: Exit if forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -298,6 +322,11 @@ jobs: ...@@ -298,6 +322,11 @@ jobs:
- run: - run:
name: Package Grafana name: Package Grafana
command: | command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo Using test GPG key pair since building a forked PR
source scripts/build/gpg-test-vars.sh
fi
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 --edition oss $CIRCLE_TAG
...@@ -333,6 +362,13 @@ jobs: ...@@ -333,6 +362,13 @@ jobs:
package-enterprise: package-enterprise:
executor: grafana-build executor: grafana-build
steps: steps:
- run:
name: Exit if forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -384,6 +420,13 @@ jobs: ...@@ -384,6 +420,13 @@ jobs:
type: string type: string
executor: grafana-publish executor: grafana-publish
steps: steps:
- run:
name: Exit if forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -424,6 +467,12 @@ jobs: ...@@ -424,6 +467,12 @@ jobs:
command: | command: |
yarn install --frozen-lockfile --no-progress yarn install --frozen-lockfile --no-progress
yarn storybook:build yarn storybook:build
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
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
echo Testing release echo Testing release
...@@ -455,6 +504,13 @@ jobs: ...@@ -455,6 +504,13 @@ jobs:
type: boolean type: boolean
executor: docker executor: docker
steps: steps:
- run:
name: Exit if enterprise and forked PR
command: |
if [[ "<< parameters.edition >>" == "enterprise" && -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -474,11 +530,11 @@ jobs: ...@@ -474,11 +530,11 @@ jobs:
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 --edition << parameters.edition >> \
--ubuntu=<< parameters.ubuntu >> $CIRCLE_WORKFLOW_ID --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 --edition << parameters.edition >> \
--ubuntu=<< parameters.ubuntu >> --archs amd64 $CIRCLE_WORKFLOW_ID --ubuntu=<< parameters.ubuntu >> --archs amd64
fi fi
mkdir -p << parameters.edition >>/docker mkdir -p << parameters.edition >>/docker
mv docker/*.tar << parameters.edition >>/docker/ mv docker/*.tar << parameters.edition >>/docker/
...@@ -504,6 +560,13 @@ jobs: ...@@ -504,6 +560,13 @@ jobs:
type: boolean type: boolean
executor: docker executor: docker
steps: steps:
- run:
name: Exit if forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- attach_workspace: - attach_workspace:
at: /tmp/workspace at: /tmp/workspace
- checkout - checkout
...@@ -664,7 +727,7 @@ jobs: ...@@ -664,7 +727,7 @@ jobs:
steps: steps:
- checkout - checkout
- run: - run:
name: ci job started name: CI job started
command: "./scripts/ci-job-started.sh" command: "./scripts/ci-job-started.sh"
- restore_cache: - restore_cache:
key: dependency-cache-{{ checksum "yarn.lock" }} key: dependency-cache-{{ checksum "yarn.lock" }}
...@@ -682,11 +745,11 @@ jobs: ...@@ -682,11 +745,11 @@ jobs:
- store_test_results: - store_test_results:
path: reports/junit path: reports/junit
- run: - run:
name: ci job failed name: CI job failed
command: "./scripts/ci-job-failed.sh" command: "./scripts/ci-job-failed.sh"
when: on_fail when: on_fail
- run: - run:
name: ci job succeeded name: CI job succeeded
command: "./scripts/ci-job-succeeded.sh" command: "./scripts/ci-job-succeeded.sh"
when: on_success when: on_success
...@@ -697,17 +760,17 @@ jobs: ...@@ -697,17 +760,17 @@ jobs:
steps: steps:
- checkout - checkout
- run: - run:
name: ci job started name: CI job started
command: "./scripts/ci-job-started.sh" command: "./scripts/ci-job-started.sh"
- run: - run:
name: build backend and run go tests name: build backend and run go tests
command: "./scripts/circle-test-backend.sh" command: "./scripts/circle-test-backend.sh"
- run: - run:
name: ci job failed name: CI job failed
command: "./scripts/ci-job-failed.sh" command: "./scripts/ci-job-failed.sh"
when: on_fail when: on_fail
- run: - run:
name: ci job succeeded name: CI job succeeded
command: "./scripts/ci-job-succeeded.sh" command: "./scripts/ci-job-succeeded.sh"
when: on_success when: on_success
...@@ -719,15 +782,15 @@ jobs: ...@@ -719,15 +782,15 @@ jobs:
- checkout - checkout
- setup_remote_docker - setup_remote_docker
- run: - run:
name: ci job started name: CI job started
command: "./scripts/ci-job-started.sh" command: "./scripts/ci-job-started.sh"
- run: - run:
name: install docker name: Install docker
command: | command: |
apt-get update apt-get update
apt-get install -y docker.io apt-get install -y docker.io
- run: - run:
name: build grafana docs website name: Build grafana docs website
command: | command: |
# https://circleci.com/docs/2.0/building-docker-images/#mounting-folders # https://circleci.com/docs/2.0/building-docker-images/#mounting-folders
# create a dummy container which will hold a volume with config # create a dummy container which will hold a volume with config
...@@ -737,11 +800,11 @@ jobs: ...@@ -737,11 +800,11 @@ jobs:
# start an application container using this volume # start an application container using this volume
docker run --volumes-from docs-website --rm -it grafana/docs-base:latest /bin/bash -c 'npm i && make prod' docker run --volumes-from docs-website --rm -it grafana/docs-base:latest /bin/bash -c 'npm i && make prod'
- run: - run:
name: ci job failed name: CI job failed
command: "docker stop docs-website && docker rm docs-website && ./scripts/ci-job-failed.sh" command: "docker stop docs-website && docker rm docs-website && ./scripts/ci-job-failed.sh"
when: on_fail when: on_fail
- run: - run:
name: ci job succeeded name: CI job succeeded
command: "docker stop docs-website && docker rm docs-website && ./scripts/ci-job-succeeded.sh" command: "docker stop docs-website && docker rm docs-website && ./scripts/ci-job-succeeded.sh"
when: on_success when: on_success
...@@ -749,12 +812,19 @@ jobs: ...@@ -749,12 +812,19 @@ jobs:
docker: docker:
- image: circleci/node:12 - image: circleci/node:12
steps: steps:
- run:
name: Exit if forked PR
command: |
if [[ -n "$CIRCLE_PR_NUMBER" ]]; then
echo "Nothing to do for forked PRs, so marking this step successful"
circleci step halt
fi
- checkout - checkout
- run: - run:
name: ci job started name: CI job started
command: "./scripts/ci-job-started.sh" command: "./scripts/ci-job-started.sh"
- run: - run:
name: Boostrap lerna name: Bootstrap lerna
command: "npx lerna bootstrap" command: "npx lerna bootstrap"
- run: - run:
name: npm - Prepare auth token name: npm - Prepare auth token
...@@ -763,11 +833,11 @@ jobs: ...@@ -763,11 +833,11 @@ jobs:
name: Release packages name: Release packages
command: ./scripts/build/release-packages.sh "${CIRCLE_TAG}" command: ./scripts/build/release-packages.sh "${CIRCLE_TAG}"
- run: - run:
name: ci job failed name: CI job failed
command: "./scripts/ci-job-failed.sh" command: "./scripts/ci-job-failed.sh"
when: on_fail when: on_fail
- run: - run:
name: ci job succeeded name: CI job succeeded
command: "./scripts/ci-job-succeeded.sh" command: "./scripts/ci-job-succeeded.sh"
when: on_success when: on_success
......
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