Skip to content

Buildkite: Skip PR builds for non-legacy branches#3343

Open
reakaleek wants to merge 1 commit into
masterfrom
torpid-wildcat
Open

Buildkite: Skip PR builds for non-legacy branches#3343
reakaleek wants to merge 1 commit into
masterfrom
torpid-wildcat

Conversation

@reakaleek

Copy link
Copy Markdown
Member

What

Make the required buildkite/docs-build-pr check exit 0 early (reporting success without building) when a PR targets a branch that no longer carries legacy AsciiDoc docs.

Why

As docs migrate from this legacy AsciiDoc system to docs-builder, PRs targeting already-migrated branches (stack main/9.x, ECK 3.x, etc.) still trigger the required check and run a useless build. We want those to go green instantly. The check can't simply be removed because it's required.

This supersedes #3233, whose single regex ^([0-8])\.[0-9]+$ broke non-stack-versioned doc sets, as reviewers flagged:

  • ECE (cloud) uses milestone branch names (ms-119, ms-105…) → matched nothing → would have wrongly skipped every ECE build.
  • ECK (cloud-on-k8s) is legacy only on 2.x/1.x/0.x; 3.x lives in docs-builder but matched ^[0-8]\. → would have wrongly built.

How

  • New .buildkite/scripts/legacy_branches.pl derives each repo's legacy branch set directly from conf.yaml — reusing the build's own YAML::LoadFile parser and the branch-resolution convention from lib/ES/Book.pm / lib/ES/BranchTracker.pm (LHS branch keys, map_branches, exclude_branches). It maps the GitHub repo name to the conf repo key via the top-level repos: URL map (handles cases like esfelastic-serverless-forwarder).
  • build_pr.sh consults the helper inside the product-repo path (before cloning) and exits 0 when the target branch isn't in the repo's legacy set. Fails open on any helper error or unknown repo, so a real build is never blocked.
  • Deriving from conf.yaml means the guard needs no edits as products migrate — no hardcoded version patterns.

Test plan

Verified the helper locally (Perl YAML present):

  • legacy_branches.pl elasticsearch8.19 … 0.90, no 9.x
  • legacy_branches.pl cloudms-* milestones (+ master), no main
  • legacy_branches.pl cloud-on-k8s0.8 … 2.16, no 3.x
  • legacy_branches.pl elastic-serverless-forwarder → resolves via esf key
  • legacy_branches.pl clients-teammain (proves map_branches)
  • unknown repo → exit 2 (fail open)
  • shellcheck .buildkite/scripts/build_pr.sh clean for the new guard

Behavioral: elasticsearch+main → skip 0; +8.18 → build. cloud+main → skip 0; +ms-119 → build. cloud-on-k8s+3.0 → skip 0; +2.16 → build.

Notes

The guard runs on the host agent (docs-ubuntu-2204). libyaml-perl is installed in the build Dockerfile (inside the container) but the host image's Perl YAML status is unconfirmed. The fail-open behavior means no regression if it's missing — the skip simply won't take effect until libyaml-perl is added to the agent image (verify with perl -MYAML -e1).

🤖 Generated with Claude Code

Make the docs-build-pr check exit 0 early (reporting success on the
still-required check) when a PR targets a branch that no longer carries
legacy AsciiDoc docs. A new Perl helper derives each repo's legacy branch
set from conf.yaml so the guard stays correct as products migrate to
docs-builder, without hardcoded version patterns.

Supersedes #3233, which used a single regex that broke non-stack-versioned
doc sets (e.g. ECE's ms-* branches, ECK 3.x).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@reakaleek reakaleek requested a review from a team as a code owner June 22, 2026 18:43
@reakaleek reakaleek requested a review from theletterf June 22, 2026 18:43
@github-actions

Copy link
Copy Markdown

A documentation preview will be available soon.

Request a new doc build by commenting
  • Rebuild this PR: run docs-build
  • Rebuild this PR and all Elastic docs: run docs-build rebuild

run docs-build is much faster than run docs-build rebuild. A rebuild should only be needed in rare situations.

If your PR continues to fail for an unknown reason, the doc build pipeline may be broken. Elastic employees can check the pipeline status here.

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great and love the pl checking conf.yml

I think we can hardcore main and master as fallback even if the yaml dep is missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants