Skip to content

Fancy --sub_dir and --keep_hash #1262

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

Merged
merged 7 commits into from
Oct 8, 2019
Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Oct 7, 2019

This adds a fancy interaction between --sub-dir and --keep_hash that
is meant to make sure we build exactly the right docs for pull
requests.

When we first deploy pull request builds we targeted them at the tip of
the pull request branch. This caused trouble because the tip of the pull
request branch was often behind the last successful build. Building the
docs against that would often cause spurious failure from out of date
links. Merging master into the PR branch usually fixed it but it was
annoying.

We fixed this problem by switching our target to the result of merging
the pull request branch into the target branch. This was better
because it had fewer spurious failures, but often caused us to think
that the docs changes were larger than they actually were because the
target branch often had changes in it that hadn't yet been picked up by
the docs build. This was annoying because the diffs generated by the
docs builds had changes that weren't part of the PR. Which made it
difficult to track down what actually changed.

This solves the problem by first merging the --sub_dired branch into
the last successful docs build. Thus we only build exactly what is in
the PR. We trigger this behavior by checking for both the --keep_hash
and --sub_dir flags and checking for outstanding changes in the
--sub_dired branch.

This behavior might end up being slower sometimes because merging can be
expensive, but it is usually less expensive than building a book we
don't have to build. So maybe it'll all come out in the wash.

This adds a fancy interaction between `--sub-dir` and `--keep_hash` that
is meant to make sure we build *exactly* the right docs for pull
requests.

When we first deploy pull request builds we targeted them at the tip of
the pull request branch. This caused trouble because the tip of the pull
request branch was often behind the last successful build. Building the
docs against that would often cause spurious failure from out of date
links. Merging `master` into the PR branch usually fixed it but it was
annoying.

We fixed this problem by switching our target to the result of merging
the pull request branch into the target branch. This was *better*
because it had fewer spurious failures, but often caused us to think
that the docs changes were larger than they actually were because the
target branch often had changes in it that hadn't yet been picked up by
the docs build. This was annoying because the `diff`s generated by the
docs builds had changes that weren't part of the PR. Which made it
difficult to track down what actually changed.

This solves the problem by first merging the `--sub_dir`ed branch into
the last successful docs build. Thus we only build *exactly* what is in
the PR. We trigger this behavior by checking for both the `--keep_hash`
and `--sub_dir` flags *and* checking for outstanding changes in the
`--sub_dir`ed branch.

This behavior might end up being slower sometimes because merging can be
expensive, but it is usually less expensive than building a book we
don't have to build. So maybe it'll all come out in the wash.
@nik9000 nik9000 requested a review from olksdr October 7, 2019 21:22
@nik9000
Copy link
Member Author

nik9000 commented Oct 7, 2019

@olksdr This one kind of terrifies me a little, but I think it'll be ok. I did a fair bit of playing with it locally and everything seemed right. If we merge this then all of the PR builds will immediately start doing noop merges because we build against github's pre-merged hash. When we're good and ready we can switch them.

Copy link
Contributor

@olksdr olksdr left a comment

Choose a reason for hiding this comment

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

I've left only one question - otherwise lgtm

lib/ES/Repo.pm Outdated
run qw(git diff-index --quiet HEAD --);
1;
};
unless ( $has_uncommitted_changes ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it be if here ?

if ($has_uncommitted_changes ) {
 # execute the code inside ?
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Weird! I've got something backwards....

Copy link
Member Author

Choose a reason for hiding this comment

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

OK - here is what happened --exit-code causes run to throw an exception if there are changes. Which causes eval to return 0. So, you could say that I named the variable backwards. Fixing.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah 😄 the name was confusing a little bit.

@olksdr
Copy link
Contributor

olksdr commented Oct 8, 2019

@nik9000 before I finished this review you'd already fixed few things 😄

@nik9000
Copy link
Member Author

nik9000 commented Oct 8, 2019

@nik9000 before I finished this review you'd already fixed few things smile

Sorry!

@nik9000 nik9000 merged commit a28a83b into elastic:master Oct 8, 2019
nik9000 added a commit that referenced this pull request Oct 8, 2019
It doesn't seem to be doing the right thing in PRs....

This reverts commit a28a83b.
nik9000 added a commit that referenced this pull request Oct 8, 2019
nik9000 added a commit that referenced this pull request Oct 8, 2019
New, this time real alarm. Reverting.

This reverts commit 0efe2bc.
@nik9000
Copy link
Member Author

nik9000 commented Oct 8, 2019

I've reverted this because it looked like it was causing trouble with the PR builds that it was trying to help. I'll investigate further.

nik9000 added a commit that referenced this pull request Oct 9, 2019
nik9000 added a commit that referenced this pull request Oct 10, 2019
Revert "Revert "Revert "Revert "Fancy --sub_dir and --keep_hash (#1262)""""

Adds support building from references

We try to do a ton of `git` operations inside the docker container while
building docs. Without this change if one of those operations points to
a git repo that was created with `--reference` but wasn't
`--dissociate`d then we'd fail because with didn't mount the reference.
This mounts the reference into the docker container *exactly* where they
exist on the host system. Doing anything less makes git very unhappy.
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