Skip to content

Commit d61f5f1

Browse files
committed
Add LiterateCheck
1 parent 99acd73 commit d61f5f1

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Reusable Readme Generation Workflow"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
julia-version:
7+
description: "Julia version"
8+
default: "1"
9+
required: false
10+
type: string
11+
outputs:
12+
up_to_date:
13+
description: "If the README.md is up-to-date or not."
14+
value: "${{ jobs.literate.outputs.up_to_date }}"
15+
literate-diff-patch:
16+
description: "A patch consisting of changes which can be applied to comply with literate check. Available only if `outputs.up_to_date` is `false`"
17+
value: "${{ jobs.literate.outputs.literate_changes }}"
18+
19+
concurrency:
20+
group: "${{ github.run_id || github.ref }}:${{ github.workflow }}"
21+
cancel-in-progress: true
22+
23+
jobs:
24+
literate:
25+
name: "Literate Check"
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: julia-actions/setup-julia@v2
30+
with:
31+
version: "${{ inputs.julia-version }}"
32+
- name: Install Literate and generate docs
33+
shell: julia --color=yes {0}
34+
run: |
35+
using Pkg
36+
Pkg.add(PackageSpec(name="Literate"))
37+
using Literate
38+
Literate.markdown("examples/README.jl", "docs/src"; flavor=Literate.DocumenterFlavor(), name="index")
39+
- name: Check if docs need to be updated
40+
id: check-literate
41+
run: |
42+
MODIFIED_FILES="$(git diff --name-only)"
43+
44+
if [ -z "$MODIFIED_FILES" ]; then
45+
echo "up_to_date=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "The documentation is outdated, rerun Literate to regenerate them."
48+
echo "$MODIFIED_FILES"
49+
50+
{
51+
echo "literate_changes<<EOF"
52+
echo "$(git diff)"
53+
echo EOF
54+
} >> $GITHUB_OUTPUT
55+
56+
exit 1
57+
fi

0 commit comments

Comments
 (0)