Skip to content

Get started using Vale at Red Hat

Learn how to use Vale to lint your Red Hat documentation. This guide covers installing Vale and the RedHat style, analyzing documentation with various tools (CLI, IDE integrations, and desktop app), understanding and reporting Vale output, and integrating Vale into your workflow with GitHub Actions, GitLab CI, and other continuous integration services.

Introduction

Vale is a command-line tool that allows you to check your writing for grammar and spelling errors against a set of style rules. It’s open source, fast, and highly customizable.

Vale can help you improve your content. For example:

  • You can measure how well your content complies with the style guide.

  • You can fix style issues before you create a PR.

  • You can perform more consistent peer reviews.

  • You can write content that is more easily localized.

Installing Vale

Install the Vale linter to begin reviewing content for style and structure.

Important

If you are working in an established project that has already implemented Vale, you do not need to create a new vale.ini. The project will already have a vale.ini configuration.

Prerequisites
  • Install the Asciidoctor Ruby gem.

  • If you have previously installed Vale, you can check what version you are currently running. Run the following command:

    $ vale --version
    Example output
    vale version 3.6.1
Procedure
  1. Install Vale. For RHEL or Fedora Linux operating systems, run the following command:

    $ sudo dnf copr enable mczernek/vale && sudo dnf install vale

    On macOS, run:

    $ brew install vale
  2. Verify the Vale install location. You might need to update your text editor with this value.

    $ which vale
    Example output
    /usr/bin/vale

    Note

    For other operating systems, see Installing Vale.

Installing the Red Hat style for Vale globally

You can install the RedHat style for Vale globally.

Important

The RedHat style for Vale requires Vale version 3.7 and above.

Important

Some product documentation repositories, such as openshift-docs, have an existing .vale.ini file. When you run vale on content files in the repository directory, the <repository>/.vale.ini file overrides the $HOME/.vale.ini file. For more information, see Vale configuration reference.

Run vale sync in your project directory to download the Vale rules relative to that project directory.

Procedure
  1. To use Vale with the RedHat package system-wide, create the following .vale.ini configuration file in your $HOME directory.

    Example .vale.ini
    StylesPath = .vale/styles
    
    MinAlertLevel = suggestion
    
    IgnoredScopes = code, tt, img, url, a, body.id
    
    SkippedScopes = script, style, pre, figure, code, tt, blockquote, listingblock, literalblock
    
    Packages = RedHat
    
    [*.adoc]
    
    BasedOnStyles = RedHat
    
    [*.md]
    
    BasedOnStyles = RedHat
    
    # Ignore code surrounded by backticks or plus sign, parameters defaults, URLs.
    TokenIgnores = (\x60[^\n\x60]+\x60), ([^\n]+=[^\n]*), (\+[^\n]+\+), (http[^\n]+\[)
    
    # Match INI files. See: https://docs.errata.ai/vale/scoping
    [*.ini]
    
    BasedOnStyles = RedHat
    
    # Ignore code surrounded by backticks or plus sign, parameters defaults, URLs.
    TokenIgnores = (\x60[^\n\x60]+\x60), ([^\n]+=[^\n]*), (\+[^\n]+\+), (http[^\n]+\[)
    
    # Disabling rules (NO)
    RedHat.CaseSensitiveTerms = NO
    RedHat.ConfigMap = NO
    RedHat.Definitions = NO
    RedHat.Slash = NO
    RedHat.Spacing = NO
    RedHat.Spelling = NO
    RedHat.TermsSuggestions = NO
  2. Sync the RedHat package to your computer.

    $ vale sync
    Example output
    $ vale sync
     SUCCESS  Downloaded package 'RedHat'
    Downloading packages [1/1]

    Tip

    To get the latest updates, run vale sync regularly.
Verification
  1. Run vale against a source file:

    $ cd <project_directory>
    $ vale <filename>
    Example output
    $ vale modules/ztp-creating-the-site-secrets.adoc
    
     modules/ztp-creating-the-site-secrets.adoc
     10:222  error       Use 'Assisted Installer'        Vale.Terms
                         instead of 'assisted
                         installer'.
     14:13   suggestion  'are referenced' is passive     RedHat.PassiveVoice
                         voice. In general, use active
                         voice. Consult the style guide
                         for acceptable use of passive
                         voice.
    
    ✖ 2 errors, 0 warnings and 1 suggestion in 1 file.

Analyzing your content with Vale

To analyze your content, you can run Vale from the command line, within your IDE, and by using the Vale-at-Red-Hat online web app.

Analyzing your content locally

For more information, see the following topics:

Git workflow integration

You can also analyze your content by integrating Vale into the Git workflow of a shared content project. For more information, see the following topics:

Analyzing your content by using the Vale-at-Red-Hat web app

To get familiar with Vale without installing the Vale software on your local client, you can use the Vale-at-Red-Hat web app. This web app is preconfigured to analyze your content by using Red Hat’s style rules.

Prerequisites
  • You must have Docker or Podman installed on your system.

Procedure
  1. Run the following command to download the image and start the container:

    docker run --rm -p 8080:8080 quay.io/ganelson/vale-online-app
  2. Open your browser and go to http://localhost:8080.

  3. Paste the content you want to check in the text area and click on the Lint button.

    By default, the Vale-at-Red-Hat web app displays warnings and errors only. You can also view suggestions by using the options menu on the left.

  4. To close the app, press Ctrl+C in the terminal where the container is running.

Analyzing your content by running Vale from the command line

To analyze your content to see how it aligns with the Red Hat supplementary and IBM style guides, you can run Vale from the command line. You can run Vale on individual files or an entire directory.

Vale analyzes the specified content according to the command options and the style preferences that you have specified in your .vale.ini configuration file.

Prerequisites
  • You’ve installed a recent release Vale on your system.

  • You’ve installed a recent release of Asciidoctor on your system.

  • You’ve installed and configured Vale CLI, setting both Packages and BasedOnStyles to RedHat in the .vale.ini file.

  • You’ve gotten the latest RedHat style by running the vale sync command.

Procedure
  1. Start a terminal session and go to the content folder containing the files that you want to analyze.

  2. Enter the vale linter command by using the following syntax:

    $ vale <target_file_name> --<option> > <output_file_name>

    Where:

    • <target_file_name> is the name of the content file that you want to analyze. Or use the * wildcard to analyze all files in the current folder.

    • <option> is an option you can use to tailor the alerts or linter output. For more information, see Example use cases for running the Vale command.

    • <output_file_name> is an option that you can append to the command to pipe the output to a specific file instead of at the command line.

Verification

Review the list of suggestions, warnings, and errors that Vale outputs to the command line. See Understanding Vale output.

Example use cases for running the Vale command
  • To verify the style compliance of a file in the current folder called example.adoc, enter:

    $ vale example.adoc
  • To verify the style compliance of all files in the current folder and turn off text wrapping in the command-line output, enter:

    $ vale *.* --no-wrap

    Note

    If you are expecting a large quantity of output in the report, use the --no-wrap option to make the results easier to read from the command line.

  • To verify the style compliance of a file named example.adoc and remove suggestions from the output to retrieve warnings and errors, enter:

    $ vale example.adoc --minAlertLevel=warning
  • To verify the style compliance of a file named example.adoc and report errors only, enter:

    $ vale example.adoc --minAlertLevel=error
  • To verify the style compliance of a file named example.adoc and output errors only into a file in JSON format, enter:

    $ vale example.adoc --minAlertLevel=error --output="JSON" | tee ~/test.json
  • To verify the style compliance of a file named example.adoc and output errors only into a file in JSON format, enter:

  • To get help including a list of valid options for running Vale, enter:

    $ vale --help
Additional resources

Using Vale in the IDE

Understanding Vale output

As a technical writer, you typically run vale on the command-line against a content file:

$ cd openshift-docs/logging/troubleshooting/
$ vale cluster-logging-troubleshooting-for-critical-alerts.adoc

The resulting command output gives you a list of suggestions, warnings, and errors based on customizable styles and vocabulary.

As a writer, you review the output, decide which issues are valid, and update your content accordingly.

Example 1. vale command line output example
238:27 error      Did you really mean        Vale.Spelling
                    'rebalancing'?
244:6  suggestion Verify your use of 'there  IBM.Usage
                  are' with the word usage
                  guidelines.
244:38 warning    Consider using 'available' CheDocs.CommonTerms
                  rather than 'present'

Understanding the vale command line tool output presentation

First column

The line and character number of the issue, such as: 244:6.

Second column

The alert level, such as error, suggestion, or warning. See: Understanding Vale alert levels

Third column

The rule message, such as: Verify your use of 'there are'

Fourth column

The name of the style and of the rule, such as: IBM.Usage.

Understanding Vale alert levels

error

Fix the language error. This alert level includes Spelling errors, which are frequently happening on products and tools names. In that case, consider creating a vocabulary for a project or extending styles.

warning

Consider fixing the language error.

suggestion

Heads up! Verify the usage depending on the context. Content containing suggestions is fine.

Collating Vale output

You can use a template to collate the results from running vale on the command line. This collated output is non-repetitive and might be easier to use.

The RedHat style includes a collate-output.tmpl template you can specify when you run the vale command. For example:

$ cd openshift-docs/
$ vale --output='.vale/styles/RedHat/collate-output.tmpl' modules/about-crio.adoc

The resulting command output collates any repetitive the suggestions, warnings, or errors.

Example vale output from the collate-output.tmpl template
 modules/about-crio.adoc

 7:9,11:107  suggestion  Define acronyms and             RedHat.Definitions
                         abbreviations (such as 'CRI')
                         on first occurrence if they're
                         likely to be unfamiliar.

0 errors, 0 warnings and 2 suggestions in 1 file.

Note

When you use the --output option, other options such as --minAlertLevel might not work.

Understanding the vale output

First column

A comma-separated list of each instance where the issue appears: 7:9,11:107.

Second column

The alert level, such as error, suggestion, or warning. See: Understanding Vale alert levels

Third column

The rule message, such as: Define acronyms and abbreviations (such as 'CRI') on first occurrence if they’re likely to be unfamiliar.

Fourth column

The name of the style and rule, such as: RedHat.Definitions.

Using Vale in the IDE

Consider using Vale in your IDE when:

Prerequisites
Procedure
  1. In Visual Studio Code, install the latest "Vale VSCode" extension by Chris Chinchilla.

  2. Restart Visual Studio Code.

Note

Avoid installing the earlier obsolete "Vale" extension by errata-ai, which is very similar in appearance to the latest extension.
Verification
  1. Open a content file causing vale alerts.

  2. Open the Problems view and search for vale alerts in it.

Glossary

Vale command-line tool

The vale command-line tool brings code-like linting to prose. Use it to validate language on your local environment or in continuous integration services.

Vale configuration file

The Vale configuration file .vale.ini defines:

  • File names patterns to match files to validate

  • Active styles and vocabulary

  • Custom content patterns to change scoping behavior

Vale rule

A Vale rule is a YAML file defining:

  • a language issue, including spelling issues

  • a proposed solution

  • a link to more information.

Vale style

A Vale style is a directory containing a collection of rules.

Vale vocabulary

In a project, a Vale vocabulary is an optional additional directory containing lists of accepted and rejected words, applying to all styles.

  • Missing words in the Vale dictionary are causing Spelling errors

  • The word is too specific to benefit to other projects.

Consider Extending styles when:

  • Missing words in the Vale dictionary are causing Spelling errors

  • Adding the word will benefit to other projects. For example: product and tool names, common terms specific to the software industry.

Generating extended Vale alerts reports

Consider generating extended Vale alerts reports about a Git repository to:

These reports use the Vale report in JSON format and additional information such as the word count.

On bigger repositories, with more than 1000000 words, consider building your own reporting tool to chunk the task in smaller pieces.

Prerequisites
Procedure
  1. Generate vale alerts reports for <location>:

    $ ./tools/vale_report.sh <location>
  2. The script creates following files for each Git repository found at <location>:

    vale-report_<repository>_-list.log

    List of AsciiDoc files considered for the report.

    vale-report_<repository>_-wordcount.log

    Word count for all files in the file list. Use this information to compare the number of alerts between repositories.

    vale-report_<repository>_.json

    Vale report in JSON format. Use the jq tool to query the results.

    vale-report_<repository>_.severity

    Breakdown of alerts by severity.

    vale-report_<repository>_.rules

    Breakdown of alerts by rules.

    vale-report_<repository>_.Spelling.txt

    Breakdown of Spelling alerts.

Defining a Vale onboarding strategy

Embracing a linter in a project is a long journey. The full Vale report can be discouraging at first. Remember that:

  • You are in charge: review the report and decide what is useful to you.

  • The styles are not perfect or complete.

  • Assess the maturity of the project.

Assess the project maturity

Zero Vale errors

The project is compliant with the RedHat style. Consider integration with a continuous integration service using the defaults from the vale-at-red-hat repository.

Under 100 Vale errors

The project is almost compliant with the RedHat style. Consider integration with a continuous integration service using the defaults from the vale-at-red-hat repository. Consider massively fixing the few errors.

Over 100 Vale errors

The project is big or poorly compliant with the RedHat style. Consider further investigation to understand the issue.

Start small

  • To onboard a collection of repositories, start by the repository with the smallest word count. See Reporting Vale alerts

Focus on errors

  • Report only errors. Don’t report warnings and suggestions.

    $ vale --minAlertLevel=error .

Expect false positives

  • The RedHat style has been thoroughly tested on a corpus of 113000 words. You can expect false positives when applying the style to a new corpus. Consider contributing to the style.

Collect data

  • Reporting Vale alerts

  • Use the results to identify the rule creating the most errors, and work on that rule. Most probably, start with the Spelling rule.

  • Report alerts for one single rule. Maybe use custom output templates to generate a custom report. See Vale documentation - JSON output of checks and Vale documentation - --output. Consider aggregating alerts to identify the most common. Examine the report to distinguish legit alerts from false positives. Use the curated list of false positives to report an issue.

    For example, for the Spelling rule, create a report containing the list of all words reported by the Spelling rule, and count their occurrences. Use that list to differentiate false positives from legit errors. Use the curated list to report an issue.

Fix the alerts

  • Run campaigns focused on one target such as: fix all errors, fix all occurrences of a given rule.

  • Disable a rule that is irrelevant in the file context. See: Vale - Markup-based configuration

    pass:[<!-- vale RedHat.Spelling = NO -->]
    
    The Spelling rule is ignored for this line.
    
    pass:[<!-- vale RedHat.Spelling = YES -->]
    
    The Spelling rule is active for this line.

Display less alerts without changing the configuration file

  • Display only errors. Don’t display warnings and suggestions.

    $ vale --minAlertLevel=error .
  • Display only errors and warnings. Don’t display suggestions.

    $ vale --minAlertLevel=warning .

Decrease the number of alerts

Adding Vale to a project

Consider adding Vale configuration files to a project to:

  • Simplify Vale usage by anyone in a project

  • Use Vale in continuous integration

Prerequisites
  • Install the Vale command-line tool.

Procedure
  1. Create a .vale.ini configuration file in the root directory for your documentation project:

    Example .vale.ini
    StylesPath = .vale/styles
    
    MinAlertLevel = suggestion
    
    IgnoredScopes = code, tt, img, url, a, body.id
    
    SkippedScopes = script, style, pre, figure, code, tt, blockquote, listingblock, literalblock
    
    Packages = RedHat
    
    [*.adoc]
    
    BasedOnStyles = RedHat
    
    [*.md]
    
    BasedOnStyles = RedHat
    
    # Ignore code surrounded by backticks or plus sign, parameters defaults, URLs.
    TokenIgnores = (\x60[^\n\x60]+\x60), ([^\n]+=[^\n]*), (\+[^\n]+\+), (http[^\n]+\[)
    
    # Match INI files. See: https://docs.errata.ai/vale/scoping
    [*.ini]
    
    BasedOnStyles = RedHat
    
    # Ignore code surrounded by backticks or plus sign, parameters defaults, URLs.
    TokenIgnores = (\x60[^\n\x60]+\x60), ([^\n]+=[^\n]*), (\+[^\n]+\+), (http[^\n]+\[)
    
    # Disabling rules (NO)
    RedHat.CaseSensitiveTerms = NO
    RedHat.ConfigMap = NO
    RedHat.Definitions = NO
    RedHat.Slash = NO
    RedHat.Spacing = NO
    RedHat.Spelling = NO
    RedHat.TermsSuggestions = NO

    Important

    By default, the .vale.ini file sets MinAlertLevel = suggestion. Consider changing MinAlertLevel to warning or error for new projects.

    For a complete list of possible configuration options, see configuration options for .vale.ini.

    Review the following Red Hat project .vale.ini files as reference for developing your own Vale configuration:

    • Run the vale sync command from the repository folder to download the rules to the project directory. For example:

      $ cd __<project_directory>__
      $ vale sync
       SUCCESS  Downloaded package 'RedHat'
      Downloading packages [1/1]
Verification
  • Run the vale command on one of your content files.

    $ cd <project_directory>
    $ vale <filename>

Creating a vocabulary for a project

Consider adding a vocabulary to your project when:

  • Missing words in the Vale dictionary cause spelling errors.

  • The word is too specific for other projects.

Procedure
  • Create or edit the vocabulary for your project: create or edit the .vale/styles/Vocab/<Project>/accept.txt file and add the missing word. Ensure the entry is not case-sensitive.

    Entry in the vocabulary, not case-sensitive
    [Pp]odman
  • Register the vocabulary in the .vale.ini file

    Vocab = <Project>
Verification
  • Run the vale command on a content file containing the word that is missing.

    $ cd <project_directory>
    $ vale <filename>
Additional resources

Integrating Vale into your Git workflow by using a GitHub Action

Integrate Vale into your GitHub content development workflow by creating a GitHub Action that uses the GitHub Action for Vale.

By creating a GitHub Action workflow for Vale, you can configure how Vale runs: you can set Vale flags and specify which Git workflow events trigger Vale jobs. For example, you can decide to:

  • Run Vale when a contributor creates a pull request.

  • Run Vale on only the changes.

  • Allow the merging of pull requests if the report has errors.

  • Block the merging of pull requests if the report has errors.

For a full list of supported configuration options, see Vale GitHub Action.

Prerequisites
  • Your content repository is on GitHub. For GitLab repos, see Defining a Vale onboarding strategy. WARNING: Because of GitHub token permissions, the Vale GitHub Action cannot post annotations to pull requests from a forked repository.

  • You have defined a continuous integration strategy for your project.

  • You have reviewed and bookmarked the official vale-action information at errata.ai.

Procedure
  1. Copy .vale.ini from vale-at-red-hat into the root of your GitHub repository and configure your style preferences.

  2. In the .github/workflows/ folder of your project repository, create a YAML file called vale.yml.

    • Tip: You can also click Actions and use the GitHub Actions wizard to initialize the vale.yml file and validate your configuration.

  3. Add the following configuration to the .github/workflows/lint-with-vale.yml file:

    ---
    name: Linting with Vale on pull request
    on: [pull_request]
    
    jobs:
      vale:
        name: Linting with Vale
        runs-on: ubuntu-22.04
        steps:
          - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
          - name: Install Asciidoctor
            run: sudo apt-get install -y asciidoctor
          - uses: errata-ai/vale-action@d89dee975228ae261d22c15adcd03578634d429c # v2.1.1
            with:
              filter_mode: diff_context
              vale_flags: "--no-exit --minAlertLevel=error --glob=*.adoc"
              reporter: github-pr-review
              fail_on_error: true
            env:
              # Required, set by GitHub actions automatically:
              # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
              GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
              REVIEWDOG_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}}
  4. Optional: Change the default configuration to suit the requirements of your project. For example, if you want to block PR merges when Vale errors exist, set fail_on_error to true.

  5. Commit and push the GitHub Action to the main branch of your GitHub repository and rebase your other branches.

Verification

To test your GitHub Action, change or add some content files and submit a pull request to the main docs branch. Vale will run and report an expandable status summary in the PR.

Enabling Vale GitLab Code Quality reports for merge requests

Use this procedure to enable the GitLab Code Quality widget for Vale. The widget reports style compliance issues in the GitLab merge request interface.

Procedure
  1. Create a .gitlab-ci.yml file at the repository root with the following content:

    image: node:16-alpine
    
    stages:
      - test
    
    code_quality:
      stage: test
      image:
        name: jdkato/vale:latest
        entrypoint: [""]
      tags: [shared]
      before_script:
        - apk update && apk add git
        - vale sync # Pull down VRH rules package specified in vale.ini
      script:
        # Get complete list of *.adoc files in the repository
        - FILES=$(find . -type f -name "*.adoc") 
        # Clean out conditions for wider Vale coverage in AsciiDoc
        - sed -i -e 's/ifdef::.*\|ifndef::.*\|ifeval::.*\|endif::.*/ /' ${FILES} 
        # Use a template to rearrange the vale JSON output
        # Run vale with --no-exit to pass the build with errors
        - vale ${FILES} --minAlertLevel=error --glob='*.adoc' --output="$(pwd)/vale-json.tmpl" > gl-code-quality-report.json
      artifacts:
        reports:
          codequality: gl-code-quality-report.json
      rules:
        - if: $CODE_QUALITY_DISABLED
          when: never
        - if: $CI_PIPELINE_SOURCE == "merge_request_event" # Run code quality job in merge request pipelines
        - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run code quality job in pipelines on the default branch (but not in other branch pipelines)
        - if: $CI_COMMIT_TAG # Run code quality job in pipelines for tags
    1. Update the $FILES step to match your documentation source type, for example, use *.md for markdown.
    2. Optional. Vale does not lint inside AsciiDoc conditional statements unless you pass the conditional variables as Asciidoctor attributes. You can bypass this limitation in the CI by temporarily removing ifdef and ifeval directives before linting with Vale. This step is only useful for AsciiDoc, and can be removed for other source formats.
  2. Create a vale-json.tmpl file at the repository root:

    {{- /* Modify Vale output https://docs.errata.ai/vale/cli#--output */ -}}
    
    {{- /* Keep track of our various counts */ -}}
    
    {{- $e := 0 -}}
    {{- $w := 0 -}}
    {{- $s := 0 -}}
    {{- $f := 0 -}}
    
    {{- /* Range over the linted files */ -}}
    
    [
    {{- $first := true -}}
    {{- range $jdx, $file := .Files -}}
      {{- $f = add1 $f -}}
      {{- $path := $file.Path -}}
    
      {{- /* Range over the file's alerts */ -}}
      {{- range $idx, $a := $file.Alerts -}}
        {{- if not $first -}},{{- end -}}
        {{- $first = false -}}
    
        {{- $error := "" -}}
        {{- if eq $a.Severity "error" -}}
          {{- $error = "critical" -}}
          {{- $e = add1 $e -}}
        {{- else if eq $a.Severity "warning" -}}
          {{- $error = "major" -}}
          {{- $w = add1 $w -}}
        {{- else -}}
          {{- $error = "minor" -}}
          {{- $s = add1 $s -}}
        {{- end}}
    
        {{- /* Variables setup */ -}}
    
        {{- $loc := printf "%d" $a.Line -}}
        {{- $check := printf "%s" $a.Check -}}
        {{- $message := printf "%s" $a.Message -}}
    
        {{- /* Compute the Base64 encoded fingerprint string */ -}}
        {{- $hashInput := printf "%s:%s:%s" $path $loc $message -}}
        {{- $Base64Encoded := b64enc $hashInput -}}
    
        {{- /* Output */ -}}
        {
          "description": "{{$check}}: {{ $message }}",
          "check_name": "vale-error-report",
          "fingerprint": "{{ $Base64Encoded }}",
          "severity": "{{ $error }}",
          "location": {
            "path": "{{ $path }}",
            "lines": {
              "begin": {{ $loc }}
            }
          }
        }
      {{- end -}}
    {{- end -}}
    ]
  3. Add the following entries to .gitignore:

    .vale
    gl-code-quality-report.json
  4. Commit the files to the local repository:

    git add .
    git commit -m "Add GitLab CI/CD code quality pipeline"
  5. Push the changes to the remote repository:

    git push -u origin main

When you merge the changes to the main branch, a code quality pipeline will run for every new commit added in a merge request. The code quality report is available in the Merge Request Overview tab.

Note

The GitLab CI job creates the code quality report by comparing a complete list of errors in the main branch and a list of errors in the merge request branch. This might cause a CI bottleneck on large repositories with 1000s of files, but for small and medium repositories, the CI processing time is negligible.

Additional resources

Using Vale with a continuous integration service

Consider using the Vale CLI with a continuous integration service when:

  • The goal is to measure or enforce the project compliance with the Style Guides.

  • Using Vale GitHub Action is not an option.

Procedure
  1. Configure your continuous integration service to download the vale CLI, the RedHat style and the Vale configuration file by using a download-vale.sh script such as:

    #!/bin/sh
    #
    # Copyright (c) 2021 Red Hat, Inc.
    # This program and the accompanying materials are made
    # available under the terms of the Eclipse Public License 2.0
    # which is available at https://www.eclipse.org/legal/epl-2.0/
    #
    # SPDX-License-Identifier: EPL-2.0
    #
    set -e
    
    # Download latest vale release
    gh release download --repo 'errata-ai/vale' --pattern '*Linux*.tar.gz'
    tar -xf vale*
    ./vale -v
    
    # Download latest vale configuration from vale-at-red-hat
    curl -Os https://raw.githubusercontent.com/redhat-documentation/vale-at-red-hat/master/.vale.ini
    
    # Download latest `RedHat` style
    mkdir .vale/styles || true
    cd .vale/styles
    gh release download --repo 'redhat-documentation/vale-at-red-hat' --pattern 'RedHat.zip'
    unzip RedHat.zip
  2. Configure your continuous integration service to validate language changes by using a validate-language-changes.sh script such as:

    #!/bin/sh
    #
    # Copyright (c) 2021 Red Hat, Inc.
    # This program and the accompanying materials are made
    # available under the terms of the Eclipse Public License 2.0
    # which is available at https://www.eclipse.org/legal/epl-2.0/
    #
    # SPDX-License-Identifier: EPL-2.0
    #
    set -e
    
    if [ -z "${GITHUB_BASE_REF}" ]
        then 
            MAINBRANCH="origin/main"
        else
            MAINBRANCH="origin/$GITHUB_BASE_REF"
    fi
    FILES=$(git diff --name-only --diff-filter=AM "$MAINBRANCH" "*.adoc")
    if [ -n "${FILES}" ]
        then
            echo "Validating languages on file added or modified in comparison to $MAINBRANCH with $(vale -v)"
            set -x
            # shellcheck disable=SC2086 # We want to split on spaces
            vale ${FILES}
        else
            echo "No files added or modified in comparison to $MAINBRANCH"
    fi