-
Notifications
You must be signed in to change notification settings - Fork 345
Buildkite build PR job #2835
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
Buildkite build PR job #2835
Conversation
They're now set in the pre-command hook
a48ae90
to
126758b
Compare
This is a more explicit approach that can be applied to the PR pipeline only and allows to run only once before/after the build, as opposed to the pre/post command hooks that run for every command.
This reverts commit 126758b. We no longer invoke the pre-commit hook from the pre-command
This makes sense to me. I can see this causing problems if someone pushes to a PR, and then relatively quickly pushes a followup commit. At a minimum, it's worth documenting, but folks are probably used to Jenkins enough to know to just run a new build if they see anything strange. I imagine we could also check if any other builds are running on the same content repo and PR, and either abort the current one or cancel the other one, but this might require additional credentials to talk to Buildkite about other running builds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like how readable the build_pr.sh
script ended up being, and could be used for PRs in both the docs repo and content repos!
I handful of questions and suggestions, but nothing that should block the merge. Some of the suggestions could also be handled in follow-up PRs.
rebuild_opt=" --rebuild" | ||
elif [[ ${GITHUB_PR_COMMENT_VAR_SKIP_OPT:="unset"} == "skiplinkcheck" ]];then | ||
build_args+=" --skiplinkcheck" | ||
if [[ ${GITHUB_PR_COMMENT_VAR_WARN_OPT:="unset"} == "warnlinkcheck" ]];then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't fully thought through how this works, but it doesn't seem like it's possible for --warnlinkcheck
to get set unless --skiplinkcheck
is also set, but I thought that --skiplinkcheck
overrides --warnlinkcheck
. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theses flags will be passed by the Buildkite PR bot based on the comment left on the PR - as configured here:
"trigger_comment_regex": "run docs-build ?(?<rebuild_opt>rebuild)? ?(?<warn_opt>warnlinkcheck)? ?(?<skip_opt>skiplinkcheck)?",
Nothing prevents a GH user from passing all 3 flags - does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What flags would you pass to get --warnlinkcheck
to run? If you pass GITHUB_PR_COMMENT_VAR_WARN_OPT=warnlink
, then build_args
won't be modified unless you also pass GITHUB_PR_COMMENT_VAR_SKIP_OPT=skiplinkcheck
.
But you can't pass both, or the docs build should raise an error.
Co-authored-by: Greg Back <[email protected]>
Secrets should be defined in pre-command hooks to benefit from redaction See https://buildkite.com/docs/pipelines/managing-log-output#redacted-environment-variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still confused about how to pass --warnlinkcheck
, and have one other small suggestion, but I'll approve this so you can merge, in case I'm misunderstanding how the logic works.
Co-authored-by: Greg Back <[email protected]>
(moved over from #2804 since the previous one was started by a contractor no-longer at Elastic and I took over the work from there).
This PR introduces a Buildkite job to build pull requests. It replaces and combine the following Jenkins job:
General approach
In the Jenkins world, we setup a dedicated job per repository with the job dsl coming from a template. We took a different approach in Buildkite, and instead setup a single Buildkite job that gets triggered for every PR builds on any of the docs product repo or the elastic/docs repo. This allows us to keep things tidy in Buildkite ( a single job) and limit considerably the amount of CI code to write in any product repository (see discussion on this approach here).
There are some downsides to this approach however:
going to Buildkite build page looking for a specific build for a PR is not straight forward - it can be done by adding GET params to the builds url. For eg, to view the builds PR 3366 in
elastic/observability-docs
, we can visit the following URL: https://buildkite.com/elastic/docs-build-pr/builds?meta_data[repo_pr]=observability-docs_3366Since the same job is used for any PR in any of the product repositories, we allow concurrent builds of that job (otherwise, we could only run a single doc build at a time for any of the product repo). I have not seen/experienced/validated this yet, but we could run into scenarios where the same PR with 2 docs builds triggered in a short time frame try to push to the same preview branch and .
Docs repo configuration
We use the Buildkite PR bot in a non-conventional manner to achieve the above result:
master
branch ofelastic/docs
- here (That file is not read in other branches)."always_trigger_branch":true
option. This is currently set to this branch while under development.elastic:docs
repository, we use the default"always_trigger_branch":false
option - since the build logic is stored within theelastic:docs
repo - this is what would allow us to test out changes to the build logic itself.Finally, the Buildkite PR bot allows for changes detections at certain path - this allows us to not trigger a PR build for every change in every docs repo, but only target doc changes.
With the above said, we have 3 configuration blobs in the PR bot config:
./docs
folder should be added hereelastic/docs
is controlled hereThe below config options have been configured for all of the above repositories:
rebuild
warnlinkcheck
skiplinkcheck
(takes precedence over the warnlinkcheck option)PR job setup
When a docs PR job is opened / commented on, the Buildkite PR bot will trigger a docs-build-pr job, passing a few key env variables about the PR. The build script checks out that specific branch of the repository locally and references it in the build argument leveraging the
--sub-dir
option.Similarly to Jenkins, PR on the
elastic/docs
repo always trigger a fullrebuild
.PR are annotated with a link to the job preview and diff upon successful build - see example here.
Similar to other Buildkite job, docs preview changes are pushed to the bk branch until the migration is complete.
pre/post command hooks
We're leveraging theses the pre-command hook to setup the build commit status to
pending
and the post-commit one tosuccess
andfailure
. At this time, we're re-using the GITHUB token from thepreview-cleaner
job that has sufficient permissions to do such API calls.All of the perms (to clone repo, commit) are tied to elasticmachine - I suspect this may have to change at some point in the future, but that's the current setup.
Jenkins/Buildkite comparison
Example of jobs that ran, and the differences between Jenkins and Buildkite, and the diff between the built-docs branches.
Note - on the docs changes in the
docs
repo, we're seeing images conflicts and changes - see convo about it here.