Skip to content

Commit 67d7430

Browse files
committed
feat: set up nightly docs build in CI
0 parents  commit 67d7430

10 files changed

Lines changed: 626 additions & 0 deletions

File tree

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.md]
10+
trim_trailing_whitespace = false
11+
12+
[*.{sh,yml}]
13+
indent_size = 2
14+
indent_style = space
15+
16+
[.pre-commit-config.yaml]
17+
indent_size = 4
18+
indent_style = space

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: github-actions
5+
directory: /
6+
schedule:
7+
interval: weekly
8+
allow:
9+
- dependency-type: direct

.github/workflows/deploy.yml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: 0 1 * * * # daily
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: pages
13+
cancel-in-progress: true
14+
15+
jobs:
16+
list-docs:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
matrix: ${{ steps.make-matrix.outputs.matrix }}
20+
index_json: ${{ steps.make-matrix.outputs.index_json }}
21+
hash: ${{ steps.check-hash.outputs.hash }}
22+
changed: ${{ steps.check-hash.outputs.changed }}
23+
env:
24+
# This option controls which branches/tags are included in the documentation.
25+
list_docs_options: -d master -m v4.3.1 -e v5.0.0-beta.1 -s
26+
steps:
27+
- name: Checkout the repository
28+
uses: actions/checkout@v6
29+
30+
- name: Build docs index
31+
id: make-matrix
32+
run: |
33+
./scripts/list-docs.sh ${{ env.list_docs_options }} >_index.json
34+
cat _index.json
35+
36+
matrix="$(jq -c '{include: .docs}' _index.json)"
37+
echo "matrix=$matrix" >>"$GITHUB_OUTPUT"
38+
39+
index_json="$(jq -cS . _index.json)"
40+
echo "index_json=$index_json" >>"$GITHUB_OUTPUT"
41+
echo "$index_json" >_index.json
42+
43+
- name: Compute hash and check if updated
44+
id: check-hash
45+
env:
46+
hash: ${{ hashFiles('_index.json', 'scripts/make-docs.sh', 'scripts/update-index.sh', 'docs/_config.yml') }}
47+
run: |
48+
changed=true
49+
git fetch --no-tags origin pages-state:refs/remotes/origin/pages-state 2>/dev/null || :
50+
if git show origin/pages-state:.pages.hash >/dev/null 2>&1; then
51+
old_hash=$(git show origin/pages-state:.pages.hash | tr -d '\r\n')
52+
if [ "$hash" = "$old_hash" ]; then
53+
changed=false
54+
fi
55+
fi
56+
echo "changed=$changed" >>"$GITHUB_OUTPUT"
57+
echo "hash=$hash" >>"$GITHUB_OUTPUT"
58+
59+
build-docs:
60+
name: build-docs (${{ matrix.dir }})
61+
needs: list-docs
62+
runs-on: ubuntu-latest
63+
outputs:
64+
index_json: ${{ needs.list-docs.outputs.index_json }}
65+
hash: ${{ needs.list-docs.outputs.hash }}
66+
changed: ${{ needs.list-docs.outputs.changed }}
67+
strategy:
68+
fail-fast: false
69+
matrix: ${{ fromJSON(needs.list-docs.outputs.matrix) }}
70+
steps:
71+
- name: Checkout the repository
72+
uses: actions/checkout@v6
73+
74+
- name: Cache docs
75+
id: cache-docs
76+
uses: actions/cache@v4
77+
with:
78+
path: docs/${{ matrix.dir }}
79+
key: docs-${{ matrix.dir }}-${{ matrix.ref }}-${{ matrix.dev }}-${{ hashFiles('scripts/make-docs.sh') }}
80+
81+
- name: Install dependencies
82+
if: steps.cache-docs.outputs.cache-hit != 'true' && needs.list-docs.outputs.changed == 'true'
83+
run: |
84+
sudo apt-get update
85+
sudo apt-get install -y --no-install-recommends doxygen-latex graphviz groff latex2html
86+
87+
- name: Build docs
88+
if: steps.cache-docs.outputs.cache-hit != 'true' && needs.list-docs.outputs.changed == 'true'
89+
run: ./scripts/make-docs.sh ${{ matrix.dev && '-d ' || '' }}${{ matrix.ref }} docs/${{ matrix.dir }}
90+
91+
- name: Upload docs artifact
92+
if: needs.list-docs.outputs.changed == 'true'
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: docs-${{ matrix.dir }}
96+
path: |
97+
docs/${{ matrix.dir }}
98+
workaround/for/upload-artifact/issues/174 # See: https://github.com/actions/upload-artifact/issues/174
99+
if-no-files-found: error
100+
101+
collect-docs:
102+
needs: build-docs
103+
if: needs.build-docs.outputs.changed == 'true'
104+
runs-on: ubuntu-latest
105+
outputs:
106+
hash: ${{ needs.build-docs.outputs.hash }}
107+
steps:
108+
- name: Checkout the repository
109+
uses: actions/checkout@v6
110+
111+
- name: Download all docs artifacts
112+
uses: actions/download-artifact@v4
113+
with:
114+
merge-multiple: true
115+
116+
- name: Build docs index page
117+
run: |
118+
echo '${{ needs.build-docs.outputs.index_json }}' >_index.json
119+
./scripts/update-index.sh _index.json docs
120+
cat docs/index.md
121+
122+
- name: Configure GitHub Pages
123+
uses: actions/configure-pages@v5
124+
125+
- name: Build site with Jekyll
126+
uses: actions/jekyll-build-pages@v1
127+
with:
128+
source: docs
129+
destination: _site
130+
131+
- name: Upload Pages artifact
132+
uses: actions/upload-pages-artifact@v3
133+
with:
134+
path: _site
135+
136+
deploy-docs:
137+
needs: collect-docs
138+
runs-on: ubuntu-latest
139+
outputs:
140+
hash: ${{ needs.collect-docs.outputs.hash }}
141+
permissions:
142+
pages: write
143+
id-token: write
144+
environment:
145+
name: github-pages
146+
url: ${{ steps.deployment.outputs.page_url }}
147+
steps:
148+
# Prerequisite: The following repository setting is required:
149+
# Pages -> Build and deployment -> Source: GitHub Actions
150+
- name: Deploy to GitHub Pages
151+
id: deployment
152+
uses: actions/deploy-pages@v4
153+
154+
update-state:
155+
needs: deploy-docs
156+
runs-on: ubuntu-latest
157+
permissions:
158+
contents: write
159+
steps:
160+
- name: Checkout the repository
161+
uses: actions/checkout@v6
162+
163+
- name: Update pages-state hash
164+
run: |
165+
git fetch --no-tags origin pages-state:refs/remotes/origin/pages-state 2>/dev/null || :
166+
if git show-ref --verify --quiet refs/remotes/origin/pages-state; then
167+
git switch -c pages-state --track origin/pages-state 2>/dev/null || git switch pages-state
168+
else
169+
git switch --orphan pages-state
170+
fi
171+
echo '${{ needs.deploy-docs.outputs.hash }}' >.pages.hash
172+
git add .pages.hash
173+
git -c user.name='github-actions[bot]' \
174+
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
175+
commit -m 'chore(pages): update deployed hash' || true
176+
git push origin pages-state

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
schedule:
7+
- cron: 0 0 1 * * # monthly
8+
workflow_dispatch:
9+
10+
jobs:
11+
pre-commit:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout the repository
15+
uses: actions/checkout@v6
16+
17+
- name: Create requirements.txt
18+
run: echo 'pre-commit' >requirements.txt
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version: '3.12'
24+
cache: 'pip'
25+
26+
- name: Run pre-commit
27+
uses: pre-commit/action@v3.0.1

.github/workflows/update.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Update
2+
3+
on:
4+
schedule:
5+
- cron: 0 1 * * 0 # weekly
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: update
10+
cancel-in-progress: true
11+
12+
jobs:
13+
pre-commit-autoupdate:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
steps:
19+
- name: Checkout the repository
20+
uses: actions/checkout@v6
21+
22+
- name: Create requirements.txt
23+
run: echo 'pre-commit' >requirements.txt
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: '3.12'
29+
cache: 'pip'
30+
31+
- name: Install pre-commit
32+
run: pip install -r requirements.txt
33+
34+
- name: Autoupdate hooks
35+
run: |
36+
pre-commit autoupdate
37+
rm -f requirements.txt
38+
39+
# Prerequisite: The following repository setting is required:
40+
# Actions -> General -> Workflow permissions ->
41+
# Allow GitHub Actions to create and approve pull requests
42+
- name: Create pull request
43+
uses: peter-evans/create-pull-request@v8
44+
with:
45+
commit-message: 'chore(pre-commit): autoupdate hooks'
46+
committer: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'
47+
author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'
48+
branch: chore/create-pull-request/pre-commit-autoupdate
49+
delete-branch: true
50+
title: 'chore(pre-commit): autoupdate hooks'
51+
body: |
52+
Automated `pre-commit autoupdate`.

.pre-commit-config.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v6.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-case-conflict
7+
- id: check-executables-have-shebangs
8+
- id: check-illegal-windows-names
9+
- id: check-merge-conflict
10+
- id: check-shebang-scripts-are-executable
11+
- id: check-symlinks
12+
- id: check-yaml
13+
- id: destroyed-symlinks
14+
- id: end-of-file-fixer
15+
- id: fix-byte-order-marker
16+
- id: mixed-line-ending
17+
- id: trailing-whitespace
18+
19+
- repo: https://github.com/scop/pre-commit-shfmt
20+
rev: v3.12.0-2
21+
hooks:
22+
- id: shfmt
23+
24+
- repo: https://github.com/shellcheck-py/shellcheck-py
25+
rev: v0.11.0.1
26+
hooks:
27+
- id: shellcheck
28+
args: [--severity=style]
29+
30+
- repo: https://github.com/rhysd/actionlint
31+
rev: v1.7.10
32+
hooks:
33+
- id: actionlint
34+
35+
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
36+
rev: 3.6.0
37+
hooks:
38+
- id: editorconfig-checker
39+
args: [-disable-indent-size]

docs/_config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: FORM documentation
2+
description: FORM is a Symbolic Manipulation System
3+
4+
titles_from_headings:
5+
enabled: false
6+
7+
plugins:
8+
- jekyll-redirect-from

0 commit comments

Comments
 (0)