Style actions#

Style actions verify code and documentation quality compliance with PyAnsys guidelines.

Code style action#

This action evaluates the code quality of your project by using pre-commit. The action installs and runs pre-commit. It is assumed that your project contains a .pre-commit-config.yaml file in the root directory. The action can also be extended to lint docker files that are contained in the docker directory and the .devcontainer directory.

Warning

If docker lint is enabled and directories docker or .devcontainer exist, the action will fail if it doesn’t find a Dockerfile.

Source code for this action

Input

Description

Required

Type

Default

python-version

Python version used for installing and running pre-commit.

False

string

3.1

use-python-cache

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.

False

boolean

1

docker-lint

Extend the workflow to lint Dockerfile(s).

False

bool

0

docker-recursive

Search for Dockerfile(s) recursively. Only applies to allowed directories, i.e. docker and .devcontainer.

False

bool

0

docker-error-level

Fail docker-style action based on hadolint output (-1: never, 0: error, 1: warning, 2: info)

False

int

2

skip-install

Whether to skip the installation of the project or not. If true, the project is not installed. If false, the project is installed. By default, the project is not installed.

False

boolean

1

Examples#

Running code style checks
code-style:
  name: "Running code style checks"
  runs-on: ubuntu-latest
  steps:
    - name: "Run PyAnsys code style checks"
      uses: ansys/actions/code-style@v6.0

Doc style action#

Check documentation style using Vale. This action is a wrapper on top of the errata-ai/vale-action.

Source code for this action

Input

Description

Required

Type

Default

token

The token value used to authorize Vale to add comments and suggestions in the file section.

True

string

vale-config

Path to the Vale configuration file.

False

string

doc/.vale.ini

vale-version

Version number for Vale.

False

string

3.4.1

toml-version

Toml version used for retrieving the towncrier directory.

False

string

0.10.2

ignore-changelogd

Whether or not to ignore markdown files in doc/changelog.d/.

False

bool

True

checkout

Whether to clone the repository in the CI/CD machine. Default value is true.

False

boolean

True

Examples#

Running documentation style checks
doc-style:
  name: "Running documentation style checks"
  runs-on: ubuntu-latest
  steps:
    - name: "Running documentation style checks"
      uses: ansys/actions/doc-style@v6.0
      with:
        token: ${{ secrets.GITHUB_TOKEN }}

Docker style action#

Evaluate the quality of your project Dockerfile(s) by using hadolint. This action can be used to lint Dockerfile(s) from multiple directories, see input “directory” description. The action uses hadolint-gh-action behind the scenes. If you want to evaluate multiple Dockerfiles contained in various directories of the provided directory, use the recursive option. When linting a Dockerfile dedicated to Windows, one should use hadolint shell pragma to avoid false positives from ShellCheck, see hadolint shell pragma.

Note

This action emphasizes the fact of having Dockerfile(s) contained inside the ‘docker’ directory in the root of the project.

Warning

This action only looks for docker files named Dockerfile. A docker file like Dockerfile.linux will not be linted.

Source code for this action

Input

Description

Required

Type

Default

directory

Directory from which to search for Dockerfile(s). You can pass multiple directories for processing by separating them with spaces, e.g. “docker .devcontainer”.

False

string

docker

recursive

Search for Dockerfile(s) recursively.

False

bool

False

error-level

Fail action based on hadolint output (-1: never, 0: error, 1: warning, 2: info)

False

int

2

checkout

Whether to clone the repository in the CI/CD machine. Default value is true.

False

boolean

True

Examples#

Docker style
docker-style:
  name: "Docker style"
  runs-on: ubuntu-latest
  steps:
    - uses: ansys/actions/docker-style@v6.0
      with:
        directory: docker
        recursive: true
        error-level: 1

Commit style action#

Action that checks if the title of the pull request is following the conventional commits standard.

Source code for this action

Input

Description

Required

Type

Default

token

The token value used to authorize Vale to add comments and suggestions in the file section.

True

string

use-upper-case

Use of uppercase letters in the “type” field of the commit. For example, “FIX!: fix server crash issue” would be a valid commit. .. note:

Expected type are upper cases of conventional commit types.

False

boolean

False

Examples#

Run commit style checks
commit-style:
  name: "Run commit style checks"
  runs-on: ubuntu-latest
  steps:
    - uses: ansys/actions/commit-style@v6.0
      with:
        token: ${{ secrets.GITHUB_TOKEN }}

Branch name style action#

Checks if the name of the branch follows the branch naming convention of PyAnsys.

Note

Branch names must start with one of the following prefixes:

  • fix

  • feat

  • junk

  • maint

  • docs

  • no-ci

  • testing or test

  • release

  • dependabot

Source code for this action

Examples#

Run branch name style checks
branch-name-style:
  name: "Run branch name style checks"
  runs-on: ubuntu-latest
  steps:
    - uses: ansys/actions/branch-name-style@v6.0