Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ steps:
(build.pull_request.id != null && !build.pull_request.repository.fork) ||
((build.source == "schedule" || build.source == "ui") && build.env("K8S_NIGHTLY") == "1") ||
((build.branch == "main" || build.branch =~ /^release\//) && build.source == "webhook")
command: buildkite-agent pipeline upload .buildkite/testsuite.yml
command: .buildkite/scripts/conditional_testsuite.sh

# NOTE: This build IS NOT dependent on tests passing due to their current flakey state.
# It's recommended to check that tests have passed for the given commit before using it.
Expand Down
57 changes: 57 additions & 0 deletions .buildkite/scripts/conditional_testsuite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
set -eo pipefail

if [[ "$BUILDKITE_SOURCE" == "webhook" && -n "$BUILDKITE_PULL_REQUEST" && "$BUILDKITE_PULL_REQUEST" != "false" ]]; then
# It's a PR, let's check what changed
base_branch="$BUILDKITE_PULL_REQUEST_BASE_BRANCH"
if [[ -z "$base_branch" ]]; then
base_branch="main"
fi

# Fetch base branch to compare against
git fetch origin $base_branch

# Get changed files
changed_files=$(git diff --name-only origin/$base_branch...HEAD)

# Check if any non-docs/non-GHA files changed
requires_ci=false
for file in $changed_files; do
if [[ ! "$file" =~ ^docs/ && ! "$file" =~ ^\.github/ ]]; then
requires_ci=true
Comment on lines +17 to +21
break
fi
done
Comment on lines +12 to +24

if [[ "$requires_ci" == "false" ]]; then
echo "--- Skipping CI as only docs or GHA workflows changed"

# Generate a dummy pipeline that just passes to satisfy required checks
cat << 'PIPELINE' | buildkite-agent pipeline upload
steps:
- command: echo "Skipped CI as no source files changed"
label: ":fast_forward: Skipped"
notify:
- github_commit_status:
context: "Operator Test Suite"
- github_commit_status:
context: "k8s-operator-v2"
- github_commit_status:
context: "k8s-operator-v2-helm"
- github_commit_status:
context: "Lint"
- github_commit_status:
context: "Unit Tests"
- github_commit_status:
context: "Integration Tests"
- github_commit_status:
context: "Acceptance Tests"
- github_commit_status:
context: "Kuttl-V1-Nodepools Tests"
PIPELINE
exit 0
fi
fi

# Fallback to normal behavior
buildkite-agent pipeline upload .buildkite/testsuite.yml
Loading