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.
-
Integrating Vale into your Git workflow by using a GitHub Action is not an option.
Procedure
-
Configure your continuous integration service to download the
vale
CLI, theRedHat
style and the Vale configuration file by using adownload-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
-
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") 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
Additional resources