Merge pull request #527 from github/SupportAllYaml

Supporting yml and yaml file names
This commit is contained in:
Lukas Gravley 2020-08-06 11:26:52 -05:00 committed by GitHub
commit b76da563c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 11 deletions

View file

@ -243,9 +243,9 @@ a {
### dartanalyzer standard Config file
- `.github/linters/.dart-lint.yml`
- `.github/linters/analysis_options.yml`
- You can pass multiple rules and overwrite default rules
- File should be located at: `.github/linters/analysis_options.yaml`
- File should be located at: `.github/linters/analysis_options.yml`
### dartanalyzer disable single line
@ -263,7 +263,7 @@ int x = ''; // ignore: invalid_assignment
### dartanalyzer disable entire file
- You can disable entire files with the `analyzer.exclude` property in `analysis_options.yaml`
- You can disable entire files with the `analyzer.exclude` property in `analysis_options.yml`
```dart
analyzer:

View file

@ -43,7 +43,7 @@ COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path
CSS_FILE_NAME='.stylelintrc.json' # Name of the file
CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules
# Dart Vars
DART_FILE_NAME='analysis_options.yaml' # Name of the file
DART_FILE_NAME='analysis_options.yml' # Name of the file
DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules
# Docker Vars
DOCKERFILE_NAME='.dockerfilelintrc' # Name of the file
@ -477,6 +477,28 @@ GetLinterRules() {
LANGUAGE_FILE_NAME="${LANGUAGE_NAME}_FILE_NAME"
LANGUAGE_LINTER_RULES="${LANGUAGE_NAME}_LINTER_RULES"
##########################
# Get the file extension #
##########################
FILE_EXTENSION=$(echo "${!LANGUAGE_FILE_NAME}" | rev | cut -d'.' -f1 | rev)
FILE_NAME=$(echo "${!LANGUAGE_FILE_NAME}" | rev | cut -d'.' -f2 | rev)
###############################
# Set the secondary file name #
###############################
SECONDARY_FILE_NAME=''
#################################
# Check for secondary file name #
#################################
if [[ $FILE_EXTENSION == 'yml' ]]; then
# Need to see if yaml also exists
SECONDARY_FILE_NAME="$FILE_NAME.yaml"
elif [[ $FILE_EXTENSION == 'yaml' ]]; then
# need to see if yml also exists
SECONDARY_FILE_NAME="$FILE_NAME.yml"
fi
#####################################
# Validate we have the linter rules #
#####################################
@ -489,6 +511,19 @@ GetLinterRules() {
########################################
eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}"
else
# Check if we have secondary name to check
if [ -n "$SECONDARY_FILE_NAME" ]; then
# We have a secondary name to validate
if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}" ]; then
info "----------------------------------------------"
info "User provided file:[${SECONDARY_FILE_NAME}], setting rules file..."
########################################
# Update the path to the file location #
########################################
eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}"
fi
fi
########################################################
# No user default provided, using the template default #
########################################################
@ -1754,9 +1789,9 @@ if [ "${VALIDATE_XML}" == "true" ]; then
LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILE_ARRAY_XML[@]}"
fi
###############
################
# YAML LINTING #
###############
################
if [ "${VALIDATE_YAML}" == "true" ]; then
######################
# Lint the Yml Files #

View file

@ -732,7 +732,7 @@ function LintAnsibleFiles() {
########################################
# Make sure we dont lint certain files #
########################################
if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then
if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]] || [[ ${FILE} == *"vault.yaml"* ]] || [[ ${FILE} == *"galaxy.yaml"* ]]; then
# This is a file we dont look at
continue
fi