Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ on:
default: false
required: false
type: boolean
upload-artifact:
description: "Upload the built documentation (`docs/build`) as a workflow artifact when the build succeeds"
default: false
required: false
type: boolean
artifact-name:
description: "Name of the documentation artifact"
default: "docs-artifact"
required: false
type: string
artifact-retention-days:
description: "Number of days to keep the documentation artifact uploaded by `upload-artifact` (0 uses the repository default)"
default: 3
required: false
type: number

jobs:
tests:
Expand Down Expand Up @@ -110,6 +125,20 @@ jobs:
DOCUMENTER_KEY: ${{ env.CAN_DEPLOY_DOCS == 'true' && inputs.use-documenter-key && (inputs.documenter-key || secrets.DOCUMENTER_KEY) || '' }}
run: ${{ inputs.debug-documenter && 'JULIA_DEBUG="Documenter"' || '' }} julia --color=yes --project=docs/ ${{ inputs.coverage && '--code-coverage=user' || '' }} docs/make.jl

- name: "Upload Documentation as Artifact"
# Like every step without a status function in its `if:`, this runs only when the
# steps before it succeeded, so a failed build uploads nothing. Pull requests from
# forks cannot deploy a preview (see CAN_DEPLOY_DOCS), so this artifact is the only
# way to inspect their rendered documentation.
uses: actions/upload-artifact@v7
if: "${{ inputs.upload-artifact }}"
with:
name: "${{ inputs.artifact-name }}"
path: "docs/build"
if-no-files-found: error
retention-days: "${{ inputs.artifact-retention-days }}"
compression-level: 9

- name: "Filter coverage directories to those that exist"
# julia-processcoverage hard-errors on directories that don't exist
# (the "src,ext" default includes ext even for packages without
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ documentation (and runs doctests, with coverage).
| `coverage` | boolean | `true` | Collect doctest coverage. |
| `coverage-directories` | string | `"src,ext"` | Coverage dirs. |
| `continue-on-error` | boolean | — | Don't fail the run if the job fails. |
| `upload-artifact` | boolean | `false` | Upload `docs/build` as a workflow artifact when the build succeeds. |
| `artifact-name` | string | `"docs-artifact"` | Name of the documentation artifact. |
| `artifact-retention-days` | number | `3` | Days to keep that artifact (`0` = repository default). |

```yaml
jobs:
Expand All @@ -307,6 +310,27 @@ jobs:
secrets: "inherit"
```

Pull requests from forks can't deploy a documentation preview, so the job
only reports whether the docs build. To let reviewers download and inspect
the rendered docs, set `upload-artifact: true`; the site then appears as
`docs-artifact` under the run's **Artifacts**. The build must produce files in
`docs/build`; the upload fails if that directory has no files. When multiple
documentation jobs run together, give each artifact a distinct name:

```yaml
jobs:
docs:
strategy:
matrix:
julia: ["1", "lts"]
uses: "SciML/.github/.github/workflows/documentation.yml@v1"
secrets: "inherit"
with:
julia-version: ${{ matrix.julia }}
upload-artifact: true
artifact-name: docs-${{ matrix.julia }}
```

### `runic.yml`

Checks formatting with [Runic](https://github.com/fredrikekre/Runic.jl) — the
Expand Down
24 changes: 24 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -693,3 +693,27 @@ end
end
@test count("if: \"\${{ inputs.group-env-value == 'QA' }}\"", txt) == 2
end

@testset "documentation artifact upload contract" begin
txt = read(joinpath(@__DIR__, "..", ".github", "workflows", "documentation.yml"), String)
block(pattern) = (m = match(pattern, txt); isnothing(m) ? "" : m.match)
upload_input = block(r"(?ms)^ upload-artifact:\n.*?(?=^ [\w-]+:|^jobs:)")
name = block(r"(?ms)^ artifact-name:\n.*?(?=^ [\w-]+:|^jobs:)")
upload = block(r"(?ms)^ - name: \"Upload Documentation as Artifact\"\n.*?(?=^ - |\z)")

@test occursin(r"(?m)^ default: false$", upload_input)
@test occursin(r"(?m)^ type: boolean$", upload_input)
@test occursin(r"(?m)^ default: \"docs-artifact\"$", name)
@test occursin(r"(?m)^ type: string$", name)
@test occursin(raw"if: \"${{ inputs.upload-artifact }}\"", upload)
@test occursin(raw"name: \"${{ inputs.artifact-name }}\"", upload)
@test occursin("path: \"docs/build\"", upload)
@test occursin("if-no-files-found: error", upload)
@test !occursin(r"(?m)^\s*overwrite:", upload)
build_at = findfirst(" - name: \"Build and Deploy Documentation\"", txt)
upload_at = findfirst(" - name: \"Upload Documentation as Artifact\"", txt)
@test !isnothing(build_at) && !isnothing(upload_at)
if !isnothing(build_at) && !isnothing(upload_at)
@test first(build_at) < first(upload_at)
end
end
Loading