mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-06 09:15:49 -05:00
Update explicit references to master
Wherever the script previously used the master branch, we now substitute our DEFAULT_BRANCH variable. We also create this variable at the beginning of the script, and default it to master if no value was passed in.
This commit is contained in:
parent
2ab14d961b
commit
33c2dd57f7
2 changed files with 10 additions and 8 deletions
|
@ -104,6 +104,7 @@ RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/r
|
||||||
ENV GITHUB_SHA=${GITHUB_SHA} \
|
ENV GITHUB_SHA=${GITHUB_SHA} \
|
||||||
GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \
|
GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH} \
|
||||||
GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \
|
GITHUB_WORKSPACE=${GITHUB_WORKSPACE} \
|
||||||
|
DEFAULT_BRANCH=${DEFAULT_BRANCH} \
|
||||||
VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \
|
VALIDATE_ALL_CODEBASE=${VALIDATE_ALL_CODEBASE} \
|
||||||
VALIDATE_YAML=${VALIDATE_YAML} \
|
VALIDATE_YAML=${VALIDATE_YAML} \
|
||||||
VALIDATE_JSON=${VALIDATE_JSON} \
|
VALIDATE_JSON=${VALIDATE_JSON} \
|
||||||
|
|
|
@ -69,6 +69,7 @@ LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON'
|
||||||
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
||||||
GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path
|
GITHUB_EVENT_PATH="${GITHUB_EVENT_PATH}" # Github Event Path
|
||||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
||||||
|
DEFAULT_BRANCH="${DEFAULT_BRANCH:-master}" # Default Git Branch to use (master by default)
|
||||||
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory
|
ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY}" # Ansible Directory
|
||||||
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files
|
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files
|
||||||
VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language
|
VALIDATE_YAML="${VALIDATE_YAML}" # Boolean to validate language
|
||||||
|
@ -1154,10 +1155,10 @@ BuildFileList()
|
||||||
echo "Pulling in code history and branches..."
|
echo "Pulling in code history and branches..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################################################################
|
#################################################################################
|
||||||
# Switch codebase back to master to get a list of all files changed #
|
# Switch codebase back to the default branch to get a list of all files changed #
|
||||||
#####################################################################
|
#################################################################################
|
||||||
SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout master 2>&1)
|
SWITCH_CMD=$(cd "$GITHUB_WORKSPACE" || exit; git pull --quiet; git checkout "$DEFAULT_BRANCH" 2>&1)
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Load the error code #
|
# Load the error code #
|
||||||
|
@ -1169,7 +1170,7 @@ BuildFileList()
|
||||||
##############################
|
##############################
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
# Error
|
# Error
|
||||||
echo "Failed to switch to master branch to get files changed!"
|
echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!"
|
||||||
echo "ERROR:[$SWITCH_CMD]"
|
echo "ERROR:[$SWITCH_CMD]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -1180,14 +1181,14 @@ BuildFileList()
|
||||||
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo "Generating Diff with:[git diff --name-only 'master..$GITHUB_SHA' --diff-filter=d]"
|
echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# Get the Array of files changed in the comits #
|
# Get the Array of files changed in the comits #
|
||||||
################################################
|
################################################
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "master..$GITHUB_SHA" --diff-filter=d 2>&1))
|
RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "$DEFAULT_BRANCH..$GITHUB_SHA" --diff-filter=d 2>&1))
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Load the error code #
|
# Load the error code #
|
||||||
|
@ -1910,7 +1911,7 @@ RunTestCases()
|
||||||
{
|
{
|
||||||
# This loop will run the test cases and exclude user code
|
# This loop will run the test cases and exclude user code
|
||||||
# This is called from the automation process to validate new code
|
# This is called from the automation process to validate new code
|
||||||
# When a PR is opened, the new code is validated with the master branch
|
# When a PR is opened, the new code is validated with the default branch
|
||||||
# version of linter.sh, and a new container is built with the latest codebase
|
# version of linter.sh, and a new container is built with the latest codebase
|
||||||
# for testing. That container is spun up, and ran,
|
# for testing. That container is spun up, and ran,
|
||||||
# with the flag: TEST_CASE_RUN=true
|
# with the flag: TEST_CASE_RUN=true
|
||||||
|
|
Loading…
Reference in a new issue