From 1c5408b27e2407bb3e95379cc8ed658a5fc9d306 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Thu, 5 Dec 2024 14:52:18 +0000 Subject: [PATCH] Use new GitHub actions (#110) * Use new GitHub actions * Tidy names * Add Format action * Format * Add JuliaFormatter config --- .JuliaFormatter.toml | 2 ++ .github/workflows/Docs.yml | 16 +++--------- .github/workflows/DocsNav.yml | 49 ----------------------------------- .github/workflows/Format.yml | 25 ++++-------------- docs/make.jl | 17 +++++------- 5 files changed, 16 insertions(+), 93 deletions(-) create mode 100644 .JuliaFormatter.toml delete mode 100644 .github/workflows/DocsNav.yml diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..cb40e92 --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1,2 @@ +style = "blue" +format_markdown = true diff --git a/.github/workflows/Docs.yml b/.github/workflows/Docs.yml index 73ee754..e012053 100644 --- a/.github/workflows/Docs.yml +++ b/.github/workflows/Docs.yml @@ -18,21 +18,11 @@ concurrency: permissions: contents: write pull-requests: read - statuses: write jobs: docs: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: '1' - - name: Install dependencies - run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - - name: Build and deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token - DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key - JULIA_DEBUG: Documenter # Print `@debug` statements (https://github.com/JuliaDocs/Documenter.jl/issues/955) - run: julia --project=docs/ docs/make.jl + - name: Build and deploy Documenter.jl docs + uses: TuringLang/DocsNav/DocsDocumenter@v2 diff --git a/.github/workflows/DocsNav.yml b/.github/workflows/DocsNav.yml deleted file mode 100644 index 14614d1..0000000 --- a/.github/workflows/DocsNav.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Add Navbar - -on: - page_build: # Triggers the workflow on push events to gh-pages branch - workflow_dispatch: # Allows manual triggering - schedule: - - cron: '0 0 * * 0' # Runs every week on Sunday at midnight (UTC) - -jobs: - add-navbar: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout gh-pages - uses: actions/checkout@v4 - with: - ref: gh-pages - fetch-depth: 0 - - - name: Download insert_navbar.sh - run: | - curl -O https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/insert_navbar.sh - chmod +x insert_navbar.sh - - - name: Update Navbar - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - - # Define the URL of the navbar to be used - NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/TuringNavbar.html" - - # Update all HTML files in the current directory (gh-pages root) - ./insert_navbar.sh . $NAVBAR_URL - - # Remove the insert_navbar.sh file - rm insert_navbar.sh - - # Check if there are any changes - if [[ -n $(git status -s) ]]; then - git add . - git commit -m "Added navbar and removed insert_navbar.sh" - git push "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages - else - echo "No changes to commit" - fi diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml index 9d8e17d..efd4d41 100644 --- a/.github/workflows/Format.yml +++ b/.github/workflows/Format.yml @@ -3,11 +3,9 @@ name: Format on: push: branches: - # This is where pull requests from "bors r+" are built. - - staging - # This is where pull requests from "bors try" are built. - - trying - # Build the main branch. + - main + pull_request: + branches: - main concurrency: @@ -19,20 +17,7 @@ concurrency: jobs: format: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@latest - with: - version: 1 - name: Format code - run: | - using Pkg - Pkg.add(; name="JuliaFormatter", uuid="98e50ef6-434e-11e9-1051-2b60c6c9e899") - using JuliaFormatter - format("."; verbose=true) - shell: julia --color=yes {0} - - uses: reviewdog/action-suggester@v1 - if: github.event_name == 'pull_request' - with: - tool_name: JuliaFormatter - fail_on_error: true + uses: TuringLang/actions/Format@v2 diff --git a/docs/make.jl b/docs/make.jl index 404169e..cf031b4 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,17 +2,12 @@ using Documenter using AbstractPPL # Doctest setup -DocMeta.setdocmeta!(AbstractPPL, :DocTestSetup, :(using AbstractPPL); recursive=true) +DocMeta.setdocmeta!(AbstractPPL, :DocTestSetup, :(using AbstractPPL); recursive = true) makedocs(; - sitename="AbstractPPL", - modules=[AbstractPPL], - pages=[ - "Home" => "index.md", - "API" => "api.md", - ], - checkdocs=:exports, - doctest=false, + sitename = "AbstractPPL", + modules = [AbstractPPL], + pages = ["Home" => "index.md", "API" => "api.md"], + checkdocs = :exports, + doctest = false, ) - -deploydocs(; repo="github.com/TuringLang/AbstractPPL.jl.git", push_preview=true)