Skip to content

Commit

Permalink
Use pre-built image for docs-preview to speed up the build
Browse files Browse the repository at this point in the history
  • Loading branch information
zzak authored and rafaelfranca committed Apr 15, 2024
1 parent df303fb commit 9cf1d86
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 14 additions & 3 deletions pipelines/docs-preview/initial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ steps:
command: |
PATH=/bin:/usr/bin
set -e
if [ -d ".buildkite" ]; then
echo "+++ :bk-status-failed: .buildkite/ already exists; please remove it and try again"
exit 1
fi
if [ -n "$$CONFIG_REPO" ]; then
GIT_REPO="$$CONFIG_REPO"
else
GIT_REPO="https://github.com/rails/buildkite-config"
fi
GIT_REPO="https://github.com/rails/buildkite-config"
GIT_BRANCH="main"
GIT_BRANCH="$${CONFIG_BRANCH-main}"
GIT_BRANCH="$${GIT_BRANCH#*:}"
echo "Cloning buildkite-config:"
echo "git clone -b \"$$GIT_BRANCH\" \"$$GIT_REPO\" .buildkite"
Expand All @@ -25,6 +32,7 @@ steps:
sh -c "$$PIPELINE_COMMAND"
([ -f .buildkite/.dockerignore ] && cp .buildkite/.dockerignore .dockerignore) || true
plugins:
- artifacts#v1.9.3:
upload: ".dockerignore"
Expand All @@ -38,21 +46,24 @@ steps:
- .buildkite/runner
compressed: ".buildkite.tgz"
env:
BUNDLE_FROZEN: true
PIPELINE_COMMAND: >-
docker run --rm
-v "$$PWD":/app:ro -w /app
-e CI
-e BUILDKITE
-e BUILDKITE_AGENT_META_DATA_QUEUE
-e BUILDKITE_BRANCH
-e BUILDKITE_BUILD_ID
-e BUILDKITE_PIPELINE_SLUG
-e BUILDKITE_PULL_REQUEST
-e BUILDKITE_PULL_REQUEST_BASE_BRANCH
-e BUILDKITE_REBUILT_FROM_BUILD_ID
-e BUILD_QUEUE
-e BUNDLE_FROZEN
-e DOCKER_IMAGE
-e RUN_QUEUE
-e QUEUE
ruby:latest
.buildkite/bin/pipeline-generate docs-preview |
buildkite-agent pipeline upload
timeout_in_minutes: 5
8 changes: 7 additions & 1 deletion pipelines/docs-preview/pipeline.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
# frozen_string_literal: true

Buildkite::Builder.pipeline do
require "buildkite_config"
use Buildkite::Config::BuildContext

plugin :docker, "docker#v5.10.0"
plugin :artifacts, "artifacts#v1.9.3"

build_context = context.extensions.find(Buildkite::Config::BuildContext)
build_context.ruby = Buildkite::Config::RubyConfig.new(prefix: "ruby:", version: Gem::Version.new("3.3"))

command do
label "build", emoji: :rails
key "build"
command "bundle install && bundle exec rake preview_docs"
plugin :docker, {
image: "ruby:latest",
image: build_context.image_name_for("br-main", prefix: nil),
environment: [
"BUILDKITE_BRANCH",
"BUILDKITE_BUILD_CREATOR",
Expand Down

0 comments on commit 9cf1d86

Please sign in to comment.