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

Replacing bash script with Julia script for inserting navbar #11

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

shravanngoswamii
Copy link
Member

Closes #9 #10

Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

This is great - very lightweight code and well structured!

I have a few comments just to polish the edges really.

DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsNav/scripts/insert_navbar.jl Outdated Show resolved Hide resolved
DocsDocumenter/action.yml Outdated Show resolved Hide resolved
@shravanngoswamii
Copy link
Member Author

@penelopeysm Thanks, I have updated the script with your suggested changes, let me know if we should add anything else!

One more thing, can we just schedule only DocsNav part of DocsDocumenter workflow on weekly basis so if our navbar script or navbar itself changes then we won't have to manually trigger workflows in all repos + we should also add worklow dispatch event in all repos so we can also trigger it manually if required...!

Most of our repos still use DocsNav.yml workflow from TuringLang/turinglang.github.io, I guess we are ready to use this everywhere...

@penelopeysm
Copy link
Member

can we just schedule only DocsNav part of DocsDocumenter workflow

Hmmm, that's an interesting one. I do see the utility there.
I guess the strategy would be to clone the gh-pages branch and then edit every HTML file inside it?

Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

super happy with everything else :)

@shravanngoswamii
Copy link
Member Author

I don't think we can schedule composite actions, let's just add a schedule in all workflow to run docs:

  schedule:
    - cron: '0 0 * * 0'  # Runs every week on Sunday at midnight (UTC)

@shravanngoswamii
Copy link
Member Author

Let's merge this first so we can fix all broken docs!

@shravanngoswamii shravanngoswamii merged commit 576c71d into main Feb 6, 2025
@shravanngoswamii shravanngoswamii deleted the sg/new-navbar-script branch February 6, 2025 11:04
@penelopeysm
Copy link
Member

penelopeysm commented Feb 6, 2025

I'm thinking about how Documenter.jl attempts to be very smart about what docs it deploys. This isn't to do with our workflows, it's baked into Documenter.jl itself. For example

https://turinglang.org/DynamicPPL.jl/stable/ - this subdir is only updated when Documenter is run on a new tag

https://turinglang.org/DynamicPPL.jl/dev/ - this subdir is updated when Documenter is run on the main branch

https://turinglang.org/DynamicPPL.jl/v0.34/ - this subdir is updated when Documenter is run on 0.34

But if we update the navbar, we presumably want to edit all the subdirs at once. I think the only way to do that is something like this

name: Update navbar

on:
  schedule:
    - cron: '0 0 * * 0'
  workflow_dispatch:

jobs:
  update-navbar:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: gh-pages

      [... install julia...]

      - name: Replace navbar
        uses: TuringLang/actions/DocsNav@v(whatever)
        with:
          doc-path: '.'

What do you think?

(Also, yes, it's definitely time to update all the workflows in the organisation repos. That'll be great fun 😅 )

@shravanngoswamii
Copy link
Member Author

shravanngoswamii commented Feb 6, 2025

Should I tag it with v3? As it's a major change, Bash to Julia!

@penelopeysm
Copy link
Member

I think we can be liberal with version numbers so yes :)

@shravanngoswamii
Copy link
Member Author

shravanngoswamii commented Feb 6, 2025

What do you think?

How about something like this:

name: "Documentation"

on:
  push:
    branches:
      - main
    tags: '*'
  pull_request:
    branches:
      - main
  schedule:
    - cron: '0 0 * * 0'
  workflow_dispatch:

permissions:
  contents: write

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
  docs:
    runs-on: ubuntu-latest
    if: github.event_name != 'schedule'

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Build and deploy Documenter.jl docs
        uses: TuringLang/actions/DocsDocumenter@(whatever)

  update-navbar:
    runs-on: ubuntu-latest
    if: github.event_name == 'schedule'

    steps:
      - name: Checkout gh-pages branch
        uses: actions/checkout@v4
        with:
          ref: gh-pages

      - name: Insert navbar
        uses: TuringLang/actions/DocsNav@(whatever)
        with:
          julia: true (conditional installation😅)
          doc-path: '.'
          navbar-url: ${{ github.action_path }}/DocsNav/scripts/TuringNavbar.html

      - name: Commit and push changes
        run: |
          if [[ -n $(git status -s) ]]; then
            git add .
            git commit -m "Update navbar (automated)"
            git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages
          else
            echo "No changes to commit"
          fi

@penelopeysm
Copy link
Member

I think I have a slight preference for having two separate workflows, but yeah, that general structure should work!
I think its fine for DocsNav to require someone to do julia-actions/install-julia before it, many github actions don't auto install system dependencies :)

@penelopeysm
Copy link
Member

penelopeysm commented Feb 6, 2025

Where would you like to go from here? Should we maybe update the workflows on DynamicPPL to start? Then once we're happy with it + confident that it works we can copy paste to the other repos?

@shravanngoswamii
Copy link
Member Author

Where would you like to go from here?

I am fine with both approaches, but having only one workflow will require less future efforts in case of any change.

Should we maybe update the workflows on DynamicPPL to start? Then once we're happy with it + confident that it works we can copy paste to the other repos?

DynamicPPLs docs are broken so let's start with it, I guess you have owner access for DynamicPPL so can you test it out there, then I will start opening PRs for all other repos!

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 Navbar Insertion More Robust
2 participants