From d8cdd820e6e55836d13086da489887f06fdd897f Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Fri, 19 Apr 2024 13:54:25 +0200 Subject: [PATCH 01/22] feat: add upload assets to doc-build --- _doc-build-linux/action.yml | 110 +++++++++++++++++++++++++++++ _doc-build-windows/action.yml | 126 ++++++++++++++++++++++++++++++++++ doc-build/action.yml | 20 ++++++ 3 files changed, 256 insertions(+) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 2e4f30146..311eac094 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -123,6 +123,23 @@ inputs: required: true type: boolean + add-pdf-html-docs-as-assets: + description: | + Whether to add PDF and HTML documentation as assets of the HTML + documentation. The HTML documentation is compressed before being added. + The PDF file name is expected to be the same as the project name defined + in the pyproject.toml file. Default value is ``false``. + + .. warning:: + + The HTML files are expected to be contained in ``doc/_build`` and the + PDF file is copied in ``doc/_build/html/_static/assets/download``. + If such directories do not exist in your repo, the action will fail. + + required: true + type: boolean + + runs: using: "composite" steps: @@ -234,6 +251,99 @@ runs: xvfb-run ${{ env.SPHINX_BUILD_MAKE }} -C doc json SPHINXOPTS="${{ inputs.sphinxopts }}" fi + # ------------------------------------------------------------------------ + + - uses: ansys/actions/_logging@main + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + with: + level: "INFO" + message: > + Set environment variable PACKAGE_PDF_FILENAME. + +# - name: Determine pdf filename +# if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} +# shell: bash +# run: | +# python -m pip install toml +# PDF_FILENAME=$(python -c " +# import toml;\ +# pyproject = toml.load('pyproject.toml');\ +# name = pyproject.get('tool', {}).get('poetry', {}).get('name')\ +# or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name');\ +# pdf_name = name + '.pdf';\ +# print(pdf_name)") +# echo "PDF_FILENAME=${PDF_FILENAME}" >> $GITHUB_ENV + + - name: Install toml + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: bash + run: | + python -m pip install toml + + - name: Determine PDF filename + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: python + run: | + import os + import toml + + pyproject = toml.load('pyproject.toml') + name = pyproject.get('tool', {}).get('poetry', {}).get('name') \ + or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name') + pdf_name = name + '.pdf' + + # Get the GITHUB_ENV variable + github_env = os.getenv('GITHUB_ENV') + + # Append the PDF_FILENAME with its value to GITHUB_ENV + with open(github_env, "a") as f: + f.write(f"PDF_FILENAME={pdf_name}") + + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME == '') }} + with: + level: "ERROR" + message: > + Unable to determine PDF filename using pyproject.toml data. + + # ------------------------------------------------------------------------ + - uses: ansys/actions/_logging@main + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + with: + level: "INFO" + message: > + Check if expected directories exist. + + - name: Check expected build directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: bash + run: | + echo "EXPECTED_BUILD_DIR='doc\_build'" >> $GITHUB_ENV + echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d '${{ env.EXPECTED_BUILD_DIR }}' ] && echo "true" || echo "false" ) >> $GITHUB_ENV + + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_BUILD_DIR == 'false') }} + with: + level: "ERROR" + message: > + Expected build directory ${{ env.EXPECTED_BUILD_DIR }} does not exist. + + - name: Check expected download directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: bash + run: | + echo "EXPECTED_DOWNLOAD_DIR=$(echo '${{ env.EXPECTED_BUILD_DIR }}\html\_static\assets\download')" >> $GITHUB_ENV + echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$( [ -d '${{ env.EXPECTED_DOWNLOAD_DIR }}' ] && echo "true" || echo "false" ) >> $GITHUB_ENV + + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} + with: + level: "ERROR" + message: > + Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. + + # ------------------------------------------------------------------------ + - name: "Upload HTML documentation artifact" uses: actions/upload-artifact@v4 with: diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index 14212ac17..24b161af6 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -115,6 +115,23 @@ inputs: required: true type: boolean + add-pdf-html-docs-as-assets: + description: | + Whether to add PDF and HTML documentation as assets of the HTML + documentation. The HTML documentation is compressed before being added. + The PDF file name is expected to be the same as the project name defined + in the pyproject.toml file. Default value is ``false``. + + .. warning:: + + The HTML files are expected to be contained in ``doc\_build`` and the + PDF file is copied in ``doc\_build\html\_static\assets\download``. + If such directories do not exist in your repo, the action will fail. + + required: true + type: boolean + + runs: using: "composite" steps: @@ -258,6 +275,115 @@ runs: # ------------------------------------------------------------------------ + - uses: ansys/actions/_logging@main + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + with: + level: "INFO" + message: > + Set environment variable PACKAGE_PDF_FILENAME. + + # - name: Determine pdf filename + # if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + # shell: powershell + # run: | + # python -m pip install toml + # $PDF_FILENAME=$(python -c "" + # import toml;\ + # pyproject = toml.load('pyproject.toml');\ + # name = pyproject.get('tool', {}).get('poetry', {}).get('name')\ + # or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name');\ + # pdf_name = name + '.pdf';\ + # print(pdf_name)") + # echo "PDF_FILENAME=${PDF_FILENAME} | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Install toml + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: powershell + run: | + python -m pip install toml + + - name: Determine PDF filename + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: python + run: | + import os + import toml + + pyproject = toml.load('pyproject.toml') + name = pyproject.get('tool', {}).get('poetry', {}).get('name') \ + or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name') + pdf_name = name + '.pdf' + + # Get the GITHUB_ENV variable + github_env = os.getenv('GITHUB_ENV') + + # Append the PDF_FILENAME with its value to GITHUB_ENV + with open(github_env, "a") as f: + f.write(f"PDF_FILENAME={pdf_name}") + + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME == '') }} + with: + level: "ERROR" + message: > + Unable to determine PDF filename using pyproject.toml data. + + # ------------------------------------------------------------------------ + + - uses: ansys/actions/_logging@main + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + with: + level: "INFO" + message: > + Check if expected directories exist. + + - name: Check expected build directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: powershell + run: | + echo "EXPECTED_BUILD_DIR='doc\_build'" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 + echo "EXISTS_EXPECTED_BUILD_DIR=$(if (Test-Path '${{ env.EXPECTED_BUILD_DIR }}') { echo 'true' } else { echo 'false' })" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 + + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_BUILD_DIR == 'false') }} + with: + level: "ERROR" + message: > + Expected build directory ${{ env.EXPECTED_BUILD_DIR }} does not exist. + + - name: Check expected download directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: powershell + run: | + echo "EXPECTED_DOWNLOAD_DIR='${{ env.EXPECTED_BUILD_DIR }}\html\_static\assets\download'" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 + echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$(if (Test-Path '${{ env.EXPECTED_DOWNLOAD_DIR }}') { echo 'true' } else { echo 'false' })" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 + + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} + with: + level: "ERROR" + message: > + Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. + + # ------------------------------------------------------------------------ + + - name: Check build directory + uses: ansys/actions/_logging@main + if: inputs.add-pdf-html-docs-as-assets == 'true' + with: + level: "INFO" + message: > + Add PDF and HTML documentation as assets. + + - name: Add assets to HTML docs + shell: powershell + run: | + zip -r documentation-html.zip ${{ env.EXPECTED_BUILD_DIR }}\html + mv documentation-html.zip ${{ env.EXPECTED_DOWNLOAD_DIR }} + cp ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} + + # ------------------------------------------------------------------------ + - uses: ansys/actions/_logging@main with: level: "INFO" diff --git a/doc-build/action.yml b/doc-build/action.yml index 51751ec8e..5e2a8e114 100644 --- a/doc-build/action.yml +++ b/doc-build/action.yml @@ -150,6 +150,24 @@ inputs: required: false type: boolean + add-pdf-html-docs-as-assets: + description: | + Whether to add PDF and HTML documentation as assets of the HTML + documentation. The HTML documentation is compressed before being added. + The PDF file name is expected to be the same as the project name defined + in the pyproject.toml file. Default value is ``false``. + + .. warning:: + + The HTML files are expected to be contained in ``doc/_build`` and the + PDF file is copied in ``doc/_build/html/_static/assets/download``. + If such directories do not exist in your repo, the action will fail. + + default: false + required: false + type: boolean + + runs: using: "composite" steps: @@ -183,6 +201,7 @@ runs: checkout: ${{ inputs.checkout }} skip-json-build: ${{ inputs.skip-json-build }} check-links: ${{ inputs.check-links }} + add-pdf-html-docs-as-assets: ${{ inputs.add-pdf-html-docs-as-assets }} # ------------------------------------------------------------------------ @@ -208,3 +227,4 @@ runs: checkout: ${{ inputs.checkout }} skip-json-build: ${{ inputs.skip-json-build }} check-links: ${{ inputs.check-links }} + add-pdf-html-docs-as-assets: ${{ inputs.add-pdf-html-docs-as-assets }} From b33538bf0b3a8aea49bbcd5322a3294dac687bfa Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Fri, 19 Apr 2024 17:17:39 +0200 Subject: [PATCH 02/22] TO BE REVERTED: use dedicated branch --- doc-build/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc-build/action.yml b/doc-build/action.yml index 0d5ce4930..b1fa614bb 100644 --- a/doc-build/action.yml +++ b/doc-build/action.yml @@ -188,7 +188,7 @@ runs: - name: Documentation build (Linux) if: ${{ runner.os == 'Linux' }} - uses: ansys/actions/_doc-build-linux@main + uses: ansys/actions/_doc-build-linux@feat/doc-build-upload-assets with: python-version: ${{ inputs.python-version }} use-python-cache: ${{ inputs.use-python-cache }} @@ -215,7 +215,7 @@ runs: - name: Documentation build (Windows) if: ${{ runner.os == 'Windows' }} - uses: ansys/actions/_doc-build-windows@main + uses: ansys/actions/_doc-build-windows@feat/doc-build-upload-assets with: python-version: ${{ inputs.python-version }} use-python-cache: ${{ inputs.use-python-cache }} From a696f5ac527b884a20c966b3c3187ef56f5d7fa6 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 22 Apr 2024 10:23:57 +0200 Subject: [PATCH 03/22] FIX: Var env update --- _doc-build-windows/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index 24b161af6..11ca8f285 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -341,7 +341,7 @@ runs: if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: powershell run: | - echo "EXPECTED_BUILD_DIR='doc\_build'" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 + echo "EXPECTED_BUILD_DIR=$(echo 'doc\_build')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append echo "EXISTS_EXPECTED_BUILD_DIR=$(if (Test-Path '${{ env.EXPECTED_BUILD_DIR }}') { echo 'true' } else { echo 'false' })" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - uses: ansys/actions/_logging@main @@ -355,7 +355,7 @@ runs: if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: powershell run: | - echo "EXPECTED_DOWNLOAD_DIR='${{ env.EXPECTED_BUILD_DIR }}\html\_static\assets\download'" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 + echo "EXPECTED_DOWNLOAD_DIR=$(echo '${{ env.EXPECTED_BUILD_DIR }}\html\_static\assets\download')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$(if (Test-Path '${{ env.EXPECTED_DOWNLOAD_DIR }}') { echo 'true' } else { echo 'false' })" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - uses: ansys/actions/_logging@main From 8ad300587ea385be14151527571c179c55676729 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 22 Apr 2024 10:55:27 +0200 Subject: [PATCH 04/22] FIX: Var env update --- _doc-build-windows/action.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index 11ca8f285..dd599ff2a 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -337,11 +337,16 @@ runs: message: > Check if expected directories exist. - - name: Check expected build directory + - name: Set expected build directory if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: powershell run: | echo "EXPECTED_BUILD_DIR=$(echo 'doc\_build')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Check expected build directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: powershell + run: | echo "EXISTS_EXPECTED_BUILD_DIR=$(if (Test-Path '${{ env.EXPECTED_BUILD_DIR }}') { echo 'true' } else { echo 'false' })" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - uses: ansys/actions/_logging@main @@ -351,11 +356,16 @@ runs: message: > Expected build directory ${{ env.EXPECTED_BUILD_DIR }} does not exist. - - name: Check expected download directory + - name: Set expected download directory if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: powershell run: | echo "EXPECTED_DOWNLOAD_DIR=$(echo '${{ env.EXPECTED_BUILD_DIR }}\html\_static\assets\download')" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Check expected download directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: powershell + run: | echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$(if (Test-Path '${{ env.EXPECTED_DOWNLOAD_DIR }}') { echo 'true' } else { echo 'false' })" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 - uses: ansys/actions/_logging@main From 7c7668e9c9df71e5e4536907ecc05e7c96f6ec17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:38:50 +0200 Subject: [PATCH 05/22] Update _doc-build-windows/action.yml --- _doc-build-windows/action.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index dd599ff2a..e3e397fd8 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -282,20 +282,6 @@ runs: message: > Set environment variable PACKAGE_PDF_FILENAME. - # - name: Determine pdf filename - # if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} - # shell: powershell - # run: | - # python -m pip install toml - # $PDF_FILENAME=$(python -c "" - # import toml;\ - # pyproject = toml.load('pyproject.toml');\ - # name = pyproject.get('tool', {}).get('poetry', {}).get('name')\ - # or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name');\ - # pdf_name = name + '.pdf';\ - # print(pdf_name)") - # echo "PDF_FILENAME=${PDF_FILENAME} | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Install toml if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: powershell From 112e14fdfbe3dab4862551ef5b192a81f0bc3151 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 6 May 2024 10:39:36 +0200 Subject: [PATCH 06/22] FIX: Create expected directory if needed --- _doc-build-linux/action.yml | 17 +++++++++++++++-- _doc-build-windows/action.yml | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 311eac094..67104e9d5 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -306,6 +306,13 @@ runs: message: > Unable to determine PDF filename using pyproject.toml data. + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME != '') }} + with: + level: "INFO" + message: > + Environment variable PACKAGE_PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. + # ------------------------------------------------------------------------ - uses: ansys/actions/_logging@main if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} @@ -338,9 +345,15 @@ runs: - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} with: - level: "ERROR" + level: "WARNING" message: > - Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. + Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. Creating it... + + - name: Create expected download directory + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} + shell: bash + run: | + mkdir -p ${{ env.EXPECTED_DOWNLOAD_DIR }} # ------------------------------------------------------------------------ diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index e3e397fd8..4d171de66 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -314,6 +314,13 @@ runs: message: > Unable to determine PDF filename using pyproject.toml data. + - uses: ansys/actions/_logging@main + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME != '') }} + with: + level: "INFO" + message: > + Environment variable PACKAGE_PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. + # ------------------------------------------------------------------------ - uses: ansys/actions/_logging@main @@ -357,9 +364,15 @@ runs: - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} with: - level: "ERROR" + level: "WARNING" message: > - Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. + Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. Creating it... + + - name: Create expected download directory + if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} + shell: powershell + run: | + New-Item -ItemType directory ${{ env.EXPECTED_DOWNLOAD_DIR }} # ------------------------------------------------------------------------ From 12639c8b498616cc9623018307d1960e0a8327f1 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 6 May 2024 15:05:28 +0200 Subject: [PATCH 07/22] FIX: EOF in linux --- _doc-build-linux/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 67104e9d5..040cb9d46 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -340,7 +340,7 @@ runs: shell: bash run: | echo "EXPECTED_DOWNLOAD_DIR=$(echo '${{ env.EXPECTED_BUILD_DIR }}\html\_static\assets\download')" >> $GITHUB_ENV - echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$( [ -d '${{ env.EXPECTED_DOWNLOAD_DIR }}' ] && echo "true" || echo "false" ) >> $GITHUB_ENV + echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$( [ -d '${{ env.EXPECTED_DOWNLOAD_DIR }}' ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} From cac51b4164ad1041875b75752c1c3c6b92635c78 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 6 May 2024 15:37:30 +0200 Subject: [PATCH 08/22] FIX: EOF in linux --- _doc-build-linux/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 040cb9d46..c8389a892 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -326,7 +326,7 @@ runs: shell: bash run: | echo "EXPECTED_BUILD_DIR='doc\_build'" >> $GITHUB_ENV - echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d '${{ env.EXPECTED_BUILD_DIR }}' ] && echo "true" || echo "false" ) >> $GITHUB_ENV + echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d '${{ env.EXPECTED_BUILD_DIR }}' ] && echo 'true' || echo 'false' ) >> $GITHUB_ENV - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_BUILD_DIR == 'false') }} From 50a98d9ab0b27f21a70a435a76efbf58569ca2dd Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 6 May 2024 15:55:06 +0200 Subject: [PATCH 09/22] FIX: EOF in linux --- _doc-build-linux/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index c8389a892..c1a765d46 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -326,7 +326,7 @@ runs: shell: bash run: | echo "EXPECTED_BUILD_DIR='doc\_build'" >> $GITHUB_ENV - echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d '${{ env.EXPECTED_BUILD_DIR }}' ] && echo 'true' || echo 'false' ) >> $GITHUB_ENV + echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d '${{ env.EXPECTED_BUILD_DIR }}' ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_BUILD_DIR == 'false') }} From 6fdeeb3607964ec92a568ad0aee91ad87f4e0975 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 6 May 2024 16:16:03 +0200 Subject: [PATCH 10/22] FIX: linx path --- _doc-build-linux/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index c1a765d46..cb6f1c2a1 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -325,7 +325,7 @@ runs: if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: bash run: | - echo "EXPECTED_BUILD_DIR='doc\_build'" >> $GITHUB_ENV + echo "EXPECTED_BUILD_DIR='doc/_build'" >> $GITHUB_ENV echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d '${{ env.EXPECTED_BUILD_DIR }}' ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV - uses: ansys/actions/_logging@main @@ -339,7 +339,7 @@ runs: if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: bash run: | - echo "EXPECTED_DOWNLOAD_DIR=$(echo '${{ env.EXPECTED_BUILD_DIR }}\html\_static\assets\download')" >> $GITHUB_ENV + echo "EXPECTED_DOWNLOAD_DIR=$(echo '${{ env.EXPECTED_BUILD_DIR }}/html/_static/assets/download')" >> $GITHUB_ENV echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$( [ -d '${{ env.EXPECTED_DOWNLOAD_DIR }}' ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV - uses: ansys/actions/_logging@main From c0367dc03342832e014511655a782ff610a5de9a Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 6 May 2024 17:32:55 +0200 Subject: [PATCH 11/22] FIX: Linux var env update --- _doc-build-linux/action.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index cb6f1c2a1..440e7cfad 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -321,12 +321,17 @@ runs: message: > Check if expected directories exist. - - name: Check expected build directory + - name: Set expected build directory if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: bash run: | echo "EXPECTED_BUILD_DIR='doc/_build'" >> $GITHUB_ENV - echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d '${{ env.EXPECTED_BUILD_DIR }}' ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV + + - name: Check expected build directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: powershell + run: | + echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d ${{ env.EXPECTED_BUILD_DIR }} ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_BUILD_DIR == 'false') }} @@ -335,11 +340,16 @@ runs: message: > Expected build directory ${{ env.EXPECTED_BUILD_DIR }} does not exist. - - name: Check expected download directory + - name: Set expected download directory if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: bash run: | echo "EXPECTED_DOWNLOAD_DIR=$(echo '${{ env.EXPECTED_BUILD_DIR }}/html/_static/assets/download')" >> $GITHUB_ENV + + - name: Check expected download directory + if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} + shell: bash + run: | echo "EXISTS_EXPECTED_DOWNLOAD_DIR=$( [ -d '${{ env.EXPECTED_DOWNLOAD_DIR }}' ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV - uses: ansys/actions/_logging@main From 16f9f29406359cdffd1f083c1a5b4443ae416cd9 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 6 May 2024 17:37:59 +0200 Subject: [PATCH 12/22] FIX: Missing step in linux --- _doc-build-linux/action.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 440e7cfad..e1866baff 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -367,6 +367,28 @@ runs: # ------------------------------------------------------------------------ + - name: Check build directory + uses: ansys/actions/_logging@main + if: inputs.add-pdf-html-docs-as-assets == 'true' + with: + level: "INFO" + message: > + Add PDF and HTML documentation as assets. + + - name: Compress HTML documentation + uses: vimtor/action-zip@v1.2 + with: + files: ${{ env.EXPECTED_BUILD_DIR }}/html + dest: documentation-html.zip + + - name: Add assets to HTML docs + shell: powershell + run: | + mv documentation-html.zip ${{ env.EXPECTED_DOWNLOAD_DIR }} + cp ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} + + # ------------------------------------------------------------------------ + - name: "Upload HTML documentation artifact" uses: actions/upload-artifact@v4 with: From 8e39684a2cb875c9fe9cdab7acb3ca7f0b31bdd3 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Tue, 7 May 2024 10:18:09 +0200 Subject: [PATCH 13/22] FIX: shell typo --- _doc-build-linux/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index e1866baff..41da8e5eb 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -382,7 +382,7 @@ runs: dest: documentation-html.zip - name: Add assets to HTML docs - shell: powershell + shell: bash run: | mv documentation-html.zip ${{ env.EXPECTED_DOWNLOAD_DIR }} cp ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} From b208f1e22b810b556245c8ae2a72f8f56021479c Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Tue, 7 May 2024 11:02:23 +0200 Subject: [PATCH 14/22] FIX: shell typo --- _doc-build-linux/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 41da8e5eb..07e010198 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -329,7 +329,7 @@ runs: - name: Check expected build directory if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} - shell: powershell + shell: bash run: | echo "EXISTS_EXPECTED_BUILD_DIR=$( [ -d ${{ env.EXPECTED_BUILD_DIR }} ] && echo 'true' || echo 'false' )" >> $GITHUB_ENV From 65bb4e8535f4e2509c0824717cc5e1a73cd46ad7 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Fri, 31 May 2024 15:38:31 +0200 Subject: [PATCH 15/22] WIP: Clean up Changes include: - leveraging conf.py to determine PDF filename - using 'shared' python script to sanitize PDF filename --- _doc-build-linux/action.yml | 57 ++++++++-------------------- _doc-build-windows/action.yml | 41 +++++++------------- doc-build/parse_doc_conf.py | 71 +++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 69 deletions(-) create mode 100644 doc-build/parse_doc_conf.py diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 07e010198..e0fb8098a 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -127,8 +127,8 @@ inputs: description: | Whether to add PDF and HTML documentation as assets of the HTML documentation. The HTML documentation is compressed before being added. - The PDF file name is expected to be the same as the project name defined - in the pyproject.toml file. Default value is ``false``. + The PDF file name is expected to be retrieved through the documentation's + configuration file 'conf.py' in 'doc/source'. .. warning:: @@ -258,60 +258,27 @@ runs: with: level: "INFO" message: > - Set environment variable PACKAGE_PDF_FILENAME. - -# - name: Determine pdf filename -# if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} -# shell: bash -# run: | -# python -m pip install toml -# PDF_FILENAME=$(python -c " -# import toml;\ -# pyproject = toml.load('pyproject.toml');\ -# name = pyproject.get('tool', {}).get('poetry', {}).get('name')\ -# or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name');\ -# pdf_name = name + '.pdf';\ -# print(pdf_name)") -# echo "PDF_FILENAME=${PDF_FILENAME}" >> $GITHUB_ENV - - - name: Install toml - if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} - shell: bash - run: | - python -m pip install toml + Set environment variable PDF_FILENAME. - - name: Determine PDF filename + - name: Parse PDF file name if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} - shell: python + shell: bash run: | - import os - import toml - - pyproject = toml.load('pyproject.toml') - name = pyproject.get('tool', {}).get('poetry', {}).get('name') \ - or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name') - pdf_name = name + '.pdf' - - # Get the GITHUB_ENV variable - github_env = os.getenv('GITHUB_ENV') - - # Append the PDF_FILENAME with its value to GITHUB_ENV - with open(github_env, "a") as f: - f.write(f"PDF_FILENAME={pdf_name}") + python ${{ github.action_path }}/../doc-build/parse_doc_conf.py - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME == '') }} with: level: "ERROR" message: > - Unable to determine PDF filename using pyproject.toml data. + Unable to determine PDF filename using conf.py file. - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME != '') }} with: level: "INFO" message: > - Environment variable PACKAGE_PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. + Environment variable PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. # ------------------------------------------------------------------------ - uses: ansys/actions/_logging@main @@ -385,7 +352,13 @@ runs: shell: bash run: | mv documentation-html.zip ${{ env.EXPECTED_DOWNLOAD_DIR }} - cp ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} + if [ -e "${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }}" ]; then + cp ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} + echo "File ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }} has been copied." + else + cp ${{ env.EXPECTED_BUILD_DIR }}/latex/*.pdf ${{ env.EXPECTED_DOWNLOAD_DIR }} + echo "Couldn't find ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }}, every existing PDF file has been copied." + fi # ------------------------------------------------------------------------ diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index 4d171de66..b132f97c0 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -119,8 +119,8 @@ inputs: description: | Whether to add PDF and HTML documentation as assets of the HTML documentation. The HTML documentation is compressed before being added. - The PDF file name is expected to be the same as the project name defined - in the pyproject.toml file. Default value is ``false``. + The PDF file name is expected to be retrieved through the documentation's + configuration file 'conf.py' in 'doc/source'. .. warning:: @@ -280,46 +280,27 @@ runs: with: level: "INFO" message: > - Set environment variable PACKAGE_PDF_FILENAME. + Set environment variable PDF_FILENAME. - - name: Install toml + - name: Parse PDF file name if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: powershell run: | - python -m pip install toml - - - name: Determine PDF filename - if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} - shell: python - run: | - import os - import toml - - pyproject = toml.load('pyproject.toml') - name = pyproject.get('tool', {}).get('poetry', {}).get('name') \ - or pyproject.get('tool', {}).get('flit', {}).get('module', {}).get('name') - pdf_name = name + '.pdf' - - # Get the GITHUB_ENV variable - github_env = os.getenv('GITHUB_ENV') - - # Append the PDF_FILENAME with its value to GITHUB_ENV - with open(github_env, "a") as f: - f.write(f"PDF_FILENAME={pdf_name}") + python ${{ github.action_path }}\..\doc-build\parse_doc_conf.py - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME == '') }} with: level: "ERROR" message: > - Unable to determine PDF filename using pyproject.toml data. + Unable to determine PDF filename using conf.py file. - uses: ansys/actions/_logging@main if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true' ) && (env.PDF_FILENAME != '') }} with: level: "INFO" message: > - Environment variable PACKAGE_PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. + Environment variable PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. # ------------------------------------------------------------------------ @@ -389,7 +370,13 @@ runs: run: | zip -r documentation-html.zip ${{ env.EXPECTED_BUILD_DIR }}\html mv documentation-html.zip ${{ env.EXPECTED_DOWNLOAD_DIR }} - cp ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} + if (Test-Path $${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }}) { + cp ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} + Write-Output "File ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }} has been copied." + } else { + cp ${{ env.EXPECTED_BUILD_DIR }}/latex/*.pdf ${{ env.EXPECTED_DOWNLOAD_DIR }} + Write-Output "Couldn't find ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }}, every existing PDF file has been copied." + } # ------------------------------------------------------------------------ diff --git a/doc-build/parse_doc_conf.py b/doc-build/parse_doc_conf.py new file mode 100644 index 000000000..50525879a --- /dev/null +++ b/doc-build/parse_doc_conf.py @@ -0,0 +1,71 @@ +# 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. + +""" +Documentation script. + +Notes +----- +Script parsing the documentation's conf.py file to determine the name of +the PDF generated after building the documentation. +""" + +import os +import re +from pathlib import Path + +CONF_PATH = Path("doc", "source", "conf.py") + + +def get_project_name(conf_path): + """Parse file to retrieve documentation's project name.""" + res = None + with open(conf_path, "r") as conf_file: + for line in conf_file: + if line.strip().startswith(("project =", "project=")): + print(line) + res = re.search(r'project\s*=\s*[\'"](.+)[\'"]', line).group(1) + break + return res + + +def generate_pdf_name(project_name): + """Convert a project name to a valid file name.""" + # Remove spaces and covert to lowercase + sanitized_name = re.sub(r"\s+", "", project_name) + res = f"{sanitized_name.lower()}.pdf" + return res + + +project_name = get_project_name(CONF_PATH) +print(f"Project name: {project_name}") + +if project_name: + pdf_file_name = generate_pdf_name(project_name) + print(f"PDF file name: {pdf_file_name}") + + # Get the GITHUB_ENV variable + github_env = os.getenv("GITHUB_ENV") + + # Append PDF_FILENAME with its value to GITHUB_ENV + with open(github_env, "a") as f: + f.write(f"PDF_FILENAME={pdf_file_name}") From bff6baaade05946fbcc68a23452bfb2147d3899d Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 3 Jun 2024 11:30:09 +0200 Subject: [PATCH 16/22] FIX: Doc build typos --- _doc-build-linux/action.yml | 2 +- _doc-build-windows/action.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index e0fb8098a..28d85d274 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -292,7 +292,7 @@ runs: if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} shell: bash run: | - echo "EXPECTED_BUILD_DIR='doc/_build'" >> $GITHUB_ENV + echo "EXPECTED_BUILD_DIR=doc/_build" >> $GITHUB_ENV - name: Check expected build directory if: ${{ inputs.add-pdf-html-docs-as-assets == 'true' }} diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index b132f97c0..1dcf7ed7d 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -372,10 +372,10 @@ runs: mv documentation-html.zip ${{ env.EXPECTED_DOWNLOAD_DIR }} if (Test-Path $${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }}) { cp ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} - Write-Output "File ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }} has been copied." + Write-Output "File ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }} has been copied." } else { - cp ${{ env.EXPECTED_BUILD_DIR }}/latex/*.pdf ${{ env.EXPECTED_DOWNLOAD_DIR }} - Write-Output "Couldn't find ${{ env.EXPECTED_BUILD_DIR }}/latex/${{ env.PDF_FILENAME }}, every existing PDF file has been copied." + cp ${{ env.EXPECTED_BUILD_DIR }}\latex\*.pdf ${{ env.EXPECTED_DOWNLOAD_DIR }} + Write-Output "Couldn't find ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }}, every existing PDF file has been copied." } # ------------------------------------------------------------------------ From 34dbbcc2c2d5579025d51684578ed64b13aa0a5c Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Mon, 3 Jun 2024 12:10:28 +0200 Subject: [PATCH 17/22] FIX: Typo in env var access --- _doc-build-windows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index 1dcf7ed7d..bd0b43113 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -370,7 +370,7 @@ runs: run: | zip -r documentation-html.zip ${{ env.EXPECTED_BUILD_DIR }}\html mv documentation-html.zip ${{ env.EXPECTED_DOWNLOAD_DIR }} - if (Test-Path $${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }}) { + if (Test-Path ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }}) { cp ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }} ${{ env.EXPECTED_DOWNLOAD_DIR }} Write-Output "File ${{ env.EXPECTED_BUILD_DIR }}\latex\${{ env.PDF_FILENAME }} has been copied." } else { From f128fff29ec6b91ff944623bed06bd8606f606fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Mon, 3 Jun 2024 14:25:22 +0200 Subject: [PATCH 18/22] Apply suggestions from code review --- doc-build/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc-build/action.yml b/doc-build/action.yml index b1fa614bb..0d5ce4930 100644 --- a/doc-build/action.yml +++ b/doc-build/action.yml @@ -188,7 +188,7 @@ runs: - name: Documentation build (Linux) if: ${{ runner.os == 'Linux' }} - uses: ansys/actions/_doc-build-linux@feat/doc-build-upload-assets + uses: ansys/actions/_doc-build-linux@main with: python-version: ${{ inputs.python-version }} use-python-cache: ${{ inputs.use-python-cache }} @@ -215,7 +215,7 @@ runs: - name: Documentation build (Windows) if: ${{ runner.os == 'Windows' }} - uses: ansys/actions/_doc-build-windows@feat/doc-build-upload-assets + uses: ansys/actions/_doc-build-windows@main with: python-version: ${{ inputs.python-version }} use-python-cache: ${{ inputs.use-python-cache }} From 829cf4898841cc0af5c05674b5819796646241f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:09:58 +0200 Subject: [PATCH 19/22] Apply suggestions from code review Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> --- _doc-build-linux/action.yml | 2 +- _doc-build-windows/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index 28d85d274..b904e8dbe 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -278,7 +278,7 @@ runs: with: level: "INFO" message: > - Environment variable PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. + Environment variable PDF_FILENAME set to ${{ env.PDF_FILENAME }}. # ------------------------------------------------------------------------ - uses: ansys/actions/_logging@main diff --git a/_doc-build-windows/action.yml b/_doc-build-windows/action.yml index bd0b43113..bbe3671d4 100644 --- a/_doc-build-windows/action.yml +++ b/_doc-build-windows/action.yml @@ -300,7 +300,7 @@ runs: with: level: "INFO" message: > - Environment variable PDF_FILENAME setted to ${{ env.PDF_FILENAME }}. + Environment variable PDF_FILENAME set to ${{ env.PDF_FILENAME }}. # ------------------------------------------------------------------------ From 15bc88838ddb0e85ffbb1f1985d484f1cf3fa23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:20:29 +0200 Subject: [PATCH 20/22] Update _doc-build-linux/action.yml Co-authored-by: Revathy Venugopal <104772255+Revathyvenugopal162@users.noreply.github.com> --- _doc-build-linux/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_doc-build-linux/action.yml b/_doc-build-linux/action.yml index b904e8dbe..161df60e9 100644 --- a/_doc-build-linux/action.yml +++ b/_doc-build-linux/action.yml @@ -324,7 +324,7 @@ runs: with: level: "WARNING" message: > - Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. Creating it... + Expected build directory ${{ env.EXPECTED_DOWNLOAD_DIR }} does not exist. Creating it... - name: Create expected download directory if: ${{ (inputs.add-pdf-html-docs-as-assets == 'true') && (env.EXISTS_EXPECTED_DOWNLOAD_DIR == 'false') }} From 86efef95489f3bcbe29aa13f9e3a228f8bd61c29 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Thu, 6 Jun 2024 14:13:41 +0200 Subject: [PATCH 21/22] REFACTOR: Add warning if no project var --- doc-build/parse_doc_conf.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc-build/parse_doc_conf.py b/doc-build/parse_doc_conf.py index 50525879a..b00ea89f2 100644 --- a/doc-build/parse_doc_conf.py +++ b/doc-build/parse_doc_conf.py @@ -31,6 +31,7 @@ import os import re +import warnings from pathlib import Path CONF_PATH = Path("doc", "source", "conf.py") @@ -57,9 +58,9 @@ def generate_pdf_name(project_name): project_name = get_project_name(CONF_PATH) -print(f"Project name: {project_name}") if project_name: + print(f"Project name: {project_name}") pdf_file_name = generate_pdf_name(project_name) print(f"PDF file name: {pdf_file_name}") @@ -69,3 +70,9 @@ def generate_pdf_name(project_name): # Append PDF_FILENAME with its value to GITHUB_ENV with open(github_env, "a") as f: f.write(f"PDF_FILENAME={pdf_file_name}") +else: + warnings.warn( + "The name of the project is not specified in the documentation's" + "configuration file. Please, set variable 'project'", + UserWarning, + ) From bab0eb81370afdffdeb6d1fd9b326df237e82087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:31:55 +0200 Subject: [PATCH 22/22] Update doc-build/parse_doc_conf.py --- doc-build/parse_doc_conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc-build/parse_doc_conf.py b/doc-build/parse_doc_conf.py index b00ea89f2..81b737d8c 100644 --- a/doc-build/parse_doc_conf.py +++ b/doc-build/parse_doc_conf.py @@ -73,6 +73,6 @@ def generate_pdf_name(project_name): else: warnings.warn( "The name of the project is not specified in the documentation's" - "configuration file. Please, set variable 'project'", + "configuration file. Please, set variable 'project'.", UserWarning, )