-
Notifications
You must be signed in to change notification settings - Fork 200
[CI] Use monorepo-diff BK plugin to conditionally run unit tests
#11066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
This pull request does not have a backport label. Could you fix it @ycombinator? 🙏
|
monorepo-diff BK plugin to conditionally run unit tests
|
@v1v Could you help me figure out what's going wrong in https://buildkite.com/elastic/elastic-agent/builds/30064? Thanks! |
|
as far as I see, groups are only available from at least that' when it's shown in the docs. I normally recommend starting with simple use cases and then iterating. For instance:
Otherwise, in my experience, it's hard to debug errors in Buildkite related to the syntax Another alternative could be to contact BK support; maybe they have some insights I'm not aware of. It definitely isn't easy to find issues in the BK pipeline :/ |
b3de7e7 to
745aa9b
Compare
This reverts commit 745aa9b.
💛 Build succeeded, but was flaky
Failed CI StepsHistory
cc @ycombinator |
|
Thanks for the advice, @v1v. I took your suggestion and simplified the pipeline changes to only have the With that, I first made a commit with a change to Then, I reverted that commit, so the only files in this PR's diff were non- What am I missing? Thanks. |
I'd recommend debugging what the diff command produces first: steps:
- label: "Debug diff"
command: "git diff --name-only HEAD~1"
- label: "Unit tests - Ubuntu 22.04"
key: "unit-tests-2204"
plugins:
- monorepo-diff#v1.2.0:
diff: "git diff --name-only HEAD~1"
interpolation: falseOr even using https://github.com/buildkite-plugins/monorepo-diff-buildkite-plugin/blob/main/README.md#log_level-optional Then I'd recommend to see how other projects use it: For instance, in Or look for the details that the Platform Productivity team has done with the 'self-service' automation. as far as I see they use the below snippets (pipeline and diff command) ---
steps:
- label: "Triggering pipelines"
plugins:
monorepo-diff#v1.5.1:
diff: ".buildkite/diff ${BUILDKITE_COMMIT}"
wait: true
watch:
- path: "renovate.json"
config:
label: "Verify Renovate configuration"
command: "renovate-config-validator"
agents:
image: "...."
- path: "catalog-info.yaml"
config:
command: "/agent/check-catalog-info.sh"
agents:
image: "...."
- default:
config:
label: ":pipeline: Upload default Pipeline"
command: "buildkite-agent pipeline upload .buildkite/default-pipeline.yml"#!/bin/bash
# Produces a list of changed files between two commits (works for merges and
# regular commits).
# Used in conjunction with the monorepo-diff-buildkite-plugin to determine
# which pipelines to upload/trigger based on the files changed.
[ $# -lt 1 ] && { echo "argument is missing."; exit 1; }
COMMIT=$1
HEAD_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
BRANCH_POINT_COMMIT=$(git merge-base "$HEAD_BRANCH" "$COMMIT")
if [ "$BUILDKITE_BRANCH" == "$HEAD_BRANCH" ]; then
echo "diff between $COMMIT and HEAD~1"
git diff --raw HEAD~1 | awk '{print $6; if($7) {print $7}}'
else
echo "diff between $COMMIT and $BRANCH_POINT_COMMIT"
git diff --raw "$COMMIT".."$BRANCH_POINT_COMMIT" | awk '{print $6; if($7) {print $7}}'
fihttps://github.com/buildkite/monorepo-example#buildkite-monorepo-example is the official docs from BK about using the plugin.. |
What does this PR do?
This PR uses the Buildkite
monorepo-diffplugin to run unit tests only if relevant files have changed.Why is it important?
To make CI runs more efficient.
Testing
TODO