Skip to content
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

First experiment: stable-docs #1

Closed
simonw opened this issue Aug 20, 2023 · 43 comments
Closed

First experiment: stable-docs #1

simonw opened this issue Aug 20, 2023 · 43 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Aug 20, 2023

I want to be able to publish updates to my /en/stable/ docs without needing to ship an entire release - for things like typo fixes and plugin directories.

My initial idea:

Have a stable-docs branch which is published by ReadTheDocs as the stable version.

Publish workflow force-updates that branch to be a copy of the tag that was just released

A file called _plugins.md lives in the repo and has the content for the plugins directory

Another workflow watches for changes to that file and automatically merges those changes into the stable-docs branch

So now… editing _plugins.md always goes live on stable-docs - and edits can be made on stable-docs to other stuff too, which will be over-written the next time a stable release is issued.

Would be good to have non-destructive merges into stable-docs when a release goes out just to avoid any chance of accidentally deleting edits made there that need to be preserved in history.

Also: any time you commit a change that modifies docs, tag it with !stable-docs and a workflow will automatically include that change in the current stable-docs branch.

@simonw simonw added the enhancement New feature or request label Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

Used GPT-4 to create an initial workflow for this: https://chat.openai.com/share/dbd19d7c-c022-4a11-9a52-7217316afd2a

simonw added a commit that referenced this issue Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

The first run of that workflow created this branch: https://github.com/simonw/simonw-readthedocs-experiments/tree/stable-docs

@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

https://readthedocs.org/dashboard/simonw-readthedocs-experiments/advanced/ has the default settings:

CleanShot 2023-08-20 at 11 01 27@2x

It's not giving me a "stable" option yet, maybe I need to ship a release?

simonw added a commit to simonw/simonw that referenced this issue Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

Here's what that release did: https://github.com/simonw/simonw-readthedocs-experiments/actions/runs/5918859742/job/16048570940

CleanShot 2023-08-20 at 11 08 47@2x

No need for it to update the branch since there were no changes to it yet.

@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

OK, ReadTheDocs noticed the release and created a stable version:

CleanShot 2023-08-20 at 11 10 20@2x

Now settings gives me the option to switch to that, which I'll do now: https://readthedocs.org/dashboard/simonw-readthedocs-experiments/advanced/

CleanShot 2023-08-20 at 11 11 33@2x

https://simonw-readthedocs-experiments.readthedocs.io/ now redirects to https://simonw-readthedocs-experiments.readthedocs.io/en/stable/

simonw added a commit that referenced this issue Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

That commit triggered an error: https://github.com/simonw/simonw-readthedocs-experiments/actions/runs/5918907110/job/16048660640

CleanShot 2023-08-20 at 11 14 18@2x

- name: Check if stable-docs branch exists
run: |
if ! git rev-parse --verify stable-docs > /dev/null 2>&1; then
git checkout -b stable-docs
git push -u origin stable-docs
fi

@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

I think this test found that stable-docs did not exist even when it does:

if ! git rev-parse --verify stable-docs > /dev/null 2>&1; then

simonw added a commit that referenced this issue Aug 20, 2023
simonw added a commit that referenced this issue Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

OK, that worked - the commit now skips the branch creation bit, but doesn't do anything else.

Next I'll test mentioning !stable-docs in a commit and see what happens.

simonw added a commit that referenced this issue Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

No, that didn't work:

CleanShot 2023-08-20 at 11 33 03@2x

@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

The thing I'm looking for here is to update stable-docs with the changes from the new commit.

But... I only want the docs/ changes. So I need a way of saying "cherry-pick changes from this commit that affect docs/ and apply those".

This might work: https://chat.openai.com/share/e4605046-d9e9-4fb6-838a-d0653670bbff

git show COMMIT_HASH -- docs/ > commit.patch
git apply commit.patch
git add docs/

I tested this and git show HASH --docs does indeed only return the diff for the bits that affect docs/.

@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

CleanShot 2023-08-20 at 12 30 16@2x

@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

OK, empty patches are now handled.

simonw added a commit that referenced this issue Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

That didn't quite work:

CleanShot 2023-08-20 at 12 31 34@2x

@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

Why did it create a new branch? It was supposed to use the origin/stable-docs branch.

simonw added a commit that referenced this issue Aug 20, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 20, 2023

Oops, "No changes to docs/ in this commit." - because I edited the README not something in docs/.

simonw added a commit that referenced this issue Aug 20, 2023
simonw added a commit that referenced this issue Aug 21, 2023
simonw added a commit that referenced this issue Aug 21, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

Looks promising: https://github.com/simonw/simonw-readthedocs-experiments/actions/runs/5921022485/job/16053032053

CleanShot 2023-08-20 at 18 48 24@2x

It triggered a build: https://readthedocs.org/projects/simonw-readthedocs-experiments/builds/

CleanShot 2023-08-20 at 18 49 02@2x

Those cancelled are what happens when you push a new commit before latest has finished building the last one.

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

I think this might be working!

simonw added a commit that referenced this issue Aug 21, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

https://simonw-readthedocs-experiments.readthedocs.io/en/latest/ now has the 3 page docs site.

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

If I edit three.md with !static-docs I expect the /en/stable/ site will gain a page three but will NOT update the index as I didn't touch it in that commit.

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

No that didn't trigger the step:

CleanShot 2023-08-20 at 18 55 51@2x

simonw added a commit that referenced this issue Aug 21, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

That didn't run either. This if condition is failing for some reason:

- name: Handle Commit to Main
if: contains(github.event.head_commit.message, '!stable-docs')
run: |
git fetch origin
git checkout -b stable origin/stable
# Get the list of modified files in docs/ from the current commit
FILES=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} -- docs/)

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

Because I spelt it !static-docs and not !stable-docs!

simonw added a commit that referenced this issue Aug 21, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

That had the expected effect:

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

A new release should replace stable entirely.

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

That worked. https://simonw-readthedocs-experiments.readthedocs.io/en/stable/

I think this is done! Need to write it up as a TIL and maybe put it into production for LLM.

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

No it looks like we DO need that bit I removed in 1f25cfa

CleanShot 2023-08-20 at 20 37 26@2x

simonw added a commit that referenced this issue Aug 21, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

Yeah that works again, the fetch-depth: 0 is necessary. 261aeb9

simonw added a commit to simonw/llm that referenced this issue Aug 21, 2023
simonw referenced this issue in simonw/llm Aug 21, 2023
Also test the new `stable` docs mechanism.
@simonw
Copy link
Owner Author

simonw commented Aug 21, 2023

This is now running in https://github.com/simonw/llm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant