mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-21 21:50:59 -05:00
Improved ANSIBLE_DIRECTORY validation to support the repository root (#1111)
* Improved ANSIBLE_DIRECTORY validation to support the repository root Fixes #1110, which prevents linting playbooks at the root of the repository from being supported. * Trim whitespace * Remove undesired extra validation condition Addressing review feedback from @ ferrarimarco * Avoid mutating ANSIBLE_DIRECTORY beyond the extent that was already in place Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
This commit is contained in:
parent
68e5bdea03
commit
328b17bbc8
3 changed files with 11 additions and 4 deletions
|
@ -206,7 +206,7 @@ But if you wish to select or exclude specific linters, we give you full control
|
|||
| **ENV VAR** | **Default Value** | **Notes** |
|
||||
| ---------------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. |
|
||||
| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s), relative to `DEFAULT_WORKSPACE`. |
|
||||
| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s), relative to `DEFAULT_WORKSPACE`. Set to `.` to use the top-level of the `DEFAULT_WORKSPACE`. |
|
||||
| **CSS_FILE_NAME** | `.stylelintrc.json` | Filename for [Stylelint configuration](https://github.com/stylelint/stylelint) (ex: `.stylelintrc.yml`, `.stylelintrc.yaml`) |
|
||||
| **DEFAULT_BRANCH** | `master` | The name of the repository default branch. |
|
||||
| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. |
|
||||
|
|
|
@ -139,8 +139,15 @@ function GetValidationInfo() {
|
|||
# Remove first char
|
||||
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}"
|
||||
fi
|
||||
# Need to give it full path
|
||||
TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}"
|
||||
|
||||
if [ -z "${ANSIBLE_DIRECTORY}" ] || [[ ${ANSIBLE_DIRECTORY} == "." ]]; then
|
||||
# Catches the case where ANSIBLE_DIRECTORY="/" or ANSIBLE_DIRECTORY="."
|
||||
TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}"
|
||||
else
|
||||
# Need to give it full path
|
||||
TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}"
|
||||
fi
|
||||
|
||||
# Set the value
|
||||
ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}"
|
||||
debug "Setting Ansible directory to: ${ANSIBLE_DIRECTORY}"
|
||||
|
|
|
@ -195,7 +195,7 @@ function LintCodebase() {
|
|||
# Lint the file with the rules #
|
||||
################################
|
||||
LINT_CMD=$(
|
||||
cd "${WORKSPACE_PATH}/ansible" || exit
|
||||
cd "${ANSIBLE_DIRECTORY}" || exit
|
||||
${LINTER_COMMAND} "${FILE}" 2>&1
|
||||
)
|
||||
####################################
|
||||
|
|
Loading…
Reference in a new issue