diff --git a/doc-style/action.yml b/doc-style/action.yml index c8af8f5b4..5b33192ca 100644 --- a/doc-style/action.yml +++ b/doc-style/action.yml @@ -55,6 +55,20 @@ inputs: required: false type: string + toml-version: + description: > + Toml version used for retrieving the towncrier directory. + default: '0.10.2' + required: false + type: string + + ignore-changelogd: + description: > + Whether or not to ignore markdown files in doc/changelog.d/. + default: true + required: false + type: bool + checkout: description: > Whether to clone the repository in the CI/CD machine. Default value is @@ -108,6 +122,44 @@ runs: fi fi + - name: "Install toml" + shell: bash + run: | + python -m pip install --upgrade pip toml==${{ inputs.toml-version }} + + - name: "Get towncrier directory" + shell: python + run: | + import os + import toml + + # Load pyproject.toml + with open('pyproject.toml', 'r') as f: + config = toml.load(f) + try: + # Get towncrier directory + directory=config["tool"]["towncrier"]["directory"] + except KeyError: + # If towncrier directory isn't specified in pyproject.toml + directory="" + + # Get the GITHUB_ENV variable + github_env = os.getenv('GITHUB_ENV') + + # Append the TOWNCRIER_DIR with its value to GITHUB_ENV + with open(github_env, "a") as f: + f.write(f"TOWNCRIER_DIR={directory}") + + - name: "Check if changelog.d is ignored" + shell: bash + run: | + # If changelog.d is ignored and the TOWNCRIER_DIR exists in pyproject.toml, add the ignore glob + if [[ ${{ inputs.ignore-changelogd }} == 'true' ]] && [[ -n "${{ env.TOWNCRIER_DIR }}" ]]; then + echo VALE_FLAGS="--config=${{ inputs.vale-config }} --glob=!${{ env.TOWNCRIER_DIR }}/*.md" >> $GITHUB_ENV + else + echo VALE_FLAGS="--config=${{ inputs.vale-config }}" >> $GITHUB_ENV + fi + - name: "Run Vale" uses: errata-ai/vale-action@reviewdog env: @@ -118,5 +170,5 @@ runs: level: error filter_mode: nofilter fail_on_error: true - vale_flags: "--config=${{ inputs.vale-config }}" + vale_flags: "${{ ENV.VALE_FLAGS }}" version: ${{ inputs.vale-version }} diff --git a/doc/source/style-actions/index.rst b/doc/source/style-actions/index.rst index 4d0979971..2d8d2cea6 100644 --- a/doc/source/style-actions/index.rst +++ b/doc/source/style-actions/index.rst @@ -1,112 +1,112 @@ -Style actions -============= -Style actions verify code and documentation quality compliance -with PyAnsys guidelines. - - -Code style action ------------------ - -.. jinja:: code-style - - {{ description }} - - {{ inputs_table }} - - Examples - ++++++++ - - {% for filename, title in examples %} - .. dropdown:: {{ title }} - :animate: fade-in - - .. literalinclude:: examples/{{ filename }} - :language: yaml - - {% endfor %} - - -Doc style action ----------------- - -.. jinja:: doc-style - - {{ description }} - - {{ inputs_table }} - - Examples - ++++++++ - - {% for filename, title in examples %} - .. dropdown:: {{ title }} - :animate: fade-in - - .. literalinclude:: examples/{{ filename }} - :language: yaml - - {% endfor %} - - -Docker style action -------------------- - -.. jinja:: docker-style - - {{ description }} - - {{ inputs_table }} - - Examples - ++++++++ - - {% for filename, title in examples %} - .. dropdown:: {{ title }} - :animate: fade-in - - .. literalinclude:: examples/{{ filename }} - :language: yaml - - {% endfor %} - - -Commit style action -------------------- - -.. jinja:: commit-style - - {{ description }} - - {{ inputs_table }} - - Examples - ++++++++ - - {% for filename, title in examples %} - .. dropdown:: {{ title }} - :animate: fade-in - - .. literalinclude:: examples/{{ filename }} - :language: yaml - - {% endfor %} - - -Branch name style action ------------------------- - -.. jinja:: branch-name-style - - {{ description }} - - Examples - ++++++++ - - {% for filename, title in examples %} - .. dropdown:: {{ title }} - :animate: fade-in - - .. literalinclude:: examples/{{ filename }} - :language: yaml - - {% endfor %} +Style actions +============= +Style actions verify code and documentation quality compliance +with PyAnsys guidelines. + + +Code style action +----------------- + +.. jinja:: code-style + + {{ description }} + + {{ inputs_table }} + + Examples + ++++++++ + + {% for filename, title in examples %} + .. dropdown:: {{ title }} + :animate: fade-in + + .. literalinclude:: examples/{{ filename }} + :language: yaml + + {% endfor %} + + +Doc style action +---------------- + +.. jinja:: doc-style + + {{ description }} + + {{ inputs_table }} + + Examples + ++++++++ + + {% for filename, title in examples %} + .. dropdown:: {{ title }} + :animate: fade-in + + .. literalinclude:: examples/{{ filename }} + :language: yaml + + {% endfor %} + + +Docker style action +------------------- + +.. jinja:: docker-style + + {{ description }} + + {{ inputs_table }} + + Examples + ++++++++ + + {% for filename, title in examples %} + .. dropdown:: {{ title }} + :animate: fade-in + + .. literalinclude:: examples/{{ filename }} + :language: yaml + + {% endfor %} + + +Commit style action +------------------- + +.. jinja:: commit-style + + {{ description }} + + {{ inputs_table }} + + Examples + ++++++++ + + {% for filename, title in examples %} + .. dropdown:: {{ title }} + :animate: fade-in + + .. literalinclude:: examples/{{ filename }} + :language: yaml + + {% endfor %} + + +Branch name style action +------------------------ + +.. jinja:: branch-name-style + + {{ description }} + + Examples + ++++++++ + + {% for filename, title in examples %} + .. dropdown:: {{ title }} + :animate: fade-in + + .. literalinclude:: examples/{{ filename }} + :language: yaml + + {% endfor %}