Skip to content

Commit

Permalink
Use nox for doc generation in CI
Browse files Browse the repository at this point in the history
Internal-tag: [#58500]
Signed-off-by: gkierzkowski <[email protected]>
  • Loading branch information
gkierzkowski-ant committed Jul 25, 2024
1 parent b68496c commit 9744e97
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 52 deletions.
10 changes: 2 additions & 8 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,9 @@ package_cores:
build_docs:
image: $CI_DOCS_DOCKER_IMAGE
stage: build_docs
before_script:
- pip3 install -r docs/requirements.txt
- pip3 install .
script:
- cd docs
- echo -en "\nhtml_js_files = [ '$ANNOTANT' ]" >> source/conf.py
- make html latexpdf
- cp build/latex/*.pdf build/html/
- tar cf ../$CI_DOCS_ARCHIVE -C build/html/ .
- ./.github/scripts/ci.sh docs
- tar cf "$CI_DOCS_ARCHIVE" -C docs/build/html/ .
artifacts:
paths:
- docs/build
Expand Down
22 changes: 21 additions & 1 deletion .github/scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ generate_examples() {
done
}


generate_docs() {
install_common_system_packages
begin_command_group "Install system packages for doc generation"
log_cmd apt-get install -y texlive-full make
end_command_group
enter_venv

begin_command_group "Install python packages for doc generation"
log_cmd pip install nox
end_command_group

begin_command_group "Generating documentation"
log_cmd nox -s doc_gen
end_command_group
}

package_cores() {
install_common_system_packages
begin_command_group "Install system packages for packaging cores"
Expand Down Expand Up @@ -172,7 +189,10 @@ examples)
package_cores)
package_cores
;;
docs)
generate_docs
;;
*)
echo "Usage: $0 {lint|tests|examples|package_cores}"
echo "Usage: $0 {lint|tests|examples|package_cores|docs}"
;;
esac
75 changes: 32 additions & 43 deletions .github/workflows/ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,41 @@

name: GH Pages

on:
pull_request:
push:
branches:
- main
on: [pull_request, push]

jobs:
docs-generation:
runs-on: ubuntu-latest
container:
image: debian:bookworm

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y texlive-full
python3 -m pip install -r docs/requirements.txt
pip install .
- name: Generate documentation
run: |
cd docs
make html latexpdf
cp build/latex/*.pdf build/html/
- uses: actions/upload-artifact@v3
with:
name: gh-page
path: docs/build/html

- name: Deploy to Github Pages
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
run: |
cd docs/build/html
touch .nojekyll
git init
cp ../../../.git/config ./.git/config
git add .
git config --local user.email "push@gha"
git config --local user.name "GHA"
git commit -am "update ${{ github.sha }}"
git push -u origin +HEAD:gh-pages
rm -rf .git
- name: Install git package
run: |
apt-get update -qq
apt-get install -y git
- uses: actions/checkout@v4

- name: Generate documentation
run: |
./.github/scripts/ci.sh docs
- uses: actions/upload-artifact@v3
with:
name: gh-page
path: docs/build/html

- name: Deploy to Github Pages
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
run: |
cd docs/build/html
touch .nojekyll
git init
cp ../../../.git/config ./.git/config
git add .
git config --local user.email "push@gha"
git config --local user.name "GHA"
git commit -am "update ${{ github.sha }}"
git push -u origin +HEAD:gh-pages
rm -rf .git

0 comments on commit 9744e97

Please sign in to comment.