drdoctr/doctr

doctr not working with forks

kyleniemeyer opened this issue · 19 comments

Although I haven't changed anything except to add some new files, I'm now getting a Don't have permission to push. Not trying. message in Travis, which seems to prevent pushing the generated files back to the repo for GitHub Pages to pick up.

Looking at a recent successful build, it looks like that time it did a git pull then git push, neither of which is happening now.

Any ideas?

It should print one of these messages indicating why it thinks it shouldn't push:

doctr/doctr/travis.py

Lines 571 to 602 in 0f19ff7

def determine_push_rights(*, branch_whitelist, TRAVIS_BRANCH,
TRAVIS_PULL_REQUEST, TRAVIS_TAG, build_tags, fork):
"""Check if Travis is running on ``master`` (or a whitelisted branch) to
determine if we can/should push the docs to the deploy repo
"""
canpush = True
if TRAVIS_TAG:
if not build_tags:
print("The docs are not pushed on tag builds. To push on future tag builds, use --build-tags")
return build_tags
if not any([re.compile(x).match(TRAVIS_BRANCH) for x in branch_whitelist]):
print("The docs are only pushed to gh-pages from master. To allow pushing from "
"a non-master branch, use the --no-require-master flag", file=sys.stderr)
print("This is the {TRAVIS_BRANCH} branch".format(TRAVIS_BRANCH=TRAVIS_BRANCH), file=sys.stderr)
canpush = False
if TRAVIS_PULL_REQUEST != "false":
print("The website and docs are not pushed to gh-pages on pull requests", file=sys.stderr)
canpush = False
if fork:
print("The website and docs are not pushed to gh-pages on fork builds.", file=sys.stderr)
canpush = False
if last_commit_by_doctr():
print(red("The last commit on this branch was pushed by doctr. Not pushing to "
"avoid an infinite build-loop."), file=sys.stderr)
canpush = False
return canpush

The exception is if you are using --no-push or have doctr: push: false in your .travis.yml. It won't print a message indicating why in that case.

OK, I see The website and docs are not pushed to gh-pages on fork builds... what does this mean, and why would this be an issue now? (Was this added in a newer version of doctr or something?)

My repo is a fork, but that's because I forked my website template from elsewhere a while ago. How can I override this?

That's curious if it used to work on the same repo.

Travis doesn't allow secure environment variables on builds from forked repos (unless things have changed). You may need to delete the repo and recreate it as a non-forked repo.

But again that's curious if it used to work. If that's the case we should figure out what is going on.

Yeah, it used to work fine, and I haven't changed anything. I hadn't made any changes in a few weeks, that's all.

OK, I'm guessing the last build was before the most recent release of doctr. The change to not push on forks was new https://drdoctr.github.io/changelog.html, #332. I guess the logic isn't correct, or maybe Travis changed something. I had thought secure environment variables didn't work at all on forks, but I guess that isn't the case. Maybe we should only not push on a fork if the environment variable isn't there.

If you need a workaround you can manually install doctr 1.7.4.

Fix started at #343. I still need to fix the tests and do some manual testing. If you can check if that branch works on your repo that would help.

Can I get Travis to use that one somehow, or should I just try locally?

It won't work locally. You can install it on Travis using pip install git+git://github.com/drdoctr/doctr@forks.

@asmeurer thanks—I actually figured that out after commenting here... build is in progress.

So, I tried using that fork, but what's happening is weird... I see this message The last commit on this branch was pushed by doctr. Not pushing to avoid an infinite build-loop., even after pushing a few content changes.

The full log is at https://gist.github.com/kyleniemeyer/0da4ea0d3f175c7401ca9f5f53a4dd31

Though it does look like it's successfully pushing the generated content. No idea.

That happens if you run Travis on the GitHub pages branch itself (gh-pages for most repos, master for *.github.io repos). That's because doctr pushes up to that branch, so otherwise it would get caught in an infinite build loop.

Is this close to being resolved? I've been using doctr for a number of my open-source projects and I love it!

I have a side project that uses several open-source projects I develop and thought it'd be cool to showcase the project in a sphinx-gallery. I set up the docs to build and they were deploying from Travis via doctr but then I filled out the rest of the project and it requires more resources than Travis can provide (13 GB of ram at least and preferably a GPU) - I was thinking that I'd manually build and deploy the docs from my local machine since I won't edit the project moving forward but I'm getting this issue when I run:

doctr deploy --force --built-docs ./docs/_build/html .
......

[__doctr_working_branch 545c548] Update docs after building Travis build <unknown> of GeothermalDesignChallenge
 30 files changed, 246 insertions(+), 61 deletions(-)
 create mode 100644 .doctr-files
Don't have permission to push. Not trying.
git checkout 33cdb9ab37bb7801d3873a4fb87011cb5bda901b
Note: checking out '33cdb9ab37bb7801d3873a4fb87011cb5bda901b'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 33cdb9a Revert to xenial distribution
git stash pop
Already up to date!
HEAD detached at 33cdb9a
nothing to commit, working tree clean
Dropped refs/stash@{0} (0bb8899dbb2347db767d67e3b423bacd291cbf45)

The project is: https://github.com/OpenGeoVis/GeothermalDesignChallenge

I do intend to fix this issue. It requires some manual testing to get any fix like this, which is why I've been a bit slow. I'll try to get to it this week.

However, this sounds like a separate issue from what you are having. doctr was never designed to be run locally. We could probably make it work, but it would require some changes.

However, this sounds like a separate issue from what you are having. doctr was never designed to be run locally. We could probably make it work, but it would require some changes.

How big of changes?

I've honestly never thought of doing it, so I'm not sure. I'd have to take a look to see. Feel free to open an issue for it.

I opened #345 about it.