Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend doc-build to be windows compatible #453

Merged
merged 64 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
f7b3ca2
WIP: Add windows doc build
SMoraisAnsys Mar 18, 2024
70ac1f1
WIP: Add windows doc build job
SMoraisAnsys Mar 18, 2024
d33e76e
WIP: remove workflow
SMoraisAnsys Mar 18, 2024
2c2f469
Revert "WIP: Add windows doc build job"
SMoraisAnsys Mar 18, 2024
22f604b
WIP: Remove commit-style job
SMoraisAnsys Mar 18, 2024
ba14218
WIP: remove failing depends
SMoraisAnsys Mar 18, 2024
c8f2dee
WIP: Add windows doc build job
SMoraisAnsys Mar 18, 2024
781a047
Revert "WIP: remove workflow"
SMoraisAnsys Mar 18, 2024
0e2d561
WIP: Remove multiple jobs
SMoraisAnsys Mar 18, 2024
9f2718c
WIP: use correct action
SMoraisAnsys Mar 18, 2024
53c7c54
WIP: Fix forgotten shell
SMoraisAnsys Mar 18, 2024
c55791a
WIP: Use pwsh when needed
SMoraisAnsys Mar 18, 2024
e70dfa1
FIX: Miss click
SMoraisAnsys Mar 18, 2024
20ae81d
WIP: Update PATH with Miktek bins
SMoraisAnsys Mar 18, 2024
565cdc2
WIP: Fix backslash with quote
SMoraisAnsys Mar 18, 2024
9620f3d
WIP: Test fix build
SMoraisAnsys Mar 18, 2024
57964b5
WIP: Test fix build
SMoraisAnsys Mar 18, 2024
076fa09
FEAT: Add doc build on different os
SMoraisAnsys Mar 18, 2024
55f7673
REFACT: Warning message
SMoraisAnsys Mar 19, 2024
2c09b2c
MISC: Revert to old ci_cd workflow
SMoraisAnsys Mar 19, 2024
0502911
MISC: Add blank line
SMoraisAnsys Mar 19, 2024
051e67b
Merge branch 'main' into feat/doc-build-os-compatible
SMoraisAnsys Mar 19, 2024
a447316
WIP: Fix if conditions
SMoraisAnsys Mar 19, 2024
046004e
WIP: Fix if conditions
SMoraisAnsys Mar 19, 2024
37b489c
WIP: Fix if conditions
SMoraisAnsys Mar 19, 2024
579caec
WIP: Another try to fix if conditions
SMoraisAnsys Mar 19, 2024
6f52019
WIP
SMoraisAnsys Mar 20, 2024
3719970
WIP
SMoraisAnsys Mar 20, 2024
cd1b7c6
WIP
SMoraisAnsys Mar 20, 2024
e459dbb
Apply suggestions from code review
SMoraisAnsys Mar 27, 2024
77e388a
WIP: Change log commands
SMoraisAnsys Mar 28, 2024
92dd179
WIP: use powershell as shell
SMoraisAnsys Mar 28, 2024
cf08a56
WIP: Force choco install
SMoraisAnsys Mar 28, 2024
f21eb63
WIP: Update PATH
SMoraisAnsys Mar 28, 2024
2f827f2
WIP: Refact
SMoraisAnsys Mar 28, 2024
f94aa98
WIP: Test asci coloration in windows
SMoraisAnsys Mar 28, 2024
666a6b4
WIP: Reorder calls
SMoraisAnsys Mar 28, 2024
c53b75c
WIP: Fix windows format errors
SMoraisAnsys Mar 28, 2024
8d9767e
WIP: Fix github action path?
SMoraisAnsys Mar 28, 2024
b5caf75
WIP: Split Miktex config in steps
SMoraisAnsys Mar 28, 2024
36582b2
WIP
SMoraisAnsys Mar 28, 2024
aca7aa5
WIP
SMoraisAnsys Mar 28, 2024
4f141f9
WIP
SMoraisAnsys Mar 28, 2024
7ec154b
WIP
SMoraisAnsys Mar 28, 2024
717926c
WIP: Fix env var setting
SMoraisAnsys Mar 28, 2024
71eb41d
WIP
SMoraisAnsys Mar 28, 2024
3180c7a
WIP: Try removing updates due to timeout
SMoraisAnsys Mar 28, 2024
003ac77
WIP: Clean up
SMoraisAnsys Apr 8, 2024
dc7bad7
WIP: Fix shell between linux and windows
SMoraisAnsys Apr 8, 2024
66f9540
WIP: test using pwsh
SMoraisAnsys Apr 8, 2024
7c89311
Revert "WIP: test using pwsh"
SMoraisAnsys Apr 8, 2024
7c6546c
WIP: Use logging private action
SMoraisAnsys Apr 8, 2024
d0fa06a
REFACT: Remove os input to leverage runner.os
SMoraisAnsys Apr 8, 2024
4719289
Merge branch 'main' into feat/doc-build-os-compatible
SMoraisAnsys Apr 8, 2024
2d2f79b
FIX: wrong log
SMoraisAnsys Apr 8, 2024
17b191b
FIX: wrong log
SMoraisAnsys Apr 8, 2024
41b2251
FIX: wrong log
SMoraisAnsys Apr 8, 2024
2e81a28
Update doc-build/action.yml
SMoraisAnsys Apr 10, 2024
34341c7
Update doc-build/action.yml
SMoraisAnsys Apr 10, 2024
e7e0add
Update doc-build/action.yml
SMoraisAnsys Apr 10, 2024
3881f21
Update _doc-build-linux/action.yml
SMoraisAnsys Apr 11, 2024
4f3020f
Update doc-build/action.yml
SMoraisAnsys Apr 11, 2024
c890807
DOC: Update sphinx-build as dependency
SMoraisAnsys Apr 11, 2024
c6d56f2
Merge branch 'main' into feat/doc-build-os-compatible
RobPasMue Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
257 changes: 257 additions & 0 deletions _doc-build-linux/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
# Copyright (C) 2022 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: >
Documentation build action
description: |
Build library documentation using `Sphinx
<https://www.sphinx-doc.org/en/master/>`_. The action installs documentation
dependencies provided either in a requirement file, e.g.
``requirements/requirements_doc.txt``, or in the ``[doc]`` section of the
additional dependencies in the ``pyproject.toml`` file. Assuming that
`sphinx-build
<https://www.sphinx-doc.org/en/master/man/sphinx-build.html>`_ is available
after installing the documentation dependencies, the action uses it
to generate documentation from the source. It requires that all the
documentation is contained in the ``doc/`` directory of a project. The
action locates the ``doc/Makefile`` and runs the ``make html`` and
``make pdf`` commands. If desired, the ``make json`` command can
also be executed to generate JSON documentation.
inputs:

# Required inputs

python-version:
description: >
Python version used for installing and running ``Sphinx``.
required: true
type: string

use-python-cache:
description: >
Whether to use the Python cache for installing previously downloaded
libraries. If ``true``, previously downloaded libraries are installed from the
Python cache. If ``false``, libraries are downloaded from the PyPI index.
required: true
type: boolean

sphinxopts:
description: |
Set of options to pass to the ``Sphinx`` builder.
.. note::
This will override the ``SPHINXOPTS`` declared in your Makefile.
required: true
type: string

dependencies:
description: >
String of system dependencies to be installed before building the
documentation of the project.
required: true
type: string

skip-dependencies-cache:
description: >
Whether to ignore dependencies cache or not - for OS libraries.
required: true
type: boolean

requires-xvfb:
description: |
Whether to install `X Virtual Frame Buffer (XVFB)
<https://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml>`_ and run
the whole test session using XVFB.
required: true
type: boolean

skip-install:
description: >
Whether to skip the installation of the project.
Pure documentation projects require that this action be set to ``false``
because there is no Python library associated with the project.
required: true
type: boolean

requirements-file:
description: >
Path to the requirements file in case it needs to be in a specific location.
This is useful for non python projects, where you don't necessarily have a requirements
file in the root of the project.
required: true
type: string

checkout:
description: >
Whether to clone the repository in the CI/CD machine.
required: true
type: boolean

skip-json-build:
description: >
Whether to skip the generation of JSON documentation.
required: true
type: boolean

check-links:
description: >
Whether to perform external link checks during the generation of
documentation.
required: true
type: boolean

runs:
using: "composite"
steps:

- name: "Collect system dependencies"
shell: bash
run: |
if [[ ${{ inputs.requires-xvfb }} == 'true' ]]; then
echo "NEEDED_DEPS=$(echo '${{ inputs.dependencies }} xvfb')" >> $GITHUB_ENV
else
echo "NEEDED_DEPS=$(echo '${{ inputs.dependencies }}')" >> $GITHUB_ENV
fi
- name: "Cache apt packages needed"
uses: awalsh128/cache-apt-pkgs-action@v1.3.1
if: inputs.skip-dependencies-cache == 'false' && env.NEEDED_DEPS != ''
with:
packages: ${{ env.NEEDED_DEPS }}
version: 1.0

- name: "Update apt-get"
shell: bash
run: |
sudo apt-get update
- name: "Install system dependencies"
shell: bash
run: |
sudo apt-get install -y ${{ env.NEEDED_DEPS }}
- name: "Install LaTeX"
shell: bash
run: |
sudo apt-get install -y texlive-latex-extra latexmk
- name: "Check if requirements.txt file exists"
shell: bash
run: |
echo "EXISTS_DOC_REQUIREMENTS=$(if [ -f ${{ inputs.requirements-file }} ]; then echo 'true'; else echo 'false'; fi)" >> $GITHUB_ENV
- name: "Print previous output"
shell: bash
run: |
echo "Output was found ${{ env.EXISTS_DOC_REQUIREMENTS }}"
- name: "Update pip"
shell: bash
run: python -m pip install -U pip

- name: "Install documentation dependencies from requirements file"
shell: bash
if: env.EXISTS_DOC_REQUIREMENTS == 'true'
run: |
python -m pip install -r ${{ inputs.requirements-file }}
- name: "Install Python library"
shell: bash
if: inputs.skip-install == 'false'
run: |
python -m pip install .
- name: "Install documentation dependencies from pyproject.toml"
shell: bash
if: env.EXISTS_DOC_REQUIREMENTS == 'false'
run: |
if grep -q 'build-backend = "poetry\.core\.masonry\.api"' "pyproject.toml"; then
python -m pip install poetry
poetry install --with doc
else
python -m pip install .[doc]
fi
- name: "Determine make command context"
shell: bash
run: |
if grep -q 'build-backend = "poetry\.core\.masonry\.api"' "pyproject.toml"; then
echo "SPHINX_BUILD_MAKE=$(echo 'poetry run -- make')" >> $GITHUB_ENV
else
echo "SPHINX_BUILD_MAKE=$(echo 'make')" >> $GITHUB_ENV
fi
- name: "Build HTML, PDF, and JSON documentation"
if: inputs.requires-xvfb == 'false'
shell: bash
run: |
if [[ ${{ inputs.check-links }} == 'true' ]];
then
${{ env.SPHINX_BUILD_MAKE }} -C doc linkcheck SPHINXOPTS="${{ inputs.sphinxopts }}"
fi
${{ env.SPHINX_BUILD_MAKE }} -C doc html SPHINXOPTS="${{ inputs.sphinxopts }}"
${{ env.SPHINX_BUILD_MAKE }} -C doc pdf
if [[ ${{ inputs.skip-json-build }} == 'false' ]];
then
${{ env.SPHINX_BUILD_MAKE }} -C doc json SPHINXOPTS="${{ inputs.sphinxopts }}"
fi
- name: "Build HTML, PDF, and JSON documentation using xvfb"
if: inputs.requires-xvfb == 'true'
shell: bash
run: |
if [[ ${{ inputs.check-links }} == 'true' ]];
then
xvfb-run ${{ env.SPHINX_BUILD_MAKE }} -C doc linkcheck SPHINXOPTS="${{ inputs.sphinxopts }}"
fi
xvfb-run ${{ env.SPHINX_BUILD_MAKE }} -C doc html SPHINXOPTS="${{ inputs.sphinxopts }}"
xvfb-run ${{ env.SPHINX_BUILD_MAKE }} -C doc pdf
if [[ ${{ inputs.skip-json-build }} == 'false' ]];
then
xvfb-run ${{ env.SPHINX_BUILD_MAKE }} -C doc json SPHINXOPTS="${{ inputs.sphinxopts }}"
fi
- name: "Upload HTML documentation artifact"
uses: actions/upload-artifact@v4
with:
name: documentation-html
path: doc/_build/html
retention-days: 7

- name: "Upload PDF documentation artifact"
uses: actions/upload-artifact@v4
with:
name: documentation-pdf
path: doc/_build/latex/*.pdf
retention-days: 7

- name: "Upload JSON documentation artifact"
uses: actions/upload-artifact@v4
if: inputs.skip-json-build == 'false'
with:
name: documentation-json
path: doc/_build/json
retention-days: 7