Skip to content

Adding mdbook support/CI for PRs #7

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 6 commits into from
Feb 2, 2021
Merged

Conversation

simonsan
Copy link
Contributor

@simonsan simonsan commented Jan 30, 2021

Fixes #6

Output: https://simonsan.github.io/std-dev-guide/

@KodrAus Feedback welcome :)

@simonsan simonsan changed the title Adding mdbook support [WIP] Adding mdbook support Jan 30, 2021
@camelid
Copy link
Member

camelid commented Jan 30, 2021

Is this based on equivalent code for the rustc-dev-guide? Ideally we'd keep the infra code in sync somehow...

@KodrAus
Copy link
Contributor

KodrAus commented Jan 31, 2021

I think the rustc dev guide is using Travis CI for its mdbook support. Was there a reason not to use Actions on that side too?

@camelid
Copy link
Member

camelid commented Jan 31, 2021

Was there a reason not to use Actions on that side too?

Not sure, but I think we're going to try to switch to Actions. And new stuff is being put on Actions: rust-lang/rustc-dev-guide#1037

@JohnTitor
Copy link
Member

JohnTitor commented Jan 31, 2021

IIRC third-party actions shouldn't be used generally for security reasons (I think @pietroalbini has some thoughts about it).

I think the rustc dev guide is using Travis CI for its mdbook support. Was there a reason not to use Actions on that side too?

It's just not updated yet, we have rust-lang/rustc-dev-guide#940 but it isn't done.

@KodrAus
Copy link
Contributor

KodrAus commented Jan 31, 2021

IIRC third-party actions shouldn't be used generally for security reasons

Is this just for third-party actions that we pass secrets into? Or can any third-party action access secrets without us explicitly passing them through? I'd be interested to hear more about that.

@JohnTitor
Copy link
Member

Given rust-lang/crates.io#2951 (comment) I think we should avoid using them regardless of secrets.

@KodrAus
Copy link
Contributor

KodrAus commented Jan 31, 2021

Thanks @JohnTitor, that seems fair to me.

@simonsan Maybe we could look at what it would take to inline the pieces of these actions we actually use? If we want to move the Rustc guide to Actions too at some point it seems like we may as well try get something working with it here too, then look at making things consistent.

@camelid
Copy link
Member

camelid commented Jan 31, 2021

For the "setup mdBook" part I would think you could just copy the commands that are run in Travis from the rustc-dev-guide since they're just shell commands. Not sure about the deploy; you might want to look through the .travis.yml file and the ci/ directory in rust-lang/rustc-dev-guide.

@KodrAus
Copy link
Contributor

KodrAus commented Feb 1, 2021

I imagine the deploy would be the usual dance of creating an empty Git repository, copying the HTML content into it and force pushing that to the gh-pages branch.

@camelid
Copy link
Member

camelid commented Feb 1, 2021

I think the rustc-dev-guide actually just force-pushes to a branch called gh-pages.

I think this is the responsible CI code:

https://github.com/rust-lang/rustc-dev-guide/blob/85c995de1b29f942a85b10dd5175412cc5d32c42/.travis.yml#L27-L34

I don't know Travis though, so I can't explain it :)

@simonsan
Copy link
Contributor Author

simonsan commented Feb 1, 2021

These scripts in ./ci there is a markdown lint action, we use in patterns:

  markdown-lint:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: Lint all files recursively
        uses: avto-dev/markdown-lint@v1
        with:
          config: '.markdownlint.yaml' 
          args: '**/*.md'

Would you also not consider using this and instead use the script? MDL is easy to setup with a yaml file:
https://github.com/rust-unofficial/patterns/blob/master/.markdownlint.yaml

Same for markdown link check:

  markdown-link-check:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - uses: gaurav-nelson/github-action-markdown-link-check@v1
      with:
        use-verbose-mode: 'yes'
        use-quiet-mode: 'yes'
        config-file: '.github/workflows/url-check-config.json'
        check-modified-files-only: 'yes'

These actions shouldn't modify anything and push something to branches and mostly run during a PR, so I'm not sure whether there should be any security concerns about it, while I understand these for mdbook actions and deployment.

@simonsan simonsan changed the title [WIP] Adding mdbook support Adding mdbook support Feb 1, 2021
Copy link
Contributor

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @simonsan! Once we update the variables this looks good to me.

@simonsan
Copy link
Contributor Author

simonsan commented Feb 1, 2021

@KodrAus Should I remove the .travis.yml?

@simonsan simonsan changed the title Adding mdbook support Adding mdbook support/CI for PRs Feb 1, 2021
@simonsan
Copy link
Contributor Author

simonsan commented Feb 1, 2021

@KodrAus I've added mdbook build/test to test the building process of the book and the code samples during PR. Do you think that makes sense? I have prepared fixes for the files already so mdbook test runs through successfully that I can PR as well.

@simonsan
Copy link
Contributor Author

simonsan commented Feb 1, 2021

Blocking:
#10 - One link is broken and one link is missing
#11 - Makes code sample tests pass for now

@KodrAus
Copy link
Contributor

KodrAus commented Feb 2, 2021

Thanks @simonsan! I merged in your fixes.

Removing the .travis.yml sounds good to me too 🙂 Save Travis a little compute.

remove empty lines in book.toml
@simonsan
Copy link
Contributor Author

simonsan commented Feb 2, 2021

Removing the .travis.yml sounds good to me too 🙂 Save Travis a little compute.

Done :)

@KodrAus
Copy link
Contributor

KodrAus commented Feb 2, 2021

Thanks so much for working on this @simonsan! 🙇

@KodrAus KodrAus merged commit c40be4b into rust-lang:master Feb 2, 2021
github-actions bot pushed a commit that referenced this pull request Feb 2, 2021
@simonsan simonsan deleted the mdbook branch February 3, 2021 07:50
@simonsan
Copy link
Contributor Author

simonsan commented Feb 3, 2021

@KodrAus Seems there is still an issue with that CNAME. Anything to fix from my side?

@KodrAus
Copy link
Contributor

KodrAus commented Feb 4, 2021

@simonsan It's all good, we've got #12 opened to track getting that sorted. Thanks again for working on this!

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.

Make the book accessible through GitHub Pages
4 participants