From 5f4720556ed797d04ffad709c8b2a98f34741211 Mon Sep 17 00:00:00 2001 From: Hartley McGuire Date: Sat, 20 Sep 2025 15:05:48 -0400 Subject: [PATCH] Automatically ci-skip if all changed files are md Currently, documentation changes require contributors to add a variation of "ci skip" to their pull request in order to not run the full Rails test suite. However, it requires contributors to know about this feature in order to use it (to get faster/less flaky builds). This commit tries to remove the requirements of that knowledge by automatically skipping the full test suite in some cases (currently when all changed files are markdown). It also introduces a new opt-out "ci full" which can be used in cases where the automatic opt-out is undesired for some reason. --- lib/buildkite/config/build_context.rb | 11 +++++++++++ pipelines/rails-ci/pipeline.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/buildkite/config/build_context.rb b/lib/buildkite/config/build_context.rb index c5f7760..da68a37 100644 --- a/lib/buildkite/config/build_context.rb +++ b/lib/buildkite/config/build_context.rb @@ -23,11 +23,22 @@ def nightly? ENV.has_key?("RAILS_CI_NIGHTLY") end + def full? + # [ci full], [full ci], [ci-full], or [full-ci] + [ENV["BUILDKITE_MESSAGE"], FetchPr.title].grep(/(ci full|full ci|ci-full|full-ci)/i).any? + end + def skip? # [ci skip], [skip ci], [ci-skip], or [skip-ci] [ENV["BUILDKITE_MESSAGE"], FetchPr.title].grep(/(ci skip|skip ci|ci-skip|skip-ci)/i).any? end + def only_markdown? + `git diff --name-only $BUILDKITE_PULL_REQUEST_BASE_BRANCH` + .lines(chomp: true) + .all? { |line| line.end_with? ".md" } + end + def rails_root Pathname.pwd end diff --git a/pipelines/rails-ci/pipeline.rb b/pipelines/rails-ci/pipeline.rb index fe59733..f8dc4a7 100644 --- a/pipelines/rails-ci/pipeline.rb +++ b/pipelines/rails-ci/pipeline.rb @@ -42,7 +42,7 @@ end end - if build_context.skip? + if !build_context.full? && (build_context.skip? || build_context.only_markdown?) command do label ":bk-status-passed: Build skipped" skip true